From 605e63e1dff12400a201b8b83c186c4373134e7f Mon Sep 17 00:00:00 2001 From: Gerrygames Date: Thu, 17 Jan 2019 12:22:36 +0100 Subject: [PATCH] fix fence connections to stairs, remove waterlogged blocks from stair data --- .../AbstractFenceConnectionHandler.java | 10 ++++++++-- .../blockconnections/WallConnectionHandler.java | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) 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 c863b24ed..eb034452c 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 @@ -15,15 +15,17 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler { @Getter private Set blockStates = new HashSet<>(); private Map connectedBlockStates = new HashMap<>(); + private static final StairConnectionHandler STAIR_CONNECTION_HANDLER = new StairConnectionHandler(); public AbstractFenceConnectionHandler(String blockConnections, String key) { this.blockConnections = blockConnections; for (Map.Entry blockState : ConnectionData.keyToId.entrySet()) { if (key.equals(blockState.getKey().split("\\[")[0])) { + WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey()); + if (blockData.hasData("waterlogged") && blockData.getValue("waterlogged").equals("true")) continue; blockStates.add(blockState.getValue()); ConnectionData.connectionHandlerMap.put(blockState.getValue(), this); - WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey()); connectedBlockStates.put(getStates(blockData), blockState.getValue()); } } @@ -35,7 +37,6 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler { if (blockData.getValue("north").equals("true")) states |= 2; if (blockData.getValue("south").equals("true")) states |= 4; if (blockData.getValue("west").equals("true")) states |= 8; - if (blockData.hasData("waterlogged") && blockData.getValue("waterlogged").equals("true")) states |= 16; return states; } @@ -48,6 +49,11 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler { return states; } + @Override + public int getBlockData(UserConnection user, Position position) { + return STAIR_CONNECTION_HANDLER.connect(user, position, super.getBlockData(user, position)); + } + @Override public int connect(UserConnection user, Position position, int blockState) { final Integer newBlockState = connectedBlockStates.get(getStates(user, position, blockState)); diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/WallConnectionHandler.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/WallConnectionHandler.java index dda29f196..a31b79686 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/WallConnectionHandler.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/blockconnections/WallConnectionHandler.java @@ -21,13 +21,13 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler { @Override protected byte getStates(WrappedBlockData blockData) { byte states = super.getStates(blockData); - if (blockData.getValue("up").equals("true")) states |= 32; + if (blockData.getValue("up").equals("true")) states |= 16; return states; } protected byte getStates(UserConnection user, Position position, int blockState) { byte states = super.getStates(user, position, blockState); - if (up(user, position)) states |= 32; + if (up(user, position)) states |= 16; return states; }