Paper/Spigot-Server-Patches/0465-Add-PlayerAttackEntityCooldownResetEvent.patch
Aikar 9788250b10
Clean up a lot of obfuscation helpers and impls
This fixes a bug with obfuscation helpers for attack cooldown
But every other change should stay the same.

Cleaning up a lot of helpers that pointed to already unobfuscated items.
Also adds final to many of the obfhelpers to assist with inlining.

This is pretty much a patch maintenance
2020-08-02 01:39:36 -04:00

29 lines
1.9 KiB
Diff

From 0000000000000000000000000000000000000000 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/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 574d9ef4f4f0e95a66252b0428ff84c72d5bc32c..ce823833a0b308aeb11902652157575eabf09e3b 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1822,7 +1822,16 @@ public abstract class EntityLiving extends Entity {
EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
if (damagesource.getEntity() instanceof EntityHuman) {
- ((EntityHuman) damagesource.getEntity()).resetAttackCooldown(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
+ // Paper start - PlayerAttackEntityCooldownResetEvent
+ if (damagesource.getEntity() instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) damagesource.getEntity();
+ if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent(player.getBukkitEntity(), this.getBukkitEntity(), player.getAttackCooldown(0F)).callEvent()) {
+ player.resetAttackCooldown();
+ }
+ } else {
+ ((EntityHuman) damagesource.getEntity()).resetAttackCooldown();
+ }
+ // Paper end
}
if (event.isCancelled()) {
return false;