private static void readSkipSlot(ByteBuf packet, int protocolVersion) { if ( (protocolVersion >= ProtocolConstants.MINECRAFT_1_13_2) ? packet.readBoolean() : packet.readShort() != -1 ) { if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13_2 ) { DefinedPacket.readVarInt( packet ); } packet.skipBytes( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? 1 : 3 ); // byte vs byte, short int position = packet.readerIndex(); if ( packet.readByte() != 0 ) { packet.readerIndex( position ); try { new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag(); } catch ( IOException ex ) { throw Throwables.propagate( ex ); } } } }
private List<Tag<?>> readRawNBT(File f, boolean compressed) { List<Tag<?>> tags = new ArrayList<Tag<?>>(); try { InputStream is = new FileInputStream(f); NBTInputStream ns = new NBTInputStream(is, compressed); try { boolean eof = false; while (!eof) { try { tags.add(ns.readTag()); } catch (EOFException e) { eof = true; } } } finally { try { ns.close(); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Unable to close file", "File Read Error", JOptionPane.ERROR_MESSAGE); } } } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(this, "Unable to open file", "File Read Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { return null; } return tags; }
List<Tag> tagList = new ArrayList<Tag>(length); for (int i = 0; i < length; i++) { Tag tag = readTagPayload(childType, "", depth + 1); if (tag instanceof EndTag) { throw new IOException("TAG_End not permitted in a list."); CompoundMap compoundTagList = new CompoundMap(); while (true) { Tag tag = readTag(depth + 1); if (tag instanceof EndTag) { break;
/** * Reads an NBT {@link Tag} from the stream. * * @return The tag that was read. * @throws java.io.IOException if an I/O error occurs. */ public Tag readTag() throws IOException { return readTag(0); }
/** * Reads an NBT {@link Tag} from the stream. * * @param depth The depth of this tag. * @return The tag that was read. * @throws java.io.IOException if an I/O error occurs. */ private Tag readTag(int depth) throws IOException { int typeId = is.readByte() & 0xFF; TagType type = TagType.getById(typeId); String name; if (type != TagType.TAG_END) { int nameLength = is.readShort() & 0xFFFF; byte[] nameBytes = new byte[nameLength]; is.readFully(nameBytes); name = new String(nameBytes, NBTConstants.CHARSET.name()); } else { name = ""; } return readTagPayload(type, name, depth); }
private List<Tag<?>> readRawNBT(File f, boolean compressed) { List<Tag<?>> tags = new ArrayList<Tag<?>>(); try { InputStream is = new FileInputStream(f); NBTInputStream ns = new NBTInputStream(is, compressed); try { boolean eof = false; while (!eof) { try { tags.add(ns.readTag()); } catch (EOFException e) { eof = true; } } } finally { try { ns.close(); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Unable to close file", "File Read Error", JOptionPane.ERROR_MESSAGE); } } } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(this, "Unable to open file", "File Read Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { return null; } return tags; }
List<Tag> tagList = new ArrayList<Tag>(length); for (int i = 0; i < length; i++) { Tag tag = readTagPayload(childType, "", depth + 1); if (tag instanceof EndTag) { throw new IOException("TAG_End not permitted in a list."); CompoundMap compoundTagList = new CompoundMap(); while (true) { Tag tag = readTag(depth + 1); if (tag instanceof EndTag) { break;
/** * Reads an NBT {@link Tag} from the stream. * * @return The tag that was read. * @throws java.io.IOException if an I/O error occurs. */ public Tag readTag() throws IOException { return readTag(0); }
/** * Reads an NBT {@link Tag} from the stream. * * @param depth The depth of this tag. * @return The tag that was read. * @throws java.io.IOException if an I/O error occurs. */ private Tag readTag(int depth) throws IOException { int typeId = is.readByte() & 0xFF; TagType type = TagType.getById(typeId); String name; if (type != TagType.TAG_END) { int nameLength = is.readShort() & 0xFFFF; byte[] nameBytes = new byte[nameLength]; is.readFully(nameBytes); name = new String(nameBytes, NBTConstants.CHARSET.name()); } else { name = ""; } return readTagPayload(type, name, depth); }
private List<Tag<?>> readRawNBT(File f, boolean compressed) { List<Tag<?>> tags = new ArrayList<Tag<?>>(); try { InputStream is = new FileInputStream(f); NBTInputStream ns = new NBTInputStream(is, compressed); try { boolean eof = false; while (!eof) { try { tags.add(ns.readTag()); } catch (EOFException e) { eof = true; } } } finally { try { ns.close(); } catch (IOException e) { JOptionPane.showMessageDialog(this, "Unable to close file", "File Read Error", JOptionPane.ERROR_MESSAGE); } } } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(this, "Unable to open file", "File Read Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { return null; } return tags; }
try new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag(); } catch ( IOException ex )
List<Tag> tagList = new ArrayList<Tag>(length); for (int i = 0; i < length; i++) { Tag tag = readTagPayload(childType, "", depth + 1); if (tag instanceof EndTag) { throw new IOException("TAG_End not permitted in a list."); CompoundMap compoundTagList = new CompoundMap(); while (true) { Tag tag = readTag(depth + 1); if (tag instanceof EndTag) { break;
/** * Reads an NBT {@link Tag} from the stream. * * @return The tag that was read. * @throws java.io.IOException if an I/O error occurs. */ public Tag readTag() throws IOException { return readTag(0); }
/** * Reads an NBT {@link Tag} from the stream. * * @param depth The depth of this tag. * @return The tag that was read. * @throws java.io.IOException if an I/O error occurs. */ private Tag readTag(int depth) throws IOException { int typeId = is.readByte() & 0xFF; TagType type = TagType.getById(typeId); String name; if (type != TagType.TAG_END) { int nameLength = is.readShort() & 0xFFFF; byte[] nameBytes = new byte[nameLength]; is.readFully(nameBytes); name = new String(nameBytes, NBTConstants.CHARSET.name()); } else { name = ""; } return readTagPayload(type, name, depth); }
ByteArrayInputStream in = new ByteArrayInputStream(data); InflaterInputStream iis = new InflaterInputStream(in); NBTInputStream ns = new NBTInputStream(iis, false); try { Tag<?> t = ns.readTag(); list.add(t); } catch (IOException ioe) { ns.close(); } catch (IOException ioe) {
public void load(InputStream stream, boolean compressed) throws IOException { NBTInputStream is = new NBTInputStream(stream, compressed); Tag<?> tag = is.readTag(); if (!(tag instanceof CompoundTag)) { throw new IllegalArgumentException("Expected CompoundTag, got " + tag.getClass()); } CompoundTag compound = (CompoundTag) tag; load(compound); } }
ByteArrayInputStream in = new ByteArrayInputStream(data); InflaterInputStream iis = new InflaterInputStream(in); NBTInputStream ns = new NBTInputStream(iis, false); try { Tag<?> t = ns.readTag(); list.add(t); } catch (IOException ioe) { ns.close(); } catch (IOException ioe) {
public void load(InputStream stream, boolean compressed) throws IOException { NBTInputStream is = new NBTInputStream(stream, compressed); Tag<?> tag = is.readTag(); if (!(tag instanceof CompoundTag)) { throw new IllegalArgumentException("Expected CompoundTag, got " + tag.getClass()); } CompoundTag compound = (CompoundTag) tag; load(compound); } }
ByteArrayInputStream in = new ByteArrayInputStream(data); InflaterInputStream iis = new InflaterInputStream(in); NBTInputStream ns = new NBTInputStream(iis, false); try { Tag<?> t = ns.readTag(); list.add(t); } catch (IOException ioe) { ns.close(); } catch (IOException ioe) {
public void load(InputStream stream, boolean compressed) throws IOException { NBTInputStream is = new NBTInputStream(stream, compressed); Tag<?> tag = is.readTag(); if (!(tag instanceof CompoundTag)) { throw new IllegalArgumentException("Expected CompoundTag, got " + tag.getClass()); } CompoundTag compound = (CompoundTag) tag; load(compound); } }