From 1ae07ecf527ba75705bc1a4a7b941bf3c29b749a Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Sat, 16 Jun 2018 14:54:35 -0500 Subject: [PATCH] Make shield blocking delay configurable (#1154) Resolves #1153 --- ...e-shield-blocking-delay-configurable.patch | 33 +++++++++ ...e-shield-blocking-delay-configurable.patch | 73 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 Spigot-API-Patches/0112-Make-shield-blocking-delay-configurable.patch create mode 100644 Spigot-Server-Patches/0309-Make-shield-blocking-delay-configurable.patch diff --git a/Spigot-API-Patches/0112-Make-shield-blocking-delay-configurable.patch b/Spigot-API-Patches/0112-Make-shield-blocking-delay-configurable.patch new file mode 100644 index 0000000000..963a3aaac5 --- /dev/null +++ b/Spigot-API-Patches/0112-Make-shield-blocking-delay-configurable.patch @@ -0,0 +1,33 @@ +From 26b6ff3f923bd7ff541cfc78312596986fdee0c1 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Sat, 16 Jun 2018 01:17:39 -0500 +Subject: [PATCH] Make shield blocking delay configurable + + +diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java +index 42cf95e1..5921c952 100644 +--- a/src/main/java/org/bukkit/entity/LivingEntity.java ++++ b/src/main/java/org/bukkit/entity/LivingEntity.java +@@ -385,5 +385,19 @@ public interface LivingEntity extends Attributable, Entity, Damageable, Projecti + * @param arrows Number of arrows to stick in this entity + */ + void setArrowsStuck(int arrows); ++ ++ /** ++ * Get the delay (in ticks) before blocking is effective for this entity ++ * ++ * @return Delay in ticks ++ */ ++ int getShieldBlockingDelay(); ++ ++ /** ++ * Set the delay (in ticks) before blocking is effective for this entity ++ * ++ * @param delay Delay in ticks ++ */ ++ void setShieldBlockingDelay(int delay); + // Paper end + } +-- +2.11.0 + diff --git a/Spigot-Server-Patches/0309-Make-shield-blocking-delay-configurable.patch b/Spigot-Server-Patches/0309-Make-shield-blocking-delay-configurable.patch new file mode 100644 index 0000000000..0393ad2eb8 --- /dev/null +++ b/Spigot-Server-Patches/0309-Make-shield-blocking-delay-configurable.patch @@ -0,0 +1,73 @@ +From f66a15194cb9f3ecfa8b4bbfdc458493f5a73436 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Sat, 16 Jun 2018 01:18:16 -0500 +Subject: [PATCH] Make shield blocking delay configurable + + +diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +index 03a9a96f..99ad40fa 100644 +--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java ++++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +@@ -519,4 +519,9 @@ public class PaperWorldConfig { + disableEnderpearlExploit = getBoolean("game-mechanics.disable-unloaded-chunk-enderpearl-exploit", disableEnderpearlExploit); + log("Disable Unloaded Chunk Enderpearl Exploit: " + (disableEnderpearlExploit ? "enabled" : "disabled")); + } ++ ++ public int shieldBlockingDelay = 5; ++ private void shieldBlockingDelay() { ++ shieldBlockingDelay = getInt("game-mechanics.shield-blocking-delay", 5); ++ } + } +diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java +index 9adcabd4..65bc19b1 100644 +--- a/src/main/java/net/minecraft/server/EntityLiving.java ++++ b/src/main/java/net/minecraft/server/EntityLiving.java +@@ -2481,7 +2481,7 @@ public abstract class EntityLiving extends Entity { + if (this.isHandRaised() && !this.activeItem.isEmpty()) { + Item item = this.activeItem.getItem(); + +- return item.f(this.activeItem) != EnumAnimation.BLOCK ? false : item.e(this.activeItem) - this.bp >= 5; ++ return item.f(this.activeItem) != EnumAnimation.BLOCK ? false : item.e(this.activeItem) - this.bp >= getShieldBlockingDelay(); // Paper - shieldBlockingDelay + } else { + return false; + } +@@ -2569,4 +2569,16 @@ public abstract class EntityLiving extends Entity { + public boolean cS() { + return true; + } ++ ++ // Paper start ++ public int shieldBlockingDelay = world.paperConfig.shieldBlockingDelay; ++ ++ public int getShieldBlockingDelay() { ++ return shieldBlockingDelay; ++ } ++ ++ public void setShieldBlockingDelay(int shieldBlockingDelay) { ++ this.shieldBlockingDelay = shieldBlockingDelay; ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +index a7b07637..14fb474f 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +@@ -515,5 +515,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { + public void setArrowsStuck(int arrows) { + getHandle().setArrowCount(arrows); + } ++ ++ @Override ++ public int getShieldBlockingDelay() { ++ return getHandle().getShieldBlockingDelay(); ++ } ++ ++ @Override ++ public void setShieldBlockingDelay(int delay) { ++ getHandle().setShieldBlockingDelay(delay); ++ } + // Paper end + } +-- +2.17.1 +