Fix block ids

This commit is contained in:
AJ Ferguson 2019-12-23 17:00:31 -09:00
parent 8061e2d76d
commit 46205600dd
8 changed files with 19 additions and 20 deletions

View file

@ -183,9 +183,9 @@ public class TranslatorsInit {
inventoryTranslators.put(WindowType.BLAST_FURNACE, furnace); inventoryTranslators.put(WindowType.BLAST_FURNACE, furnace);
inventoryTranslators.put(WindowType.SMOKER, furnace); inventoryTranslators.put(WindowType.SMOKER, furnace);
inventoryTranslators.put(WindowType.GENERIC_3X3, new BlockInventoryTranslator(9, 23 << 4, ContainerType.DISPENSER)); inventoryTranslators.put(WindowType.GENERIC_3X3, new BlockInventoryTranslator(9, "minecraft:dispenser[facing=north,triggered=false]", ContainerType.DISPENSER));
inventoryTranslators.put(WindowType.HOPPER, new BlockInventoryTranslator(5, 154 << 4, ContainerType.HOPPER)); inventoryTranslators.put(WindowType.HOPPER, new BlockInventoryTranslator(5, "minecraft:hopper[enabled=false,facing=down]", ContainerType.HOPPER));
inventoryTranslators.put(WindowType.SHULKER_BOX, new BlockInventoryTranslator(27, 205 << 4, ContainerType.CONTAINER)); inventoryTranslators.put(WindowType.SHULKER_BOX, new BlockInventoryTranslator(27, "minecraft:shulker_box[facing=north]", ContainerType.CONTAINER));
//inventoryTranslators.put(WindowType.BEACON, new BlockInventoryTranslator(1, 138 << 4, ContainerType.BEACON)); //TODO //inventoryTranslators.put(WindowType.BEACON, new BlockInventoryTranslator(1, "minecraft:beacon", ContainerType.BEACON)); //TODO
} }
} }

View file

@ -31,7 +31,7 @@ import com.nukkitx.protocol.bedrock.data.InventoryAction;
public class AnvilInventoryTranslator extends BlockInventoryTranslator { public class AnvilInventoryTranslator extends BlockInventoryTranslator {
public AnvilInventoryTranslator() { public AnvilInventoryTranslator() {
super(3, 145 << 4, ContainerType.ANVIL); super(3, "minecraft:anvil[facing=north]", ContainerType.ANVIL);
} }
@Override @Override

View file

@ -34,16 +34,16 @@ import com.nukkitx.protocol.bedrock.packet.ContainerOpenPacket;
import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket; import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession; 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.network.translators.block.BlockEntry;
import org.geysermc.connector.world.GlobalBlockPalette;
public class BlockInventoryTranslator extends ContainerInventoryTranslator { public class BlockInventoryTranslator extends ContainerInventoryTranslator {
final int blockId; final int blockId;
private final ContainerType containerType; private final ContainerType containerType;
public BlockInventoryTranslator(int size, int blockId, ContainerType containerType) { public BlockInventoryTranslator(int size, String javaBlockIdentifier, ContainerType containerType) {
super(size); super(size);
this.blockId = blockId; this.blockId = TranslatorsInit.getBlockTranslator().getBlockEntry(javaBlockIdentifier).getBedrockRuntimeId();
this.containerType = containerType; this.containerType = containerType;
} }
@ -54,7 +54,7 @@ public class BlockInventoryTranslator extends ContainerInventoryTranslator {
UpdateBlockPacket blockPacket = new UpdateBlockPacket(); UpdateBlockPacket blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(position); blockPacket.setBlockPosition(position);
blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(blockId)); blockPacket.setRuntimeId(blockId);
blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
session.getUpstream().sendPacket(blockPacket); session.getUpstream().sendPacket(blockPacket);
inventory.setHolderPosition(position); inventory.setHolderPosition(position);
@ -88,7 +88,7 @@ public class BlockInventoryTranslator extends ContainerInventoryTranslator {
UpdateBlockPacket blockPacket = new UpdateBlockPacket(); UpdateBlockPacket blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos); blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(realBlock.getBedrockId() << 4 | realBlock.getBedrockData())); blockPacket.setRuntimeId(realBlock.getBedrockRuntimeId());
session.getUpstream().sendPacket(blockPacket); session.getUpstream().sendPacket(blockPacket);
} }
} }

View file

