From 6d7372445ce7e5a769c68e7c05411d533b9537c4 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sat, 22 Sep 2018 22:03:53 -0500 Subject: [PATCH] Expose attack cooldown methods for Player (#1412) --- ...e-attack-cooldown-methods-for-Player.patch | 38 +++++++++++++ Spigot-API-Patches/Improve-death-events.patch | 2 +- Spigot-API-Patches/Mob-Pathfinding-API.patch | 4 +- Spigot-API-Patches/PreSpawnerSpawnEvent.patch | 2 +- ...ow-chests-to-be-placed-with-NBT-data.patch | 2 +- ...e-attack-cooldown-methods-for-Player.patch | 54 +++++++++++++++++++ Spigot-Server-Patches/Fix-1420.patch | 2 +- .../Improve-death-events.patch | 16 +++--- .../PreSpawnerSpawnEvent.patch | 2 +- ...e-get-a-ParseException-in-IChatBaseC.patch | 2 +- 10 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 Spigot-API-Patches/Expose-attack-cooldown-methods-for-Player.patch create mode 100644 Spigot-Server-Patches/Expose-attack-cooldown-methods-for-Player.patch diff --git a/Spigot-API-Patches/Expose-attack-cooldown-methods-for-Player.patch b/Spigot-API-Patches/Expose-attack-cooldown-methods-for-Player.patch new file mode 100644 index 0000000000..33c3285d72 --- /dev/null +++ b/Spigot-API-Patches/Expose-attack-cooldown-methods-for-Player.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +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 +-- \ No newline at end of file diff --git a/Spigot-API-Patches/Improve-death-events.patch b/Spigot-API-Patches/Improve-death-events.patch index 63c744285f..d75e5fec81 100644 --- a/Spigot-API-Patches/Improve-death-events.patch +++ b/Spigot-API-Patches/Improve-death-events.patch @@ -15,7 +15,7 @@ items and experience which is otherwise only properly possible by using internal code. 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 +++ b/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java @@ -0,0 +0,0 @@ import org.bukkit.inventory.ItemStack; diff --git a/Spigot-API-Patches/Mob-Pathfinding-API.patch b/Spigot-API-Patches/Mob-Pathfinding-API.patch index 7013840e1c..d5da6453b7 100644 --- a/Spigot-API-Patches/Mob-Pathfinding-API.patch +++ b/Spigot-API-Patches/Mob-Pathfinding-API.patch @@ -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 new file mode 100644 -index 00000000..d6953b39 +index 000000000..d6953b390 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java @@ -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 -index d029d34e..48eddcd3 100644 +index d029d34ea..48eddcd30 100644 --- a/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; diff --git a/Spigot-API-Patches/PreSpawnerSpawnEvent.patch b/Spigot-API-Patches/PreSpawnerSpawnEvent.patch index 7619c3d308..abe3265af7 100644 --- a/Spigot-API-Patches/PreSpawnerSpawnEvent.patch +++ b/Spigot-API-Patches/PreSpawnerSpawnEvent.patch @@ -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 new file mode 100644 -index 00000000..d7221210 +index 000000000..d72212105 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/entity/PreSpawnerSpawnEvent.java @@ -0,0 +0,0 @@ diff --git a/Spigot-Server-Patches/Allow-chests-to-be-placed-with-NBT-data.patch b/Spigot-Server-Patches/Allow-chests-to-be-placed-with-NBT-data.patch index a1bc49ef67..7507f356a9 100644 --- a/Spigot-Server-Patches/Allow-chests-to-be-placed-with-NBT-data.patch +++ b/Spigot-Server-Patches/Allow-chests-to-be-placed-with-NBT-data.patch @@ -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 -index 9573a4ecd..7594c16e9 100644 +index 9573a4ecdf..7594c16e99 100644 --- a/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 diff --git a/Spigot-Server-Patches/Expose-attack-cooldown-methods-for-Player.patch b/Spigot-Server-Patches/Expose-attack-cooldown-methods-for-Player.patch new file mode 100644 index 0000000000..c99df2a6eb --- /dev/null +++ b/Spigot-Server-Patches/Expose-attack-cooldown-methods-for-Player.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +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() + { +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/Fix-1420.patch b/Spigot-Server-Patches/Fix-1420.patch index c90906acf6..94f7eae253 100644 --- a/Spigot-Server-Patches/Fix-1420.patch +++ b/Spigot-Server-Patches/Fix-1420.patch @@ -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 -index 187f02d4e..fcb1cb36a 100644 +index 187f02d4e4..fcb1cb36af 100644 --- a/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 { diff --git a/Spigot-Server-Patches/Improve-death-events.patch b/Spigot-Server-Patches/Improve-death-events.patch index 3005a261de..4009fad329 100644 --- a/Spigot-Server-Patches/Improve-death-events.patch +++ b/Spigot-Server-Patches/Improve-death-events.patch @@ -15,7 +15,7 @@ items and experience which is otherwise only properly possible by using internal code. 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 +++ b/src/main/java/net/minecraft/server/CombatTracker.java @@ -0,0 +0,0 @@ public class CombatTracker { @@ -27,7 +27,7 @@ index 63bdb96db..96dd1a7fa 100644 int i = this.f ? 300 : 100; 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 -index bcd7af059..f6c43bab4 100644 +index bcd7af059e..f6c43bab46 100644 --- a/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 @@ -55,7 +55,7 @@ index bcd7af059..f6c43bab4 100644 return SoundCategory.NEUTRAL; } 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 +++ b/src/main/java/net/minecraft/server/EntityArmorStand.java @@ -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 -index 1328f8889..13dd55549 100644 +index 1328f88898..13dd555491 100644 --- a/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 { @@ -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; } 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 +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -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 -index 17fab031b..ee8219e3b 100644 +index 17fab031b4..ee8219e3ba 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java @@ -0,0 +0,0 @@ public enum CraftSound { @@ -285,7 +285,7 @@ index 17fab031b..ee8219e3b 100644 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 -index b6cf96e18..96232aa07 100644 +index 44ee86ceec..bfb2f1a13c 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 { @@ -306,7 +306,7 @@ index b6cf96e18..96232aa07 100644 public void injectScaledMaxHealth(Collection 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 -index a553c2065..12e2c0f6e 100644 +index a553c20657..12e2c0f6e1 100644 --- a/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 { diff --git a/Spigot-Server-Patches/PreSpawnerSpawnEvent.patch b/Spigot-Server-Patches/PreSpawnerSpawnEvent.patch index 288876b863..67d7ee7a2a 100644 --- a/Spigot-Server-Patches/PreSpawnerSpawnEvent.patch +++ b/Spigot-Server-Patches/PreSpawnerSpawnEvent.patch @@ -9,7 +9,7 @@ SpawnerSpawnEvent gets called instead of the CreatureSpawnEvent for spawners. 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 +++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java @@ -0,0 +0,0 @@ public abstract class MobSpawnerAbstract { diff --git a/Spigot-Server-Patches/Return-null-if-we-get-a-ParseException-in-IChatBaseC.patch b/Spigot-Server-Patches/Return-null-if-we-get-a-ParseException-in-IChatBaseC.patch index 2b30acad24..7c403efe33 100644 --- a/Spigot-Server-Patches/Return-null-if-we-get-a-ParseException-in-IChatBaseC.patch +++ b/Spigot-Server-Patches/Return-null-if-we-get-a-ParseException-in-IChatBaseC.patch @@ -16,7 +16,7 @@ Shulkers) may need to be changed in order for it to re-save properly No more crashing though. 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 +++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java @@ -0,0 +0,0 @@ public interface IChatBaseComponent extends Message, Iterable