Paper/Spigot-Server-Patches/0281-Expose-attack-cooldown-methods-for-Player.patch
Aikar 1ab021ddca Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears 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:
565a5727 #533: Add consumed item, hand and consumeItem boolean to EntityShootBowEvent

CraftBukkit Changes:
927200a9 #718: Add consumed item, hand and consumeItem boolean to EntityShootBowEvent
2020-08-31 08:30:51 -04: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 cc20b73a993d021789840ed2ee7ba1fc8310dc5a..a6265c71973b67a0b49a41e2163a6f48876f1b41 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -2005,6 +2005,7 @@ public abstract class EntityHuman extends EntityLiving {
this.datawatcher.set(EntityHuman.bl, nbttagcompound);
}
+ public float getCooldownPeriod() { return this.eQ(); } // Paper - OBFHELPER
public float eQ() {
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 25175230583bbd6fcfc864dcbae4111dcc0d3b33..b90b35c08cdc9bb44aaf9f4824289fd0824c937f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1970,6 +1970,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()
{