@ -33,7 +33,7 @@ import org.geysermc.connector.network.session.GeyserSession;
public class BrewingStandInventoryTranslator extends BlockInventoryTranslator { public class BrewingStandInventoryTranslator extends BlockInventoryTranslator {
public BrewingStandInventoryTranslator() { 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 @Override

View file

@ -37,11 +37,10 @@ import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.TranslatorsInit; import org.geysermc.connector.network.translators.TranslatorsInit;
import org.geysermc.connector.network.translators.block.BlockEntry; import org.geysermc.connector.network.translators.block.BlockEntry;
import org.geysermc.connector.world.GlobalBlockPalette;
public class DoubleChestInventoryTranslator extends BlockInventoryTranslator { public class DoubleChestInventoryTranslator extends BlockInventoryTranslator {
public DoubleChestInventoryTranslator(int size) { public DoubleChestInventoryTranslator(int size) {
super(size, 54 << 4, ContainerType.CONTAINER); super(size, "minecraft:chest[facing=north,type=single,waterlogged=false]", ContainerType.CONTAINER);
} }
@Override @Override
@ -51,7 +50,7 @@ public class DoubleChestInventoryTranslator extends BlockInventoryTranslator {
UpdateBlockPacket blockPacket = new UpdateBlockPacket(); UpdateBlockPacket blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(position); blockPacket.setBlockPosition(position);
blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(blockId)); blockPacket.setRuntimeId(blockId);
blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
session.getUpstream().sendPacket(blockPacket); session.getUpstream().sendPacket(blockPacket);
@ -71,7 +70,7 @@ public class DoubleChestInventoryTranslator extends BlockInventoryTranslator {
blockPacket = new UpdateBlockPacket(); blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(pairPosition); blockPacket.setBlockPosition(pairPosition);
blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(blockId)); blockPacket.setRuntimeId(blockId);
blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); blockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
session.getUpstream().sendPacket(blockPacket); session.getUpstream().sendPacket(blockPacket);
@ -99,7 +98,7 @@ public class DoubleChestInventoryTranslator extends BlockInventoryTranslator {
UpdateBlockPacket blockPacket = new UpdateBlockPacket(); UpdateBlockPacket blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos); blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(realBlock.getBedrockId() << 4 | realBlock.getBedrockData())); blockPacket.setRuntimeId(realBlock.getBedrockRuntimeId());
session.getUpstream().sendPacket(blockPacket); session.getUpstream().sendPacket(blockPacket);
holderPos = holderPos.add(Vector3i.UNIT_X); holderPos = holderPos.add(Vector3i.UNIT_X);
@ -108,7 +107,7 @@ public class DoubleChestInventoryTranslator extends BlockInventoryTranslator {
blockPacket = new UpdateBlockPacket(); blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos); blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(realBlock.getBedrockId() << 4 | realBlock.getBedrockData())); blockPacket.setRuntimeId(realBlock.getBedrockRuntimeId());
session.getUpstream().sendPacket(blockPacket); session.getUpstream().sendPacket(blockPacket);
} }

View file

@ -31,7 +31,7 @@ import org.geysermc.connector.network.session.GeyserSession;
public class EnchantmentInventoryTranslator extends BlockInventoryTranslator { public class EnchantmentInventoryTranslator extends BlockInventoryTranslator {
public EnchantmentInventoryTranslator() { public EnchantmentInventoryTranslator() {
super(2, 116 << 4, ContainerType.ENCHANTMENT); super(2, "minecraft:enchanting_table", ContainerType.ENCHANTMENT);
} }
@Override @Override

View file

@ -33,7 +33,7 @@ import org.geysermc.connector.network.session.GeyserSession;
public class FurnaceInventoryTranslator extends BlockInventoryTranslator { public class FurnaceInventoryTranslator extends BlockInventoryTranslator {
public FurnaceInventoryTranslator() { public FurnaceInventoryTranslator() {
super(3, 61 << 4, ContainerType.FURNACE); super(3, "minecraft:furnace[facing=north,lit=false]", ContainerType.FURNACE);
} }
@Override @Override

View file

@ -34,7 +34,7 @@ import org.geysermc.connector.network.translators.TranslatorsInit;
public class SingleChestInventoryTranslator extends BlockInventoryTranslator { public class SingleChestInventoryTranslator extends BlockInventoryTranslator {
public SingleChestInventoryTranslator(int size) { public SingleChestInventoryTranslator(int size) {
super(size, 54 << 4, ContainerType.CONTAINER); super(size, "minecraft:chest[facing=north,type=single,waterlogged=false]", ContainerType.CONTAINER);
} }
@Override @Override