diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java index 77a4fa123..31559d962 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java @@ -183,9 +183,9 @@ public class TranslatorsInit { inventoryTranslators.put(WindowType.BLAST_FURNACE, furnace); inventoryTranslators.put(WindowType.SMOKER, furnace); - inventoryTranslators.put(WindowType.GENERIC_3X3, new BlockInventoryTranslator(9, 23 << 4, ContainerType.DISPENSER)); - inventoryTranslators.put(WindowType.HOPPER, new BlockInventoryTranslator(5, 154 << 4, ContainerType.HOPPER)); - inventoryTranslators.put(WindowType.SHULKER_BOX, new BlockInventoryTranslator(27, 205 << 4, ContainerType.CONTAINER)); - //inventoryTranslators.put(WindowType.BEACON, new BlockInventoryTranslator(1, 138 << 4, ContainerType.BEACON)); //TODO + inventoryTranslators.put(WindowType.GENERIC_3X3, new BlockInventoryTranslator(9, "minecraft:dispenser[facing=north,triggered=false]", ContainerType.DISPENSER)); + inventoryTranslators.put(WindowType.HOPPER, new BlockInventoryTranslator(5, "minecraft:hopper[enabled=false,facing=down]", ContainerType.HOPPER)); + inventoryTranslators.put(WindowType.SHULKER_BOX, new BlockInventoryTranslator(27, "minecraft:shulker_box[facing=north]", ContainerType.CONTAINER)); + //inventoryTranslators.put(WindowType.BEACON, new BlockInventoryTranslator(1, "minecraft:beacon", ContainerType.BEACON)); //TODO } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java index 33815596e..115a7dbd7 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java @@ -31,7 +31,7 @@ import com.nukkitx.protocol.bedrock.data.InventoryAction; public class AnvilInventoryTranslator extends BlockInventoryTranslator { public AnvilInventoryTranslator() { - super(3, 145 << 4, ContainerType.ANVIL); + super(3, "minecraft:anvil[facing=north]", ContainerType.ANVIL); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BlockInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BlockInventoryTranslator.java index 0112dc9ee..54ab9bcec 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BlockInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BlockInventoryTranslator.java @@ -34,16 +34,16 @@ import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket; import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket; import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.TranslatorsInit; import org.geysermc.connector.network.translators.block.BlockEntry; -import org.geysermc.connector.world.GlobalBlockPalette; public class BlockInventoryTranslator extends ContainerInventoryTranslator { final int blockId; private final ContainerType containerType; - public BlockInventoryTranslator(int size, int blockId, ContainerType containerType) { + public BlockInventoryTranslator(int size, String javaBlockIdentifier, ContainerType containerType) { super(size); - this.blockId = blockId; + this.blockId = TranslatorsInit.getBlockTranslator().getBlockEntry(javaBlockIdentifier).getBedrockRuntimeId(); this.containerType = containerType; } @@ -54,7 +54,7 @@ public class BlockInventoryTranslator extends ContainerInventoryTranslator { UpdateBlockPacket blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(position); - blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(blockId)); + blockPacket.setRuntimeId(blockId); blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); session.getUpstream().sendPacket(blockPacket); inventory.setHolderPosition(position); @@ -88,7 +88,7 @@ public class BlockInventoryTranslator extends ContainerInventoryTranslator { UpdateBlockPacket blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(holderPos); - blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(realBlock.getBedrockId() << 4 | realBlock.getBedrockData())); + blockPacket.setRuntimeId(realBlock.getBedrockRuntimeId()); session.getUpstream().sendPacket(blockPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingStandInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingStandInventoryTranslator.java index 91f9d3270..532928e64 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingStandInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingStandInventoryTranslator.java @@ -33,7 +33,7 @@ import org.geysermc.connector.network.session.GeyserSession; public class BrewingStandInventoryTranslator extends BlockInventoryTranslator { public BrewingStandInventoryTranslator() { - super(5, 117 << 4, ContainerType.BREWING_STAND); + super(5, "minecraft:brewing_stand[has_bottle_0=false,has_bottle_1=false,has_bottle_2=false]", ContainerType.BREWING_STAND); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/DoubleChestInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/DoubleChestInventoryTranslator.java index 6c5057bbc..e0825ed87 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/DoubleChestInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/DoubleChestInventoryTranslator.java @@ -37,11 +37,10 @@ import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.TranslatorsInit; import org.geysermc.connector.network.translators.block.BlockEntry; -import org.geysermc.connector.world.GlobalBlockPalette; public class DoubleChestInventoryTranslator extends BlockInventoryTranslator { public DoubleChestInventoryTranslator(int size) { - super(size, 54 << 4, ContainerType.CONTAINER); + super(size, "minecraft:chest[facing=north,type=single,waterlogged=false]", ContainerType.CONTAINER); } @Override @@ -51,7 +50,7 @@ public class DoubleChestInventoryTranslator extends BlockInventoryTranslator { UpdateBlockPacket blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(position); - blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(blockId)); + blockPacket.setRuntimeId(blockId); blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); session.getUpstream().sendPacket(blockPacket); @@ -71,7 +70,7 @@ public class DoubleChestInventoryTranslator extends BlockInventoryTranslator { blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(pairPosition); - blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(blockId)); + blockPacket.setRuntimeId(blockId); blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); session.getUpstream().sendPacket(blockPacket); @@ -99,7 +98,7 @@ public class DoubleChestInventoryTranslator extends BlockInventoryTranslator { UpdateBlockPacket blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(holderPos); - blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(realBlock.getBedrockId() << 4 | realBlock.getBedrockData())); + blockPacket.setRuntimeId(realBlock.getBedrockRuntimeId()); session.getUpstream().sendPacket(blockPacket); holderPos = holderPos.add(Vector3i.UNIT_X); @@ -108,7 +107,7 @@ public class DoubleChestInventoryTranslator extends BlockInventoryTranslator { blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(holderPos); - blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(realBlock.getBedrockId() << 4 | realBlock.getBedrockData())); + blockPacket.setRuntimeId(realBlock.getBedrockRuntimeId()); session.getUpstream().sendPacket(blockPacket); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/EnchantmentInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/EnchantmentInventoryTranslator.java index 410bdc6a3..0b4ed4ba9 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/EnchantmentInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/EnchantmentInventoryTranslator.java @@ -31,7 +31,7 @@ import org.geysermc.connector.network.session.GeyserSession; public class EnchantmentInventoryTranslator extends BlockInventoryTranslator { public EnchantmentInventoryTranslator() { - super(2, 116 << 4, ContainerType.ENCHANTMENT); + super(2, "minecraft:enchanting_table", ContainerType.ENCHANTMENT); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java index 12a634ffd..a2eefac40 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java @@ -33,7 +33,7 @@ import org.geysermc.connector.network.session.GeyserSession; public class FurnaceInventoryTranslator extends BlockInventoryTranslator { public FurnaceInventoryTranslator() { - super(3, 61 << 4, ContainerType.FURNACE); + super(3, "minecraft:furnace[facing=north,lit=false]", ContainerType.FURNACE); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/SingleChestInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/SingleChestInventoryTranslator.java index 3b2c70d91..161117089 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/SingleChestInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/SingleChestInventoryTranslator.java @@ -34,7 +34,7 @@ import org.geysermc.connector.network.translators.TranslatorsInit; public class SingleChestInventoryTranslator extends BlockInventoryTranslator { public SingleChestInventoryTranslator(int size) { - super(size, 54 << 4, ContainerType.CONTAINER); + super(size, "minecraft:chest[facing=north,type=single,waterlogged=false]", ContainerType.CONTAINER); } @Override