Paper/Spigot-Server-Patches/0285-Expose-attack-cooldown-methods-for-Player.patch

54 Zeilen
2.2 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 d9e5d71a87140c90b79902887bd2f481f02956dc..afc665bfe9d527ca8d19f3ab9df0900d87f2d3f2 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -2006,14 +2006,17 @@ public abstract class EntityHuman extends EntityLiving {
2020-06-25 16:09:55 +02:00
this.datawatcher.set(EntityHuman.bs, nbttagcompound);
}
2020-06-25 16:09:55 +02:00
+ public float getCooldownPeriod() { return this.eR(); } // Paper - OBFHELPER
public float eR() {
return (float) (1.0D / this.b(GenericAttributes.ATTACK_SPEED) * 20.0D);
}
2020-06-25 16:09:55 +02:00
+ public float getCooledAttackStrength(float adjustTicks) { return getAttackCooldown(adjustTicks); } // Paper - OBFHELPER
public float getAttackCooldown(float f) {
return MathHelper.a(((float) this.aA + f) / this.eR(), 0.0F, 1.0F);
}
+ public void resetCooldown() { this.ey(); } // Paper - OBFHELPER
2020-06-25 16:09:55 +02:00
public void resetAttackCooldown() {
this.aA = 0;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 59b3baaa84c2f1db2d17c677c9eb0299b1494329..7828241b4ab42fd684e62950ddac85b3e43e45be 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1977,6 +1977,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().getCooledAttackStrength(adjustTicks);
+ }
+
+ public void resetCooldown() {
+ getHandle().resetCooldown();
+ }
+ // Paper end
+
// Spigot start
private final Player.Spigot spigot = new Player.Spigot()
{