Paper/Spigot-Server-Patches/0278-Expose-attack-cooldown-methods-for-Player.patch
Shane Freeder abca14ff96 Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
6f9fe1d9 #562: Add API to set equipment silently
bcddb754 SPIGOT-6256: Add method to check if the entity is in water

CraftBukkit Changes:
878b4375 #772: Add API to set equipment silently
22d7fcc9 SPIGOT-6256: Add method to check if the entity is in water
2020-12-21 07:56:22 +00:00

44 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Tue, 4 Sep 2018 15:02:00 -0500
Subject: [PATCH] Expose attack cooldown methods for Player
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 6f04a8cf06cf76f433ffcd81d0e41e9b36509948..c0b061f588944b2a9a82bea4087c68423c7e22a1 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -2012,6 +2012,7 @@ public abstract class EntityHuman extends EntityLiving {
this.datawatcher.set(EntityHuman.bl, nbttagcompound);
}
+ public float getCooldownPeriod() { return this.eR(); } // Paper - OBFHELPER
public float eR() {
return (float) (1.0D / this.b(GenericAttributes.ATTACK_SPEED) * 20.0D);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index c04ad85d16ce358dfbd72d1d84fb39970aa6aef0..27fa6f5c2e806da2bef12fb7ffbb0f9e90725594 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1993,6 +1993,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getInventory().setItemInMainHand(hand);
}
+ // Paper start
+ public float getCooldownPeriod() {
+ return getHandle().getCooldownPeriod();
+ }
+
+ public float getCooledAttackStrength(float adjustTicks) {
+ return getHandle().getAttackCooldown(adjustTicks);
+ }
+
+ public void resetCooldown() {
+ getHandle().resetAttackCooldown();
+ }
+ // Paper end
+
// Spigot start
private final Player.Spigot spigot = new Player.Spigot()
{