Java Code Examples for com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket#setRuntimeId()
The following examples show how to use
com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket#setRuntimeId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemFrameEntity.java From Geyser with MIT License | 6 votes |
/** * Updates the item frame as a block * @param session GeyserSession. */ public void updateBlock(GeyserSession session) { UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket(); updateBlockPacket.setDataLayer(0); updateBlockPacket.setBlockPosition(bedrockPosition); updateBlockPacket.setRuntimeId(bedrockRuntimeId); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); session.sendUpstreamPacket(updateBlockPacket); BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket(); blockEntityDataPacket.setBlockPosition(bedrockPosition); if (cachedTag != null) { blockEntityDataPacket.setData(cachedTag); } else { blockEntityDataPacket.setData(getDefaultTag()); } session.sendUpstreamPacket(blockEntityDataPacket); }
Example 2
Source File: BlockInventoryHolder.java From Geyser with MIT License | 6 votes |
@Override public void prepareInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) { Vector3i position = session.getPlayerEntity().getPosition().toInt(); position = position.add(Vector3i.UP); UpdateBlockPacket blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(position); blockPacket.setRuntimeId(blockId); blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY); session.sendUpstreamPacket(blockPacket); inventory.setHolderPosition(position); CompoundTag tag = CompoundTag.builder() .intTag("x", position.getX()) .intTag("y", position.getY()) .intTag("z", position.getZ()) .stringTag("CustomName", LocaleUtils.getLocaleString(inventory.getTitle(), session.getClientData().getLanguageCode())).buildRootTag(); BlockEntityDataPacket dataPacket = new BlockEntityDataPacket(); dataPacket.setData(tag); dataPacket.setBlockPosition(position); session.sendUpstreamPacket(dataPacket); }
Example 3
Source File: ItemFrameEntity.java From Geyser with MIT License | 5 votes |
@Override public boolean despawnEntity(GeyserSession session) { UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket(); updateBlockPacket.setDataLayer(0); updateBlockPacket.setBlockPosition(bedrockPosition); updateBlockPacket.setRuntimeId(0); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); session.sendUpstreamPacket(updateBlockPacket); session.getItemFrameCache().remove(position, entityId); valid = false; return true; }
Example 4
Source File: FlowerPotBlockEntityTranslator.java From Geyser with MIT License | 5 votes |
@Override public void updateBlock(GeyserSession session, BlockState blockState, Vector3i position) { BlockEntityUtils.updateBlockEntity(session, getTag(blockState, position), position); UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket(); updateBlockPacket.setDataLayer(0); updateBlockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(blockState)); updateBlockPacket.setBlockPosition(position); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); session.sendUpstreamPacket(updateBlockPacket); }
Example 5
Source File: BlockInventoryHolder.java From Geyser with MIT License | 5 votes |
@Override public void closeInventory(InventoryTranslator translator, GeyserSession session, Inventory inventory) { Vector3i holderPos = inventory.getHolderPosition(); Position pos = new Position(holderPos.getX(), holderPos.getY(), holderPos.getZ()); BlockState realBlock = session.getConnector().getWorldManager().getBlockAt(session, pos.getX(), pos.getY(), pos.getZ()); UpdateBlockPacket blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(holderPos); blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock)); session.sendUpstreamPacket(blockPacket); }
Example 6
Source File: UpdateBlockSerializer_v354.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateBlockPacket packet) { packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setRuntimeId(VarInts.readUnsignedInt(buffer)); int flagValue = VarInts.readUnsignedInt(buffer); Set<Flag> flags = packet.getFlags(); for (Flag flag : Flag.values()) { if ((flagValue & (1 << flag.ordinal())) != 0) { flags.add(flag); } } packet.setDataLayer(VarInts.readUnsignedInt(buffer)); }
Example 7
Source File: UpdateBlockSerializer_v388.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateBlockPacket packet) { packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setRuntimeId(VarInts.readUnsignedInt(buffer)); int flagValue = VarInts.readUnsignedInt(buffer); Set<Flag> flags = packet.getFlags(); for (Flag flag : Flag.values()) { if ((flagValue & (1 << flag.ordinal())) != 0) { flags.add(flag); } } packet.setDataLayer(VarInts.readUnsignedInt(buffer)); }
Example 8
Source File: UpdateBlockSerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateBlockPacket packet) { packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setRuntimeId(VarInts.readUnsignedInt(buffer)); int flagValue = VarInts.readUnsignedInt(buffer); Set<Flag> flags = packet.getFlags(); for (Flag flag : Flag.values()) { if ((flagValue & (1 << flag.ordinal())) != 0) { flags.add(flag); } } packet.setDataLayer(VarInts.readUnsignedInt(buffer)); }
Example 9
Source File: UpdateBlockSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateBlockPacket packet) { packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setRuntimeId(VarInts.readUnsignedInt(buffer)); int flagValue = VarInts.readUnsignedInt(buffer); Set<Flag> flags = packet.getFlags(); for (Flag flag : Flag.values()) { if ((flagValue & (1 << flag.ordinal())) != 0) { flags.add(flag); } } packet.setDataLayer(VarInts.readUnsignedInt(buffer)); }
Example 10
Source File: UpdateBlockSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateBlockPacket packet) { packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setRuntimeId(VarInts.readUnsignedInt(buffer)); int flagValue = VarInts.readUnsignedInt(buffer); Set<Flag> flags = packet.getFlags(); for (Flag flag : Flag.values()) { if ((flagValue & (1 << flag.ordinal())) != 0) { flags.add(flag); } } packet.setDataLayer(VarInts.readUnsignedInt(buffer)); }
Example 11
Source File: UpdateBlockSerializer_v332.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateBlockPacket packet) { packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setRuntimeId(VarInts.readUnsignedInt(buffer)); int flagValue = VarInts.readUnsignedInt(buffer); Set<Flag> flags = packet.getFlags(); for (Flag flag : Flag.values()) { if ((flagValue & (1 << flag.ordinal())) != 0) { flags.add(flag); } } packet.setDataLayer(VarInts.readUnsignedInt(buffer)); }
Example 12
Source File: UpdateBlockSerializer_v291.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateBlockPacket packet) { packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); packet.setRuntimeId(VarInts.readUnsignedInt(buffer)); int flagValue = VarInts.readUnsignedInt(buffer); Set<Flag> flags = packet.getFlags(); for (Flag flag : Flag.values()) { if ((flagValue & (1 << flag.ordinal())) != 0) { flags.add(flag); } } packet.setDataLayer(VarInts.readUnsignedInt(buffer)); }