/** * Writes a {@code TAG_String} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeStringTagPayload(StringTag tag) throws IOException { byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET.name()); os.writeShort(bytes.length); os.write(bytes); }
/** * Writes a {@code TAG_Byte_Array} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException { byte[] bytes = tag.getValue(); os.writeInt(bytes.length); os.write(bytes); }
/** * Writes a tag. * * @param tag The tag to write. * @throws java.io.IOException if an I/O error occurs. */ public void writeTag(Tag<?> tag) throws IOException { String name = tag.getName(); byte[] nameBytes = name.getBytes(NBTConstants.CHARSET.name()); os.writeByte(tag.getType().getId()); os.writeShort(nameBytes.length); os.write(nameBytes); if (tag.getType() == TagType.TAG_END) { throw new IOException("Named TAG_End not permitted."); } writeTagPayload(tag); }
/** * Writes a tag. * * @param tag The tag to write. * @throws java.io.IOException if an I/O error occurs. */ public void writeTag(Tag<?> tag) throws IOException { String name = tag.getName(); byte[] nameBytes = name.getBytes(NBTConstants.CHARSET.name()); os.writeByte(tag.getType().getId()); os.writeShort(nameBytes.length); os.write(nameBytes); if (tag.getType() == TagType.TAG_END) { throw new IOException("Named TAG_End not permitted."); } writeTagPayload(tag); }
/** * Writes a {@code TAG_String} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeStringTagPayload(StringTag tag) throws IOException { byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET.name()); os.writeShort(bytes.length); os.write(bytes); }
/** * Writes a {@code TAG_Byte_Array} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException { byte[] bytes = tag.getValue(); os.writeInt(bytes.length); os.write(bytes); }
/** * Writes a tag. * * @param tag The tag to write. * @throws java.io.IOException if an I/O error occurs. */ public void writeTag(Tag<?> tag) throws IOException { String name = tag.getName(); byte[] nameBytes = name.getBytes(NBTConstants.CHARSET.name()); os.writeByte(tag.getType().getId()); os.writeShort(nameBytes.length); os.write(nameBytes); if (tag.getType() == TagType.TAG_END) { throw new IOException("Named TAG_End not permitted."); } writeTagPayload(tag); }
/** * Writes a {@code TAG_String} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeStringTagPayload(StringTag tag) throws IOException { byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET.name()); os.writeShort(bytes.length); os.write(bytes); }
/** * Writes a {@code TAG_Byte_Array} tag. * * @param tag The tag. * @throws java.io.IOException if an I/O error occurs. */ private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException { byte[] bytes = tag.getValue(); os.writeInt(bytes.length); os.write(bytes); }