Add option to fix delayed shield blocking (#2415)

This commit is contained in:
R0bbyYT 2021-04-01 20:03:13 +02:00 committed by GitHub
parent 1d311284fd
commit 956492bca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 0 deletions

View File

@ -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
*

View File

@ -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;

View File

@ -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 {

View File

@ -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)