2020-05-06 17:48:49 +08:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2020-03-27 11:04:19 +08:00
From: nossr50 <nossr50@gmail.com>
Date: Thu, 26 Mar 2020 19:44:50 -0700
Subject: [PATCH] Add PlayerAttackEntityCooldownResetEvent
2021-03-16 15:19:45 +08:00
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
2021-05-03 03:37:24 +08:00
index dc9e12c38d1682f6c4558ca07b781de2226c0621..850225509a5398ddcc9335bf88e99bde662bfc91 100644
2021-03-16 15:19:45 +08:00
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
2021-03-16 21:04:28 +08:00
@@ -1931,7 +1931,16 @@ public abstract class EntityLiving extends Entity {
2020-03-27 11:04:19 +08:00
2020-04-27 15:34:45 +08:00
EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
if (damagesource.getEntity() instanceof EntityHuman) {
2020-06-26 09:53:21 +08:00
- ((EntityHuman) damagesource.getEntity()).resetAttackCooldown(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
2020-03-27 11:04:19 +08:00
+ // Paper start - PlayerAttackEntityCooldownResetEvent
2020-04-27 15:34:45 +08:00
+ if (damagesource.getEntity() instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) damagesource.getEntity();
2020-08-02 13:39:36 +08:00
+ if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent(player.getBukkitEntity(), this.getBukkitEntity(), player.getAttackCooldown(0F)).callEvent()) {
+ player.resetAttackCooldown();
2020-04-27 15:34:45 +08:00
+ }
+ } else {
2020-08-02 13:39:36 +08:00
+ ((EntityHuman) damagesource.getEntity()).resetAttackCooldown();
2020-03-27 11:04:19 +08:00
+ }
+ // Paper end
2020-04-27 15:34:45 +08:00
}
if (event.isCancelled()) {
return false;