mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
Expose attack cooldown methods for Player (#1412)
This commit is contained in:
parent
35d16a01a9
commit
6d7372445c
10 changed files with 108 additions and 16 deletions
|
@ -0,0 +1,38 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||||
|
Date: Tue, 4 Sep 2018 15:01:54 -0500
|
||||||
|
Subject: [PATCH] Expose attack cooldown methods for Player
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
index 6da68835..ae2b9752 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
|
||||||
|
* @param profile The new profile to use
|
||||||
|
*/
|
||||||
|
void setPlayerProfile(PlayerProfile profile);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns the amount of ticks the current cooldown lasts
|
||||||
|
+ *
|
||||||
|
+ * @return Amount of ticks cooldown will last
|
||||||
|
+ */
|
||||||
|
+ float getCooldownPeriod();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns the percentage of attack power available based on the cooldown (zero to one).
|
||||||
|
+ *
|
||||||
|
+ * @param adjustTicks Amount of ticks to add to cooldown counter for this calculation
|
||||||
|
+ * @return Percentage of attack power available
|
||||||
|
+ */
|
||||||
|
+ float getCooledAttackStrength(float adjustTicks);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Reset the cooldown counter to 0, effectively starting the cooldown period.
|
||||||
|
+ */
|
||||||
|
+ void resetCooldown();
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
// Spigot start
|
||||||
|
--
|
|
@ -15,7 +15,7 @@ items and experience which is otherwise only properly possible by using
|
||||||
internal code.
|
internal code.
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
diff --git a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
||||||
index ab9e81fd..a7b8f869 100644
|
index ab9e81fd2..a7b8f869c 100644
|
||||||
--- a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
--- a/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
||||||
+++ b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
+++ b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java
|
||||||
@@ -0,0 +0,0 @@ import org.bukkit.inventory.ItemStack;
|
@@ -0,0 +0,0 @@ import org.bukkit.inventory.ItemStack;
|
||||||
|
|
|
@ -13,7 +13,7 @@ You can use EntityPathfindEvent to cancel new pathfinds from overriding your cur
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
diff --git a/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 00000000..d6953b39
|
index 000000000..d6953b390
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
+++ b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +0,0 @@
|
||||||
|
@ -185,7 +185,7 @@ index 00000000..d6953b39
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
|
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
|
||||||
index d029d34e..48eddcd3 100644
|
index d029d34ea..48eddcd30 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/Mob.java
|
--- a/src/main/java/org/bukkit/entity/Mob.java
|
||||||
+++ b/src/main/java/org/bukkit/entity/Mob.java
|
+++ b/src/main/java/org/bukkit/entity/Mob.java
|
||||||
@@ -0,0 +0,0 @@ import org.bukkit.loot.Lootable;
|
@@ -0,0 +0,0 @@ import org.bukkit.loot.Lootable;
|
||||||
|
|
|
@ -10,7 +10,7 @@ spawners.
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java
|
diff --git a/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 00000000..d7221210
|
index 000000000..d72212105
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java
|
+++ b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +0,0 @@
|
||||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Allow chests to be placed with NBT data
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java
|
diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java
|
||||||
index 9573a4ecd..7594c16e9 100644
|
index 9573a4ecdf..7594c16e99 100644
|
||||||
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
|
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
|
||||||
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
|
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
|
||||||
@@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITic
|
@@ -0,0 +0,0 @@ public class TileEntityChest extends TileEntityLootable { // Paper - Remove ITic
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
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 c7dc6fe0ef..3df3d5bbef 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving {
|
||||||
|
this.datawatcher.set(EntityHuman.bA, nbttagcompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public float getCooldownPeriod() { return dG(); } // Paper - OBFHELPER
|
||||||
|
public float dG() {
|
||||||
|
return (float) (1.0D / this.getAttributeInstance(GenericAttributes.g).getValue() * 20.0D);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public float getCooledAttackStrength(float adjustTicks) { return r(adjustTicks); } // Paper - OBFHELPER
|
||||||
|
public float r(float f) {
|
||||||
|
return MathHelper.a(((float) this.aH + f) / this.dG(), 0.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public void resetCooldown() { dH(); } // Paper - OBFHELPER
|
||||||
|
public void dH() {
|
||||||
|
this.aH = 0;
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
|
index b6cf96e187..44ee86ceec 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||||
|
this.resourcePackStatus = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ //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()
|
||||||
|
{
|
||||||
|
--
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Fix #1420
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||||
index 187f02d4e..fcb1cb36a 100644
|
index 187f02d4e4..fcb1cb36af 100644
|
||||||
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
--- a/src/main/java/net/minecraft/server/EntityArrow.java
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
+++ b/src/main/java/net/minecraft/server/EntityArrow.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile {
|
@@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile {
|
||||||
|
|
|
@ -15,7 +15,7 @@ items and experience which is otherwise only properly possible by using
|
||||||
internal code.
|
internal code.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/CombatTracker.java b/src/main/java/net/minecraft/server/CombatTracker.java
|
diff --git a/src/main/java/net/minecraft/server/CombatTracker.java b/src/main/java/net/minecraft/server/CombatTracker.java
|
||||||
index 63bdb96db..96dd1a7fa 100644
|
index 63bdb96db8..96dd1a7fa4 100644
|
||||||
--- a/src/main/java/net/minecraft/server/CombatTracker.java
|
--- a/src/main/java/net/minecraft/server/CombatTracker.java
|
||||||
+++ b/src/main/java/net/minecraft/server/CombatTracker.java
|
+++ b/src/main/java/net/minecraft/server/CombatTracker.java
|
||||||
@@ -0,0 +0,0 @@ public class CombatTracker {
|
@@ -0,0 +0,0 @@ public class CombatTracker {
|
||||||
|
@ -27,7 +27,7 @@ index 63bdb96db..96dd1a7fa 100644
|
||||||
int i = this.f ? 300 : 100;
|
int i = this.f ? 300 : 100;
|
||||||
if (this.g && (!this.b.isAlive() || this.b.ticksLived - this.c > i)) {
|
if (this.g && (!this.b.isAlive() || this.b.ticksLived - this.c > i)) {
|
||||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||||
index bcd7af059..f6c43bab4 100644
|
index bcd7af059e..f6c43bab46 100644
|
||||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||||
|
@ -55,7 +55,7 @@ index bcd7af059..f6c43bab4 100644
|
||||||
return SoundCategory.NEUTRAL;
|
return SoundCategory.NEUTRAL;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||||
index 35afffede..e8e741374 100644
|
index 35afffedef..e8e7413748 100644
|
||||||
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||||
@@ -0,0 +0,0 @@ public class EntityArmorStand extends EntityLiving {
|
@@ -0,0 +0,0 @@ public class EntityArmorStand extends EntityLiving {
|
||||||
|
@ -69,7 +69,7 @@ index 35afffede..e8e741374 100644
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
index 1328f8889..13dd55549 100644
|
index 1328f88898..13dd555491 100644
|
||||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity {
|
@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity {
|
||||||
|
@ -207,7 +207,7 @@ index 1328f8889..13dd55549 100644
|
||||||
return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F;
|
return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
index 68f5842cf..5ab4e01ed 100644
|
index 68f5842cfe..5ab4e01edf 100644
|
||||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||||
@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
@@ -0,0 +0,0 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||||
|
@ -258,7 +258,7 @@ index 68f5842cf..5ab4e01ed 100644
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
|
||||||
index 17fab031b..ee8219e3b 100644
|
index 17fab031b4..ee8219e3ba 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
|
||||||
@@ -0,0 +0,0 @@ public enum CraftSound {
|
@@ -0,0 +0,0 @@ public enum CraftSound {
|
||||||
|
@ -285,7 +285,7 @@ index 17fab031b..ee8219e3b 100644
|
||||||
this.minecraftKey = minecraftKey;
|
this.minecraftKey = minecraftKey;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
index b6cf96e18..96232aa07 100644
|
index 44ee86ceec..bfb2f1a13c 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||||
|
@ -306,7 +306,7 @@ index b6cf96e18..96232aa07 100644
|
||||||
|
|
||||||
public void injectScaledMaxHealth(Collection<AttributeInstance> collection, boolean force) {
|
public void injectScaledMaxHealth(Collection<AttributeInstance> collection, boolean force) {
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
index a553c2065..12e2c0f6e 100644
|
index a553c20657..12e2c0f6e1 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||||
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
||||||
|
|
|
@ -9,7 +9,7 @@ SpawnerSpawnEvent gets called instead of the CreatureSpawnEvent for
|
||||||
spawners.
|
spawners.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||||
index 79600cd7..81d07606 100644
|
index 79600cd73e..81d0760634 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class MobSpawnerAbstract {
|
@@ -0,0 +0,0 @@ public abstract class MobSpawnerAbstract {
|
||||||
|
|
|
@ -16,7 +16,7 @@ Shulkers) may need to be changed in order for it to re-save properly
|
||||||
No more crashing though.
|
No more crashing though.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/IChatBaseComponent.java b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
diff --git a/src/main/java/net/minecraft/server/IChatBaseComponent.java b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
||||||
index ff14b3e09..03c148f4f 100644
|
index ff14b3e093..03c148f4f6 100644
|
||||||
--- a/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
--- a/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
||||||
+++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
+++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
||||||
@@ -0,0 +0,0 @@ public interface IChatBaseComponent extends Message, Iterable<IChatBaseComponent
|
@@ -0,0 +0,0 @@ public interface IChatBaseComponent extends Message, Iterable<IChatBaseComponent
|
||||||
|
|
Loading…
Reference in a new issue