diff --git a/common/src/main/java/us/myles/ViaVersion/AbstractViaConfig.java b/common/src/main/java/us/myles/ViaVersion/AbstractViaConfig.java index 2ee9bd131..409dbb36c 100644 --- a/common/src/main/java/us/myles/ViaVersion/AbstractViaConfig.java +++ b/common/src/main/java/us/myles/ViaVersion/AbstractViaConfig.java @@ -45,7 +45,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf private boolean serversideBlockConnections; private boolean reduceBlockStorageMemory; private boolean flowerStemWhenBlockAbove; + private boolean vineClimbFix; private boolean snowCollisionFix; + private boolean infestedBlocksFix; private int tabCompleteDelay; private boolean truncate1_14Books; private boolean leftHandedHandling; @@ -100,7 +102,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf serversideBlockConnections = getBoolean("serverside-blockconnections", false); reduceBlockStorageMemory = getBoolean("reduce-blockstorage-memory", false); flowerStemWhenBlockAbove = getBoolean("flowerstem-when-block-above", false); + vineClimbFix = getBoolean("vine-climb-fix", false); snowCollisionFix = getBoolean("fix-low-snow-collision", false); + infestedBlocksFix = getBoolean("fix-infested-block-breaking", true); tabCompleteDelay = getInt("1_13-tab-complete-delay", 0); truncate1_14Books = getBoolean("truncate-1_14-books", false); leftHandedHandling = getBoolean("left-handed-handling", true); @@ -232,7 +236,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf @Override public boolean isAutoTeam() { // Collision has to be enabled first - return isPreventCollision() && autoTeam; + return preventCollision && autoTeam; } @Override @@ -305,11 +309,21 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf return flowerStemWhenBlockAbove; } + @Override + public boolean isVineClimbFix() { + return vineClimbFix; + } + @Override public boolean isSnowCollisionFix() { return snowCollisionFix; } + @Override + public boolean isInfestedBlocksFix() { + return infestedBlocksFix; + } + @Override public int get1_13TabCompleteDelay() { return tabCompleteDelay; diff --git a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java index 140ec6bf2..e9bd1634c 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java +++ b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java @@ -280,6 +280,13 @@ public interface ViaVersionConfig { */ boolean isStemWhenBlockAbove(); + /** + * Vines not connected to any blocks will be mapped to air for 1.13+ clients to prevent them from climbing up. + * + * @return True if enabled + */ + boolean isVineClimbFix(); + /** * When activated, the 1-layer snow will be sent as 2-layer snow to 1.13+ clients to have collision. * @@ -287,6 +294,13 @@ public interface ViaVersionConfig { */ boolean isSnowCollisionFix(); + /** + * When activated, infested blocks will be mapped to their normal stone variants for 1.13+ clients. + * + * @return True if enabled + */ + boolean isInfestedBlocksFix(); + /** * When greater than 0, enables tab complete request delaying by x ticks * diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java index f9ae3188f..22c215455 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ConnectionData.java @@ -249,6 +249,10 @@ public class ConnectionData { initActions.addAll(ChorusPlantConnectionHandler.init()); initActions.add(TripwireConnectionHandler.init()); initActions.add(SnowyGrassConnectionHandler.init()); + if (Via.getConfig().isVineClimbFix()) { + initActions.add(VineConnectionHandler.init()); + } + for (String key : keyToId.keySet()) { WrappedBlockData wrappedBlockData = WrappedBlockData.fromString(key); for (ConnectorInitAction action : initActions) { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/VineConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/VineConnectionHandler.java new file mode 100644 index 000000000..e6b238f9a --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/VineConnectionHandler.java @@ -0,0 +1,45 @@ +package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections; + +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.api.minecraft.BlockFace; +import us.myles.ViaVersion.api.minecraft.Position; + +import java.util.HashSet; +import java.util.Set; + +class VineConnectionHandler extends ConnectionHandler { + private static final Set vines = new HashSet<>(); + + static ConnectionData.ConnectorInitAction init() { + final VineConnectionHandler connectionHandler = new VineConnectionHandler(); + return blockData -> { + if (!blockData.getMinecraftKey().equals("minecraft:vine")) return; + + vines.add(blockData.getSavedBlockStateId()); + ConnectionData.connectionHandlerMap.put(blockData.getSavedBlockStateId(), connectionHandler); + }; + } + + @Override + public int connect(UserConnection user, Position position, int blockState) { + if (isAttachedToBlock(user, position)) return blockState; + + Position upperPos = position.getRelative(BlockFace.TOP); + int upperBlock = getBlockData(user, upperPos); + if (vines.contains(upperBlock) && isAttachedToBlock(user, upperPos)) return blockState; + + // Map to air if not attached to block, and upper block is also not a vine attached to a block + return 0; + } + + private boolean isAttachedToBlock(UserConnection user, Position position) { + return isAttachedToBlock(user, position, BlockFace.EAST) + || isAttachedToBlock(user, position, BlockFace.WEST) + || isAttachedToBlock(user, position, BlockFace.NORTH) + || isAttachedToBlock(user, position, BlockFace.SOUTH); + } + + private boolean isAttachedToBlock(UserConnection user, Position position, BlockFace blockFace) { + return ConnectionData.occludingStates.contains(getBlockData(user, position.getRelative(blockFace))); + } +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java index 6af26aafb..ecd2c0952 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/MappingData.java @@ -141,12 +141,14 @@ public class MappingData { } // Remap infested blocks, as they are instantly breakabale in 1.13+ and can't be broken by those clients on older servers - oldToNew[1552] = 1; // stone - oldToNew[1553] = 14; // cobblestone - oldToNew[1554] = 3983; // stone bricks - oldToNew[1555] = 3984; // mossy stone bricks - oldToNew[1556] = 3985; // cracked stone bricks - oldToNew[1557] = 3986; // chiseled stone bricks + if (Via.getConfig().isInfestedBlocksFix()) { + oldToNew[1552] = 1; // stone + oldToNew[1553] = 14; // cobblestone + oldToNew[1554] = 3983; // stone bricks + oldToNew[1555] = 3984; // mossy stone bricks + oldToNew[1556] = 3985; // cracked stone bricks + oldToNew[1557] = 3986; // chiseled stone bricks + } } } } diff --git a/common/src/main/resources/assets/viaversion/config.yml b/common/src/main/resources/assets/viaversion/config.yml index 08fa85858..91481ec98 100644 --- a/common/src/main/resources/assets/viaversion/config.yml +++ b/common/src/main/resources/assets/viaversion/config.yml @@ -118,6 +118,8 @@ disable-1_13-auto-complete: false 1_13-tab-complete-delay: 0 # For 1.13 clients the smallest (1 layer) snow doesn't have collision, this will send these as 2 snowlayers for 1.13+ clients to prevent them bugging through them fix-low-snow-collision: false +# Infested blocks are instantly breakable for 1.13+ clients, resulting in them being unable to break them on sub 1.13 servers. This remaps them to their normal stone variants +fix-infested-block-breaking: true # In 1.14 the client page limit has been upped to 100 (from 50). Some anti-exploit plugins ban when clients go higher than 50. This option cuts edited books to 50 pages. truncate-1_14-books: false # This prevents clients using 1.9-1.13 on 1.8 servers from receiving no knockback/having velocity bugs whilst sneaking under a block. @@ -133,7 +135,7 @@ fix-1_14-health-nan: true # Should 1.15+ clients respawn instantly / without showing a death screen? use-1_15-instant-respawn: false # -# Enable serverside block-connections for 1.13+ clients +# Enable serverside block-connections for 1.13+ clients - all of the options in this section are built around this option serverside-blockconnections: false # Sets the method for the block connections (world for highly experimental (USE AT OWN RISK) world-level or packet for packet-level) blockconnection-method: packet @@ -142,6 +144,8 @@ reduce-blockstorage-memory: false # When activated with serverside-blockconnections, flower parts with blocks above will be sent as stems # Useful for lobbyservers where users can't build and those stems are used decoratively flowerstem-when-block-above: false +# Vines that are not connected to blocks will be mapped to air, else 1.13+ would still be able to climb up on them. +vine-climb-fix: false # #----------------------------------------------------------# # 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #