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