com.nukkitx.nbt.stream.NBTOutputStream Java Examples
The following examples show how to use
com.nukkitx.nbt.stream.NBTOutputStream.
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_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 #2
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 #3
Source File: UpdateTradeSerializer_v354.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 #4
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 #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_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 #7
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 #8
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 #9
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 #10
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 #11
Source File: BiomeDefinitionListSerializer_v313.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); } }
Example #12
Source File: BlockEntityDataSerializer_v313.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 #13
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); } }
Example #14
Source File: UpdateBlockPropertiesSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, UpdateBlockPropertiesPacket packet) { try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getProperties()); } 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 serialize(ByteBuf buffer, LevelEventGenericPacket packet) { VarInts.writeInt(buffer, packet.getEventId()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #16
Source File: StructureTemplateDataExportResponseSerializer_v361.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, StructureTemplateDataExportResponsePacket packet) { BedrockUtils.writeString(buffer, packet.getName()); boolean save = packet.isSave(); buffer.writeBoolean(save); if (save) { try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } } }
Example #17
Source File: BlockEntityDataSerializer_v361.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 #18
Source File: UpdateEquipSerializer_v361.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 #19
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 #20
Source File: BiomeDefinitionListSerializer_v332.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); } }
Example #21
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 #22
Source File: AvailableEntityIdentifiersSerializer_v332.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: BlockEntityDataSerializer_v332.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 #24
Source File: UpdateEquipSerializer_v291.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_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 #26
Source File: LevelEventGenericSerializer_v388.java From Protocol with Apache License 2.0 | 5 votes |
@Override public void serialize(ByteBuf buffer, LevelEventGenericPacket packet) { VarInts.writeInt(buffer, packet.getEventId()); try (NBTOutputStream writer = NbtUtils.createNetworkWriter(new ByteBufOutputStream(buffer))) { writer.write(packet.getTag()); } catch (IOException e) { throw new RuntimeException(e); } }
Example #27
Source File: ProxyPass.java From ProxyPass with GNU Affero General Public License v3.0 | 5 votes |
public void saveNBT(String dataName, Tag<?> dataTag) { Path path = dataDir.resolve(dataName + ".dat"); try (OutputStream outputStream = Files.newOutputStream(path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); NBTOutputStream nbtOutputStream = NbtUtils.createNetworkWriter(outputStream)){ nbtOutputStream.write(dataTag); } catch (IOException e) { throw new RuntimeException(e); } }
Example #28
Source File: DownstreamPacketHandler.java From ProxyPass with GNU Affero General Public License v3.0 | 5 votes |
@Override public boolean handle(InventoryContentPacket packet) { if (packet.getContainerId() == ContainerId.CREATIVE) { List<CreativeItemEntry> entries = new ArrayList<>(); for (ItemData data : packet.getContents()) { int id = data.getId(); Integer damage = data.getDamage() == 0 ? null : (int) data.getDamage(); CompoundTag tag = data.getTag(); String tagData = null; if (tag != null) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try (NBTOutputStream stream = new NBTOutputStream(new LittleEndianDataOutputStream(byteArrayOutputStream))) { stream.write(tag); } catch (IOException e) { throw new RuntimeException(e); } tagData = Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray()); } entries.add(new CreativeItemEntry(id, damage, tagData)); } CreativeItems items = new CreativeItems(entries); proxy.saveJson("creative_items.json", items); } return false; }
Example #29
Source File: RecipeUtils.java From ProxyPass with GNU Affero General Public License v3.0 | 5 votes |
private static String nbtToBase64(CompoundTag tag) { if (tag != null) { ByteArrayOutputStream tagStream = new ByteArrayOutputStream(); try (NBTOutputStream writer = NbtUtils.createWriterLE(tagStream)) { writer.write(tag); } catch (IOException e) { throw new RuntimeException(e); } return Base64.getEncoder().encodeToString(tagStream.toByteArray()); } else { return null; } }
Example #30
Source File: AvailableEntityIdentifiersSerializer_v354.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); } }