From d686a009d1832a8cce4ffdf5bc4c48869f108ad6 Mon Sep 17 00:00:00 2001 From: SupremeMortal <6178101+SupremeMortal@users.noreply.github.com> Date: Tue, 31 Dec 2019 23:24:54 +0000 Subject: [PATCH] Fix most block palette issues. Others are due to the mappings --- .../translators/block/BlockTranslator.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java index c4f31abe..5a6e06ac 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java @@ -28,6 +28,8 @@ public class BlockTranslator { private static final Int2IntMap JAVA_TO_BEDROCK_LIQUID_MAP = new Int2IntOpenHashMap(); private static final Int2ObjectMap BEDROCK_TO_JAVA_LIQUID_MAP = new Int2ObjectOpenHashMap<>(); + private static final int BLOCK_STATE_VERSION = 17760256; + static { /* Load block palette */ InputStream stream = Toolbox.getResource("bedrock/runtime_block_states.dat"); @@ -99,7 +101,10 @@ public class BlockTranslator { private static CompoundTag buildBedrockState(JsonNode node) { CompoundTagBuilder tagBuilder = CompoundTag.builder(); - tagBuilder.stringTag("name", node.get("bedrock_identifier").textValue()); + tagBuilder.stringTag("name", node.get("bedrock_identifier").textValue()) + .intTag("version", BlockTranslator.BLOCK_STATE_VERSION); + + CompoundTagBuilder statesBuilder = CompoundTag.builder(); // check for states if (node.has("bedrock_states")) { @@ -110,17 +115,17 @@ public class BlockTranslator { JsonNode stateValue = stateEntry.getValue(); switch (stateValue.getNodeType()) { case BOOLEAN: - tagBuilder.booleanTag(stateEntry.getKey(), stateValue.booleanValue()); + statesBuilder.booleanTag(stateEntry.getKey(), stateValue.booleanValue()); continue; case STRING: - tagBuilder.stringTag(stateEntry.getKey(), stateValue.textValue()); + statesBuilder.stringTag(stateEntry.getKey(), stateValue.textValue()); continue; case NUMBER: - tagBuilder.intTag(stateEntry.getKey(), stateValue.intValue()); + statesBuilder.intTag(stateEntry.getKey(), stateValue.intValue()); } } } - return tagBuilder.build("block"); + return tagBuilder.tag(statesBuilder.build("states")).build("block"); } public static int getBedrockBlockId(BlockState state) {