diff --git a/api/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java b/api/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java index feedb33f0..776c58097 100644 --- a/api/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java +++ b/api/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java @@ -76,6 +76,13 @@ public interface ViaVersionConfig { */ boolean isShieldBlocking(); + /** + * Whether the player can block with the shield without a delay. + * + * @return {@code true} if non delayed shield blocking is enabled. + */ + boolean isNoDelayShieldBlocking(); + /** * Get if armor stand positions are fixed so holograms show up at the correct height in 1.9 & 1.10 * diff --git a/common/src/main/java/us/myles/ViaVersion/AbstractViaConfig.java b/common/src/main/java/us/myles/ViaVersion/AbstractViaConfig.java index 426539e78..816bd1f6c 100644 --- a/common/src/main/java/us/myles/ViaVersion/AbstractViaConfig.java +++ b/common/src/main/java/us/myles/ViaVersion/AbstractViaConfig.java @@ -32,6 +32,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf private boolean useNewDeathmessages; private boolean suppressMetadataErrors; private boolean shieldBlocking; + private boolean noDelayShieldBlocking; private boolean hologramPatch; private boolean pistonAnimationPatch; private boolean bossbarPatch; @@ -91,6 +92,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf useNewDeathmessages = getBoolean("use-new-deathmessages", true); suppressMetadataErrors = getBoolean("suppress-metadata-errors", false); shieldBlocking = getBoolean("shield-blocking", true); + noDelayShieldBlocking = getBoolean("no-delay-shield-blocking", false); hologramPatch = getBoolean("hologram-patch", false); pistonAnimationPatch = getBoolean("piston-animation-patch", false); bossbarPatch = getBoolean("bossbar-patch", true); @@ -170,6 +172,11 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf return shieldBlocking; } + @Override + public boolean isNoDelayShieldBlocking() { + return noDelayShieldBlocking; + } + @Override public boolean isHologramPatch() { return hologramPatch; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index e137e4f4c..29cd075eb 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -303,6 +303,12 @@ public class WorldPackets { Item shield = new Item(442, (byte) 1, (short) 0, null); tracker.setSecondHand(shield); } + } + + // Uses left or right hand to start blocking depending on the no delay setting + boolean noDelayBlocking = Via.getConfig().isNoDelayShieldBlocking(); + + if (noDelayBlocking && hand == 1 || !noDelayBlocking && hand == 0) { wrapper.cancel(); } } else { diff --git a/common/src/main/resources/assets/viaversion/config.yml b/common/src/main/resources/assets/viaversion/config.yml index 82f41e6ec..9ee7068ab 100644 --- a/common/src/main/resources/assets/viaversion/config.yml +++ b/common/src/main/resources/assets/viaversion/config.yml @@ -167,6 +167,9 @@ auto-team: true suppress-metadata-errors: false # When enabled 1.9+ will be able to block by using shields shield-blocking: true +# If this setting is active, the main hand is used instead of the off hand to trigger the blocking of the player. +# With the main hand the blocking starts way faster. +no-delay-shield-blocking: false # Enable player tick simulation, this fixes eating, drinking, nether portals. simulate-pt: true # Should we use nms player to simulate packets, (may fix anti-cheat issues)