From a0884596e362597555b9f1131e55181806f2692f Mon Sep 17 00:00:00 2001 From: William Johnstone Date: Sat, 21 Mar 2020 22:59:16 +0000 Subject: [PATCH 1/9] Fix issue with players being able to update their own gamemode --- .../org/geysermc/connector/network/session/GeyserSession.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index acad78ea..57543952 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -395,7 +395,7 @@ public class GeyserSession implements CommandSender { startGamePacket.setBonusChestEnabled(false); startGamePacket.setStartingWithMap(false); startGamePacket.setTrustingPlayers(true); - startGamePacket.setDefaultPlayerPermission(PlayerPermission.OPERATOR); + startGamePacket.setDefaultPlayerPermission(PlayerPermission.MEMBER); startGamePacket.setServerChunkTickRange(4); startGamePacket.setBehaviorPackLocked(false); startGamePacket.setResourcePackLocked(false); From 5301c8c3f670a7a2132077a70582f96ee1ad36b5 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 25 Mar 2020 22:03:46 -0400 Subject: [PATCH 2/9] Implement bed colors Java Edition includes the bed color in the namespaced ID; in Bedrock edition it's one of the tag values as a block entity. This code involves creating a table between block states and bed color numbers and looking that up on chunk load or block update. --- .../translators/block/BlockTranslator.java | 52 +++++++++++++++++++ .../java/world/JavaChunkDataTranslator.java | 9 ++++ .../geysermc/connector/utils/ChunkUtils.java | 34 ++++++++++++ 3 files changed, 95 insertions(+) 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 18ac3e6d..f0c47410 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 @@ -50,6 +50,7 @@ public class BlockTranslator { private static final Int2ObjectMap BEDROCK_TO_JAVA_BLOCK_MAP = new Int2ObjectOpenHashMap<>(); private static final Map JAVA_ID_BLOCK_MAP = new HashMap<>(); private static final IntSet WATERLOGGED = new IntOpenHashSet(); + private static final Map BEDCOLORS = new HashMap<>(); private static final Map JAVA_ID_TO_BLOCK_ENTITY_MAP = new HashMap<>(); @@ -101,6 +102,50 @@ public class BlockTranslator { JAVA_ID_TO_BLOCK_ENTITY_MAP.put(javaBlockState, javaId); } + // If the Java ID is bed, signal that it needs a tag to show color + // The color is in the namespace ID in Java Edition but it's a tag in Bedrock. + byte bedcolor = -1; + if (javaId.contains("_bed[")) { + if (javaId.contains("minecraft:white")) { + bedcolor = 0; + } else if (javaId.contains("minecraft:orange")) { + bedcolor = 1; + } else if (javaId.contains("minecraft:magenta")) { + bedcolor = 2; + } else if (javaId.contains("minecraft:light_blue")) { + bedcolor = 3; + } else if (javaId.contains("minecraft:yellow")) { + bedcolor = 4; + } else if (javaId.contains("minecraft:lime")) { + bedcolor = 5; + } else if (javaId.contains("minecraft:pink")) { + bedcolor = 6; + } else if (javaId.contains("minecraft:gray")) { + bedcolor = 7; + } else if (javaId.contains("minecraft:light_gray")) { + bedcolor = 8; + } else if (javaId.contains("minecraft:cyan")) { + bedcolor = 9; + } else if (javaId.contains("minecraft:purple")) { + bedcolor = 10; + } else if (javaId.contains("minecraft:blue")) { + bedcolor = 11; + } else if (javaId.contains("minecraft:brown")) { + bedcolor = 12; + } else if (javaId.contains("minecraft:green")) { + bedcolor = 13; + } else if (javaId.contains("minecraft:red")) { + bedcolor = 14; + } else if (javaId.contains("minecraft:black")) { + bedcolor = 15; + } + + } + // -1 is used throughout the code to indicate no bed color. + if (bedcolor > -1) { + BEDCOLORS.put(javaBlockState, bedcolor); + } + if ("minecraft:water[level=0]".equals(javaId)) { waterRuntimeId = bedrockRuntimeId; } @@ -197,6 +242,13 @@ public class BlockTranslator { return WATERLOGGED.contains(state.getId()); } + public static byte getBedColor(BlockState state) { + if (BEDCOLORS.containsKey(state)) { + return BEDCOLORS.get(state); + } + return -1; + } + public static BlockState getJavaWaterloggedState(int bedrockId) { return BEDROCK_TO_JAVA_BLOCK_MAP.get(1 << 31 | bedrockId); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java index b9fca124..029a6f6f 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java @@ -105,7 +105,16 @@ public class JavaChunkDataTranslator extends PacketTranslator blockEntityEntry: chunkData.beds.int2ObjectEntrySet()) { + int x = blockEntityEntry.getValue().getInt("x"); + int y = blockEntityEntry.getValue().getInt("y"); + int z = blockEntityEntry.getValue().getInt("z"); + + ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntKey()), new Position(x, y, z)); + } chunkData.signs.clear(); + chunkData.beds.clear(); } else { final int xOffset = packet.getColumn().getX() << 4; final int zOffset = packet.getColumn().getZ() << 4; diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java index 8da00fa3..66238263 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java @@ -31,6 +31,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.nukkitx.math.vector.Vector3i; +import com.nukkitx.nbt.CompoundTagBuilder; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket; @@ -45,6 +46,8 @@ import org.geysermc.connector.world.chunk.ChunkPosition; import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.world.chunk.ChunkSection; +import java.util.concurrent.TimeUnit; + import static org.geysermc.connector.network.translators.block.BlockTranslator.BEDROCK_WATER_ID; public class ChunkUtils { @@ -72,6 +75,9 @@ public class ChunkUtils { if (BlockTranslator.getBlockEntityString(blockState) != null && BlockTranslator.getBlockEntityString(blockState).contains("sign[")) { Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z); chunkData.signs.put(blockState.getId(), TranslatorsInit.getBlockEntityTranslators().get("Sign").getDefaultBedrockTag("Sign", pos.getX(), pos.getY(), pos.getZ())); + } else if (BlockTranslator.getBedColor(blockState) > -1) { + Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z); + chunkData.beds.put(blockState.getId(), getBedTag(BlockTranslator.getBedColor(blockState), pos)); } else { section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id); } @@ -79,6 +85,7 @@ public class ChunkUtils { if (BlockTranslator.isWaterlogged(blockState)) { section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z), BEDROCK_WATER_ID); } + } } } @@ -128,6 +135,23 @@ public class ChunkUtils { waterPacket.setRuntimeId(0); } session.getUpstream().sendPacket(waterPacket); + + // Since Java stores bed colors as part of the namespaced ID and Bedrock stores it as a tag + // This is the only place I could find that interacts with the Java block state and block updates + byte bedcolor = BlockTranslator.getBedColor(blockState); + // If Bed Color is not -1 then it is indeed a bed with a color. + if (bedcolor > -1) { + Position pos = new Position(position.getX(), position.getY(), position.getZ()); + com.nukkitx.nbt.tag.CompoundTag finalbedTag = getBedTag(bedcolor, pos); + // Delay needed, otherwise newly placed beds will not get their color + // Delay is not needed for beds already placed on login + session.getConnector().getGeneralThreadPool().schedule(() -> + BlockEntityUtils.updateBlockEntity(session, finalbedTag, pos), + 500, + TimeUnit.MILLISECONDS + ); + } + } public static void sendEmptyChunks(GeyserSession session, Vector3i position, int radius, boolean forceUpdate) { @@ -160,5 +184,15 @@ public class ChunkUtils { public com.nukkitx.nbt.tag.CompoundTag[] blockEntities = new com.nukkitx.nbt.tag.CompoundTag[0]; public Int2ObjectMap signs = new Int2ObjectOpenHashMap<>(); + public Int2ObjectMap beds = new Int2ObjectOpenHashMap<>(); + } + public static com.nukkitx.nbt.tag.CompoundTag getBedTag(byte bedcolor, Position pos) { + CompoundTagBuilder tagBuilder = CompoundTagBuilder.builder() + .intTag("x", pos.getX()) + .intTag("y", pos.getY()) + .intTag("z", pos.getZ()) + .stringTag("id", "Bed"); + tagBuilder.byteTag("color", bedcolor); + return tagBuilder.buildRootTag(); } } From 545ab0f26894e6ea8c6cf5ece6405eba6b5a8f05 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 26 Mar 2020 10:22:44 -0400 Subject: [PATCH 3/9] Move bed-specific code to BedBlockEntityTranslator.java --- .../entity/BedBlockEntityTranslator.java | 41 +++++++++++++++++++ .../geysermc/connector/utils/ChunkUtils.java | 29 ++----------- 2 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BedBlockEntityTranslator.java diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BedBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BedBlockEntityTranslator.java new file mode 100644 index 00000000..42865918 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/entity/BedBlockEntityTranslator.java @@ -0,0 +1,41 @@ +package org.geysermc.connector.network.translators.block.entity; + +import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; +import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; +import com.nukkitx.math.vector.Vector3i; +import com.nukkitx.nbt.CompoundTagBuilder; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.block.BlockTranslator; +import org.geysermc.connector.utils.BlockEntityUtils; + +import java.util.concurrent.TimeUnit; + +public class BedBlockEntityTranslator { + + public static void checkForBedColor(GeyserSession session, BlockState blockState, Vector3i position) { + byte bedcolor = BlockTranslator.getBedColor(blockState); + // If Bed Color is not -1 then it is indeed a bed with a color. + if (bedcolor > -1) { + Position pos = new Position(position.getX(), position.getY(), position.getZ()); + com.nukkitx.nbt.tag.CompoundTag finalbedTag = getBedTag(bedcolor, pos); + // Delay needed, otherwise newly placed beds will not get their color + // Delay is not needed for beds already placed on login + session.getConnector().getGeneralThreadPool().schedule(() -> + BlockEntityUtils.updateBlockEntity(session, finalbedTag, pos), + 500, + TimeUnit.MILLISECONDS + ); + } + } + + public static com.nukkitx.nbt.tag.CompoundTag getBedTag(byte bedcolor, Position pos) { + CompoundTagBuilder tagBuilder = CompoundTagBuilder.builder() + .intTag("x", pos.getX()) + .intTag("y", pos.getY()) + .intTag("z", pos.getZ()) + .stringTag("id", "Bed"); + tagBuilder.byteTag("color", bedcolor); + return tagBuilder.buildRootTag(); + } + +} diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java index 66238263..0a3e3863 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java @@ -31,7 +31,6 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.nukkitx.math.vector.Vector3i; -import com.nukkitx.nbt.CompoundTagBuilder; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket; @@ -45,8 +44,7 @@ import org.geysermc.connector.network.translators.block.entity.BlockEntityTransl import org.geysermc.connector.world.chunk.ChunkPosition; import org.geysermc.connector.network.translators.block.BlockTranslator; import org.geysermc.connector.world.chunk.ChunkSection; - -import java.util.concurrent.TimeUnit; +import org.geysermc.connector.network.translators.block.entity.BedBlockEntityTranslator; import static org.geysermc.connector.network.translators.block.BlockTranslator.BEDROCK_WATER_ID; @@ -77,7 +75,7 @@ public class ChunkUtils { chunkData.signs.put(blockState.getId(), TranslatorsInit.getBlockEntityTranslators().get("Sign").getDefaultBedrockTag("Sign", pos.getX(), pos.getY(), pos.getZ())); } else if (BlockTranslator.getBedColor(blockState) > -1) { Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z); - chunkData.beds.put(blockState.getId(), getBedTag(BlockTranslator.getBedColor(blockState), pos)); + chunkData.beds.put(blockState.getId(), BedBlockEntityTranslator.getBedTag(BlockTranslator.getBedColor(blockState), pos)); } else { section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id); } @@ -138,19 +136,7 @@ public class ChunkUtils { // Since Java stores bed colors as part of the namespaced ID and Bedrock stores it as a tag // This is the only place I could find that interacts with the Java block state and block updates - byte bedcolor = BlockTranslator.getBedColor(blockState); - // If Bed Color is not -1 then it is indeed a bed with a color. - if (bedcolor > -1) { - Position pos = new Position(position.getX(), position.getY(), position.getZ()); - com.nukkitx.nbt.tag.CompoundTag finalbedTag = getBedTag(bedcolor, pos); - // Delay needed, otherwise newly placed beds will not get their color - // Delay is not needed for beds already placed on login - session.getConnector().getGeneralThreadPool().schedule(() -> - BlockEntityUtils.updateBlockEntity(session, finalbedTag, pos), - 500, - TimeUnit.MILLISECONDS - ); - } + BedBlockEntityTranslator.checkForBedColor(session, blockState, position); } @@ -186,13 +172,4 @@ public class ChunkUtils { public Int2ObjectMap signs = new Int2ObjectOpenHashMap<>(); public Int2ObjectMap beds = new Int2ObjectOpenHashMap<>(); } - public static com.nukkitx.nbt.tag.CompoundTag getBedTag(byte bedcolor, Position pos) { - CompoundTagBuilder tagBuilder = CompoundTagBuilder.builder() - .intTag("x", pos.getX()) - .intTag("y", pos.getY()) - .intTag("z", pos.getZ()) - .stringTag("id", "Bed"); - tagBuilder.byteTag("color", bedcolor); - return tagBuilder.buildRootTag(); - } } From 22908c4de73e7f428e4ffd143bf217526eb0b81f Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 26 Mar 2020 10:31:57 -0400 Subject: [PATCH 4/9] Remove whitespace --- .../src/main/java/org/geysermc/connector/utils/ChunkUtils.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java index 0a3e3863..340edd01 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java @@ -83,7 +83,6 @@ public class ChunkUtils { if (BlockTranslator.isWaterlogged(blockState)) { section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z), BEDROCK_WATER_ID); } - } } } @@ -137,7 +136,6 @@ public class ChunkUtils { // Since Java stores bed colors as part of the namespaced ID and Bedrock stores it as a tag // This is the only place I could find that interacts with the Java block state and block updates BedBlockEntityTranslator.checkForBedColor(session, blockState, position); - } public static void sendEmptyChunks(GeyserSession session, Vector3i position, int radius, boolean forceUpdate) { From e5766ef96a8197045fe03a9e611517ca83bfc482 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 26 Mar 2020 18:34:54 -0400 Subject: [PATCH 5/9] Store bed colors in Object2ByteOpenHashMap --- connector/pom.xml | 6 ++++++ .../network/translators/block/BlockTranslator.java | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/connector/pom.xml b/connector/pom.xml index 6d56fbca..0258e9a3 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -48,6 +48,12 @@ 8.1.1 compile + + com.nukkitx.fastutil + fastutil-object-byte-maps + 8.3.1 + compile + com.github.steveice10 opennbt 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 f0c47410..d3821154 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 @@ -35,6 +35,7 @@ import com.nukkitx.nbt.tag.ListTag; import gnu.trove.map.TObjectIntMap; import gnu.trove.map.hash.TObjectIntHashMap; import it.unimi.dsi.fastutil.ints.*; +import it.unimi.dsi.fastutil.objects.*; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.utils.Toolbox; @@ -50,7 +51,7 @@ public class BlockTranslator { private static final Int2ObjectMap BEDROCK_TO_JAVA_BLOCK_MAP = new Int2ObjectOpenHashMap<>(); private static final Map JAVA_ID_BLOCK_MAP = new HashMap<>(); private static final IntSet WATERLOGGED = new IntOpenHashSet(); - private static final Map BEDCOLORS = new HashMap<>(); + private static final Object2ByteOpenHashMap BEDCOLORS = new Object2ByteOpenHashMap<>(); private static final Map JAVA_ID_TO_BLOCK_ENTITY_MAP = new HashMap<>(); @@ -244,7 +245,7 @@ public class BlockTranslator { public static byte getBedColor(BlockState state) { if (BEDCOLORS.containsKey(state)) { - return BEDCOLORS.get(state); + return BEDCOLORS.getByte(state); } return -1; } From 7a402c40b334d8d32247c7f5e96aa5aa87865a68 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 27 Mar 2020 13:08:21 -0400 Subject: [PATCH 6/9] Use mappings to generate bed colors --- .../translators/block/BlockTranslator.java | 45 +++---------------- 1 file changed, 5 insertions(+), 40 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 d3821154..6597b9b3 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 @@ -105,46 +105,11 @@ public class BlockTranslator { // If the Java ID is bed, signal that it needs a tag to show color // The color is in the namespace ID in Java Edition but it's a tag in Bedrock. - byte bedcolor = -1; - if (javaId.contains("_bed[")) { - if (javaId.contains("minecraft:white")) { - bedcolor = 0; - } else if (javaId.contains("minecraft:orange")) { - bedcolor = 1; - } else if (javaId.contains("minecraft:magenta")) { - bedcolor = 2; - } else if (javaId.contains("minecraft:light_blue")) { - bedcolor = 3; - } else if (javaId.contains("minecraft:yellow")) { - bedcolor = 4; - } else if (javaId.contains("minecraft:lime")) { - bedcolor = 5; - } else if (javaId.contains("minecraft:pink")) { - bedcolor = 6; - } else if (javaId.contains("minecraft:gray")) { - bedcolor = 7; - } else if (javaId.contains("minecraft:light_gray")) { - bedcolor = 8; - } else if (javaId.contains("minecraft:cyan")) { - bedcolor = 9; - } else if (javaId.contains("minecraft:purple")) { - bedcolor = 10; - } else if (javaId.contains("minecraft:blue")) { - bedcolor = 11; - } else if (javaId.contains("minecraft:brown")) { - bedcolor = 12; - } else if (javaId.contains("minecraft:green")) { - bedcolor = 13; - } else if (javaId.contains("minecraft:red")) { - bedcolor = 14; - } else if (javaId.contains("minecraft:black")) { - bedcolor = 15; - } - - } - // -1 is used throughout the code to indicate no bed color. - if (bedcolor > -1) { - BEDCOLORS.put(javaBlockState, bedcolor); + JsonNode bedColor = entry.getValue().get("bed_color"); + if (bedColor != null) { + System.out.println(bedColor.intValue()); + // Converting to byte because the final tag value is a byte. bedColor.binaryValue() returns an array + BEDCOLORS.put(javaBlockState, (byte) bedColor.intValue()); } if ("minecraft:water[level=0]".equals(javaId)) { From 17258dcaf6b56e3a4a9ed9cb8395d6537526e6c6 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 27 Mar 2020 13:09:40 -0400 Subject: [PATCH 7/9] Remove debugging code --- .../connector/network/translators/block/BlockTranslator.java | 1 - 1 file changed, 1 deletion(-) 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 6597b9b3..45ac1e82 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 @@ -107,7 +107,6 @@ public class BlockTranslator { // The color is in the namespace ID in Java Edition but it's a tag in Bedrock. JsonNode bedColor = entry.getValue().get("bed_color"); if (bedColor != null) { - System.out.println(bedColor.intValue()); // Converting to byte because the final tag value is a byte. bedColor.binaryValue() returns an array BEDCOLORS.put(javaBlockState, (byte) bedColor.intValue()); } From 7b5bb22321dddb020d9a0a36855b0dc6c7f1effa Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 27 Mar 2020 14:21:34 -0400 Subject: [PATCH 8/9] Rename BEDCOLORS to BED_COLORS --- .../network/translators/block/BlockTranslator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 45ac1e82..908b88a8 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 @@ -51,7 +51,7 @@ public class BlockTranslator { private static final Int2ObjectMap BEDROCK_TO_JAVA_BLOCK_MAP = new Int2ObjectOpenHashMap<>(); private static final Map JAVA_ID_BLOCK_MAP = new HashMap<>(); private static final IntSet WATERLOGGED = new IntOpenHashSet(); - private static final Object2ByteOpenHashMap BEDCOLORS = new Object2ByteOpenHashMap<>(); + private static final Object2ByteOpenHashMap BED_COLORS = new Object2ByteOpenHashMap<>(); private static final Map JAVA_ID_TO_BLOCK_ENTITY_MAP = new HashMap<>(); @@ -108,7 +108,7 @@ public class BlockTranslator { JsonNode bedColor = entry.getValue().get("bed_color"); if (bedColor != null) { // Converting to byte because the final tag value is a byte. bedColor.binaryValue() returns an array - BEDCOLORS.put(javaBlockState, (byte) bedColor.intValue()); + BED_COLORS.put(javaBlockState, (byte) bedColor.intValue()); } if ("minecraft:water[level=0]".equals(javaId)) { @@ -208,8 +208,8 @@ public class BlockTranslator { } public static byte getBedColor(BlockState state) { - if (BEDCOLORS.containsKey(state)) { - return BEDCOLORS.getByte(state); + if (BED_COLORS.containsKey(state)) { + return BED_COLORS.getByte(state); } return -1; } From 7cbb0388e2b8cfbba3ccabdf2bab3bf16c9a0581 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 27 Mar 2020 16:16:33 -0400 Subject: [PATCH 9/9] Update mappings submodule --- connector/src/main/resources/mappings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/resources/mappings b/connector/src/main/resources/mappings index 278c7344..efc9db6b 160000 --- a/connector/src/main/resources/mappings +++ b/connector/src/main/resources/mappings @@ -1 +1 @@ -Subproject commit 278c73449aeeb4064c7513a68f98a49a5f463f0a +Subproject commit efc9db6b7d51bdf145230933ac23b321ac1c132d