diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/AbstractFenceConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/AbstractFenceConnectionHandler.java index 14a172ff7..85bcdcc92 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/AbstractFenceConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/AbstractFenceConnectionHandler.java @@ -4,6 +4,8 @@ import lombok.Getter; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.minecraft.BlockFace; import us.myles.ViaVersion.api.minecraft.Position; +import us.myles.ViaVersion.api.protocol.ProtocolVersion; +import us.myles.ViaVersion.protocols.base.ProtocolInfo; import java.util.HashMap; import java.util.HashSet; @@ -47,10 +49,11 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler { protected byte getStates(UserConnection user, Position position, int blockState) { byte states = 0; - if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)))) states |= 1; - if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)))) states |= 2; - if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)))) states |= 4; - if (connects(BlockFace.WEST, getBlockData(user, position.getRelative(BlockFace.WEST)))) states |= 8; + boolean pre1_12 = user.get(ProtocolInfo.class).getServerProtocolVersion() < ProtocolVersion.v1_12.getId(); + if (connects(BlockFace.EAST, getBlockData(user, position.getRelative(BlockFace.EAST)), pre1_12)) states |= 1; + if (connects(BlockFace.NORTH, getBlockData(user, position.getRelative(BlockFace.NORTH)), pre1_12)) states |= 2; + if (connects(BlockFace.SOUTH, getBlockData(user, position.getRelative(BlockFace.SOUTH)), pre1_12)) states |= 4; + if (connects(BlockFace.WEST, getBlockData(user, position.getRelative(BlockFace.WEST)), pre1_12)) states |= 8; return states; } @@ -65,7 +68,9 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler { return newBlockState == null ? blockState : newBlockState; } - protected boolean connects(BlockFace side, int blockState) { - return blockStates.contains(blockState) || blockConnections != null && ConnectionData.blockConnectionData.containsKey(blockState) && ConnectionData.blockConnectionData.get(blockState).connectsTo(blockConnections, side.opposite()); + protected boolean connects(BlockFace side, int blockState, boolean pre1_12) { + return blockStates.contains(blockState) || blockConnections != null + && ConnectionData.blockConnectionData.containsKey(blockState) + && ConnectionData.blockConnectionData.get(blockState).connectsTo(blockConnections, side.opposite(), pre1_12); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/BlockData.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/BlockData.java index 86fc10e36..a8adc7a15 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/BlockData.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/BlockData.java @@ -6,14 +6,20 @@ import java.util.HashMap; import java.util.Map; public class BlockData { - private Map connectData = new HashMap<>(); + private Map connectData = new HashMap<>(); - public void put(String key, Boolean[] booleans) { + public void put(String key, boolean[] booleans) { connectData.put(key, booleans); } - public boolean connectsTo(String blockConnection, BlockFace face) { - final Boolean[] booleans = connectData.get(blockConnection); + public boolean connectsTo(String blockConnection, BlockFace face, boolean pre1_12AbstractFence) { + boolean[] booleans = null; + if (pre1_12AbstractFence) { + booleans = connectData.get("allFalseIfStairPre1_12"); // https://minecraft.gamepedia.com/Java_Edition_1.12 + } + if (booleans == null) { + booleans = connectData.get(blockConnection); + } return booleans != null && booleans[face.ordinal()]; } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ChorusPlantConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ChorusPlantConnectionHandler.java index 72d7c0a94..7e60ba630 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ChorusPlantConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/ChorusPlantConnectionHandler.java @@ -3,10 +3,11 @@ 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 us.myles.ViaVersion.api.protocol.ProtocolVersion; +import us.myles.ViaVersion.protocols.base.ProtocolInfo; import java.util.ArrayList; import java.util.List; -import java.util.Map; public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler { private int endstone; @@ -46,13 +47,13 @@ public class ChorusPlantConnectionHandler extends AbstractFenceConnectionHandler @Override protected byte getStates(UserConnection user, Position position, int blockState) { byte states = super.getStates(user, position, blockState); - if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)))) states |= 16; - if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)))) states |= 32; + if (connects(BlockFace.TOP, getBlockData(user, position.getRelative(BlockFace.TOP)), false)) states |= 16; + if (connects(BlockFace.BOTTOM, getBlockData(user, position.getRelative(BlockFace.BOTTOM)), false)) states |= 32; return states; } @Override - protected boolean connects(BlockFace side, int blockState) { + protected boolean connects(BlockFace side, int blockState, boolean pre1_12) { return getBlockStates().contains(blockState) || (side == BlockFace.BOTTOM && blockState == endstone); } } 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 4825adf82..62308142e 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 @@ -212,17 +212,18 @@ public class ConnectionData { for (Entry type : entry.getValue().getAsJsonObject().entrySet()) { String name = type.getKey(); JsonObject object = type.getValue().getAsJsonObject(); - Boolean[] data = new Boolean[6]; + boolean[] data = new boolean[6]; for (BlockFace value : BlockFace.values()) { String face = value.toString().toLowerCase(); if (object.has(face)) { data[value.ordinal()] = object.getAsJsonPrimitive(face).getAsBoolean(); - } else { - data[value.ordinal()] = false; } } blockData.put(name, data); } + if (entry.getKey().contains("stairs")) { + blockData.put("allFalseIfStairPre1_12", new boolean[6]); + } blockConnectionData.put(id, blockData); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/RedstoneConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/RedstoneConnectionHandler.java index 4c8f74d97..f6e30957b 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/RedstoneConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/RedstoneConnectionHandler.java @@ -83,6 +83,6 @@ public class RedstoneConnectionHandler extends ConnectionHandler { private boolean connects(BlockFace side, int blockState) { final BlockData blockData = ConnectionData.blockConnectionData.get(blockState); - return blockData != null && blockData.connectsTo("redstoneConnections", side.opposite()); + return blockData != null && blockData.connectsTo("redstoneConnections", side.opposite(), false); } }