From 0000000000000000000000000000000000000000 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 a0a846a2e60bdc17537bd697137f65321c1a61d8..e1110274a9f6b8f7007537732ec8eff7e72040ee 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -363,4 +363,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/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 571ca7409cdce36ce228c7f3ebf2bce7a87897df..0a954a83e29f2ffc622675f671416bdadc1d3f6a 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3668,12 +3668,24 @@ public abstract class LivingEntity extends Entity { if (this.isUsingItem() && !this.useItem.isEmpty()) { Item item = this.useItem.getItem(); - return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem) - this.useItemRemaining >= 5; + return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem) - this.useItemRemaining >= getShieldBlockingDelay(); // Paper - shieldBlockingDelay } else { return false; } } + // Paper start + public int shieldBlockingDelay = level.paperConfig.shieldBlockingDelay; + + public int getShieldBlockingDelay() { + return shieldBlockingDelay; + } + + public void setShieldBlockingDelay(int shieldBlockingDelay) { + this.shieldBlockingDelay = shieldBlockingDelay; + } + // Paper end + public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 7beb84da34e58b18cd83a53eab2bcf703e8bf35e..d9f06a7ff7c6b4c60ddbc5d7131916fabd0fc4d2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -712,5 +712,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 }