com.nukkitx.nbt.stream.NBTInputStream Java Examples
The following examples show how to use
com.nukkitx.nbt.stream.NBTInputStream.
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_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 #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_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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: AvailableEntityIdentifiersSerializer_v361.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 #12
Source File: BlockEntityDataSerializer_v313.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 #13
Source File: BiomeDefinitionListSerializer_v361.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 #14
Source File: UpdateBlockPropertiesSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, UpdateBlockPropertiesPacket packet) { try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setProperties(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #15
Source File: LevelEventGenericSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void deserialize(ByteBuf buffer, LevelEventGenericPacket packet) { packet.setEventId(VarInts.readInt(buffer)); try (NBTInputStream reader = NbtUtils.createNetworkReader(new ByteBufInputStream(buffer))) { packet.setTag(reader.readTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #16
Source File: BlockEntityDataSerializer_v361.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 #17
Source File: UpdateEquipSerializer_v361.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 #18
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 #19
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 #20
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 #21
Source File: AvailableEntityIdentifiersSerializer_v332.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: BlockEntityDataSerializer_v332.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 #23
Source File: UpdateEquipSerializer_v291.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: BlockEntityDataSerializer_v291.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 #25
Source File: AvailableEntityIdentifiersSerializer_v388.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 #26
Source File: ProxyPass.java From ProxyPass with GNU Affero General Public License v3.0 | 5 votes |
public Tag<?> loadNBT(String dataName) { Path path = dataDir.resolve(dataName + ".dat"); try (InputStream inputStream = Files.newInputStream(path); NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(inputStream)){ return nbtInputStream.readTag(); } catch (IOException e) { throw new RuntimeException(e); } }
Example #27
Source File: AvailableEntityIdentifiersSerializer_v354.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 #28
Source File: UpdateEquipSerializer_v354.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 #29
Source File: BiomeDefinitionListSerializer_v354.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 #30
Source File: BlockEntityDataSerializer_v354.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); } }