PaperMC/Spigot-Server-Patches/0490-Add-PlayerAttackEntityCooldownResetEvent.patch
nossr50 a2064a4135
Add PlayerAttackEntityCooldownResetEvent
This event is called when processing a player's attack on an entity
right before their attack strength cd is reset, there are no existing
events that fire within this period of time so it was impossible to
capture the players attack strength via API prior to this commit.

The event is cancellable, which will just skip over the normal reset of
attack strength cd
2020-04-21 02:10:43 -04:00

26 lines
1.2 KiB
Diff

From 21dfa9a7108ea72db2e34c0ad40cff723f7f792c Mon Sep 17 00:00:00 2001
From: nossr50 <nossr50@gmail.com>
Date: Thu, 26 Mar 2020 19:44:50 -0700
Subject: [PATCH] Add PlayerAttackEntityCooldownResetEvent
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 8a3f2b5e40..2e186134ea 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -1057,7 +1057,11 @@ public abstract class EntityHuman extends EntityLiving {
f *= 0.2F + f2 * f2 * 0.8F;
f1 *= f2;
- this.ey();
+ // Paper start - PlayerAttackEntityCooldownResetEvent
+ if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent((Player) this.getBukkitEntity(), entity.getBukkitEntity(), this.getCooledAttackStrength(0F)).callEvent()) {
+ this.resetCooldown(); // reset it like normal
+ }
+ // Paper end
if (f > 0.0F || f1 > 0.0F) {
boolean flag = f2 > 0.9F;
boolean flag1 = false;
--
2.25.1