2020-05-06 09:48:49 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2020-03-27 03:04:19 +00:00
From: nossr50 <nossr50@gmail.com>
Date: Thu, 26 Mar 2020 19:44:50 -0700
Subject: [PATCH] Add PlayerAttackEntityCooldownResetEvent
2020-04-27 07:34:45 +00:00
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2020-07-22 23:35:44 +00:00
index 574d9ef4f4f0e95a66252b0428ff84c72d5bc32c..ad92d6d30f0e3280c2e4cab6d0c96280d40ae2ef 100644
2020-04-27 07:34:45 +00:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2020-07-22 23:35:44 +00:00
@@ -1822,7 +1822,16 @@ public abstract class EntityLiving extends Entity {
2020-03-27 03:04:19 +00:00
2020-04-27 07:34:45 +00: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 01:53:21 +00: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 03:04:19 +00:00
+ // Paper start - PlayerAttackEntityCooldownResetEvent
2020-04-27 07:34:45 +00:00
+ if (damagesource.getEntity() instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) damagesource.getEntity();
+ if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent(player.getBukkitEntity(), this.getBukkitEntity(), player.getCooledAttackStrength(0F)).callEvent()) {
+ player.resetCooldown();
+ }
+ } else {
+ ((EntityHuman) damagesource.getEntity()).resetCooldown();
2020-03-27 03:04:19 +00:00
+ }
+ // Paper end
2020-04-27 07:34:45 +00:00
}
if (event.isCancelled()) {
return false;