com.nukkitx.nbt.NbtUtils Java Examples
The following examples show how to use
com.nukkitx.nbt.NbtUtils.
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: UpdateTradeSerializer_v340.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, UpdateTradePacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknownInt(VarInts.readInt(buffer)); packet.setScreen2(VarInts.readInt(buffer) >= 40); packet.setTradeTier(VarInts.readInt(buffer)); packet.setWilling(buffer.readBoolean()); packet.setTraderUniqueEntityId(VarInts.readLong(buffer)); packet.setPlayerUniqueEntityId(VarInts.readLong(buffer)); packet.setDisplayName(BedrockUtils.readString(buffer)); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setOffers(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #2
Source File: UpdateTradeSerializer_v354.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, UpdateTradePacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknownInt(VarInts.readInt(buffer)); packet.setTradeTier(VarInts.readInt(buffer)); packet.setWilling(buffer.readBoolean()); packet.setTraderUniqueEntityId(VarInts.readLong(buffer)); packet.setPlayerUniqueEntityId(VarInts.readLong(buffer)); packet.setDisplayName(BedrockUtils.readString(buffer)); packet.setScreen2(buffer.readBoolean()); packet.setWilling(buffer.readBoolean()); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setOffers(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #3
Source File: UpdateTradeSerializer_v361.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, UpdateTradePacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknownInt(VarInts.readInt(buffer)); packet.setTradeTier(VarInts.readInt(buffer)); packet.setWilling(buffer.readBoolean()); packet.setTraderUniqueEntityId(VarInts.readLong(buffer)); packet.setPlayerUniqueEntityId(VarInts.readLong(buffer)); packet.setDisplayName(BedrockUtils.readString(buffer)); packet.setScreen2(buffer.readBoolean()); packet.setWilling(buffer.readBoolean()); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setOffers(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #4
Source File: UpdateTradeSerializer_v361.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, UpdateTradePacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknownInt()); VarInts.writeInt(buffer, packet.getTradeTier()); VarInts.writeLong(buffer, packet.getTraderUniqueEntityId()); VarInts.writeLong(buffer, packet.getPlayerUniqueEntityId()); BedrockUtils.writeString(buffer, packet.getDisplayName()); buffer.writeBoolean(packet.isScreen2()); buffer.writeBoolean(packet.isWilling()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getOffers()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #5
Source File: UpdateTradeSerializer_v332.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, UpdateTradePacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknownInt()); VarInts.writeInt(buffer, packet.isScreen2() ? 40 : 0); VarInts.writeInt(buffer, packet.getTradeTier()); buffer.writeBoolean(packet.isWilling()); VarInts.writeLong(buffer, packet.getTraderUniqueEntityId()); VarInts.writeLong(buffer, packet.getPlayerUniqueEntityId()); BedrockUtils.writeString(buffer, packet.getDisplayName()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getOffers()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #6
Source File: UpdateTradeSerializer_v332.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, UpdateTradePacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknownInt(VarInts.readInt(buffer)); packet.setScreen2(VarInts.readInt(buffer) >= 40); packet.setTradeTier(VarInts.readInt(buffer)); packet.setWilling(buffer.readBoolean()); packet.setTraderUniqueEntityId(VarInts.readLong(buffer)); packet.setPlayerUniqueEntityId(VarInts.readLong(buffer)); packet.setDisplayName(BedrockUtils.readString(buffer)); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setOffers(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #7
Source File: PaletteManager.java From BedrockConnect with GNU General Public License v3.0 | 6 votes |
public PaletteManager() { InputStream stream = BedrockConnect.class.getClassLoader().getResourceAsStream("tables/runtime_block_states.dat"); if (stream == null) { throw new AssertionError("Unable to locate block state nbt"); } Map<String, Integer> blockIdToIdentifier = new HashMap<>(); ListTag<CompoundTag> tag; NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream); ListTag<CompoundTag> blocksTag; try { tag = (ListTag<CompoundTag>) nbtInputStream.readTag(); nbtInputStream.close(); } catch (Exception ex) { System.out.println("Failed to receive blocks palette"); throw new AssertionError(ex); } CACHED_PALLETE = tag; }
Example #8
Source File: StructureTemplateDataExportResponseSerializer_v361.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, StructureTemplateDataExportResponsePacket packet) { packet.setName(BedrockUtils.readString(buffer)); boolean save = buffer.readBoolean(); packet.setSave(save); if (save) { try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { Tag<?> tag = reader.readTag(); if (tag instanceof CompoundTag) { packet.setTag((CompoundTag) tag); } else { throw new IllegalArgumentException("Tag received was not a CompoundTag"); } } catch (IOException e) { throw new RuntimeException(e); } } }
Example #9
Source File: UpdateTradeSerializer_v388.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, UpdateTradePacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknownInt()); VarInts.writeInt(buffer, packet.getTradeTier()); VarInts.writeLong(buffer, packet.getTraderUniqueEntityId()); VarInts.writeLong(buffer, packet.getPlayerUniqueEntityId()); BedrockUtils.writeString(buffer, packet.getDisplayName()); buffer.writeBoolean(packet.isScreen2()); buffer.writeBoolean(packet.isWilling()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getOffers()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #10
Source File: UpdateTradeSerializer_v388.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, UpdateTradePacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknownInt(VarInts.readInt(buffer)); packet.setTradeTier(VarInts.readInt(buffer)); packet.setWilling(buffer.readBoolean()); packet.setTraderUniqueEntityId(VarInts.readLong(buffer)); packet.setPlayerUniqueEntityId(VarInts.readLong(buffer)); packet.setDisplayName(BedrockUtils.readString(buffer)); packet.setScreen2(buffer.readBoolean()); packet.setWilling(buffer.readBoolean()); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setOffers(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #11
Source File: StructureTemplateDataExportResponseSerializer_v388.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, StructureTemplateDataExportResponsePacket packet) { packet.setName(BedrockUtils.readString(buffer)); boolean save = buffer.readBoolean(); packet.setSave(save); if (save) { try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { Tag<?> tag = reader.readTag(); if (tag instanceof CompoundTag) { packet.setTag((CompoundTag) tag); } else { throw new IllegalArgumentException("Tag received was not a CompoundTag"); } } catch (IOException e) { throw new RuntimeException(e); } } }
Example #12
Source File: UpdateTradeSerializer_v291.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, UpdateTradePacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknownInt(VarInts.readInt(buffer)); packet.setScreen2(VarInts.readInt(buffer) >= 40); packet.setWilling(buffer.readBoolean()); packet.setTraderUniqueEntityId(VarInts.readLong(buffer)); packet.setPlayerUniqueEntityId(VarInts.readLong(buffer)); packet.setDisplayName(BedrockUtils.readString(buffer)); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setOffers(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #13
Source File: UpdateTradeSerializer_v291.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, UpdateTradePacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknownInt()); VarInts.writeInt(buffer, packet.isScreen2() ? 40 : 0); buffer.writeBoolean(packet.isWilling()); VarInts.writeLong(buffer, packet.getTraderUniqueEntityId()); VarInts.writeLong(buffer, packet.getPlayerUniqueEntityId()); BedrockUtils.writeString(buffer, packet.getDisplayName()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getOffers()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #14
Source File: UpdateTradeSerializer_v313.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void deserialize(ByteBuf buffer, UpdateTradePacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknownInt(VarInts.readInt(buffer)); packet.setScreen2(VarInts.readInt(buffer) >= 40); packet.setTradeTier(VarInts.readInt(buffer)); packet.setWilling(buffer.readBoolean()); packet.setTraderUniqueEntityId(VarInts.readLong(buffer)); packet.setPlayerUniqueEntityId(VarInts.readLong(buffer)); packet.setDisplayName(BedrockUtils.readString(buffer)); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setOffers(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #15
Source File: UpdateTradeSerializer_v313.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, UpdateTradePacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknownInt()); VarInts.writeInt(buffer, packet.isScreen2() ? 40 : 0); VarInts.writeInt(buffer, packet.getTradeTier()); buffer.writeBoolean(packet.isWilling()); VarInts.writeLong(buffer, packet.getTraderUniqueEntityId()); VarInts.writeLong(buffer, packet.getPlayerUniqueEntityId()); BedrockUtils.writeString(buffer, packet.getDisplayName()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getOffers()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #16
Source File: UpdateTradeSerializer_v340.java From Protocol with Apache License 2.0 | 6 votes |
@Override public void serialize(ByteBuf buffer, UpdateTradePacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknownInt()); VarInts.writeInt(buffer, packet.isScreen2() ? 40 : 0); VarInts.writeInt(buffer, packet.getTradeTier()); buffer.writeBoolean(packet.isWilling()); VarInts.writeLong(buffer, packet.getTraderUniqueEntityId()); VarInts.writeLong(buffer, packet.getPlayerUniqueEntityId()); BedrockUtils.writeString(buffer, packet.getDisplayName()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getOffers()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #17
Source File: BiomeDefinitionListSerializer_v332.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, BiomeDefinitionListPacket packet) { try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setTag(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #18
Source File: AvailableEntityIdentifiersSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, AvailableEntityIdentifiersPacket packet) { try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #19
Source File: BiomeDefinitionListSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, BiomeDefinitionListPacket packet) { try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setTag(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #20
Source File: BlockEntityDataSerializer_v291.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, BlockEntityDataPacket packet) { BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getData()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #21
Source File: AvailableEntityIdentifiersSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, AvailableEntityIdentifiersPacket packet) { try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setTag(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #22
Source File: AvailableEntityIdentifiersSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, AvailableEntityIdentifiersPacket packet) { try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #23
Source File: UpdateEquipSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateEquipPacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknown0(VarInts.readInt(buffer)); packet.setUniqueEntityId(VarInts.readLong(buffer)); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setTag(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #24
Source File: UpdateEquipSerializer_v313.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, UpdateEquipPacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknown0()); VarInts.writeLong(buffer, packet.getUniqueEntityId()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #25
Source File: BlockEntityDataSerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, BlockEntityDataPacket packet) { packet.setBlockPosition(BedrockUtils.readBlockPosition(buffer)); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setData(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #26
Source File: BlockEntityDataSerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, BlockEntityDataPacket packet) { BedrockUtils.writeBlockPosition(buffer, packet.getBlockPosition()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getData()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #27
Source File: BiomeDefinitionListSerializer_v340.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, BiomeDefinitionListPacket packet) { try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setTag(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #28
Source File: UpdateEquipSerializer_v332.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, UpdateEquipPacket packet) { buffer.writeByte(packet.getWindowId()); buffer.writeByte(packet.getWindowType()); VarInts.writeInt(buffer, packet.getUnknown0()); VarInts.writeLong(buffer, packet.getUniqueEntityId()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #29
Source File: UpdateEquipSerializer_v332.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateEquipPacket packet) { packet.setWindowId(buffer.readUnsignedByte()); packet.setWindowType(buffer.readUnsignedByte()); packet.setUnknown0(VarInts.readInt(buffer)); packet.setUniqueEntityId(VarInts.readLong(buffer)); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setTag(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #30
Source File: BiomeDefinitionListSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, BiomeDefinitionListPacket packet) { try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }