/** * Reads a compressed NBTTagCompound from this buffer */ public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException { int i = this.readerIndex(); byte b0 = this.readByte(); if (b0 == 0) { return null; } else { this.readerIndex(i); return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L)); } }
/** * Reads a compressed NBTTagCompound from this buffer */ @Nullable public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException { int i = this.readerIndex(); byte b0 = this.readByte(); if (b0 == 0) { return null; } else { this.readerIndex(i); try { return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L)); } catch (IOException ioexception) { throw new EncoderException(ioexception); } } }
@Nullable public static NBTTagCompound readNBTTagCompound(MCDataInput input) { byte flag = input.readByte(); if (flag == 0) { return null; } else if (flag == 1) { try { return CompressedStreamTools.read(new DataInputStream(new MCDataInputStream(input)), new NBTSizeTracker(2097152L)); } catch (IOException e) { throw new EncoderException(e); } } else { throw new EncoderException("Invalid flag for readNBTTagCompound. Expected 0 || 1 Got: " + flag + " Possible incorrect read order?"); } }
public List<ItemStack> getContents(ItemStack stack) { List<ItemStack> contents = new ArrayList<ItemStack>(); if (stack.hasTagCompound()) { byte[] data = stack.getTagCompound().getByteArray("items"); if(data.length > 0) { NBTTagList stackList; try { stackList = (NBTTagList) CompressedStreamTools.func_152457_a(data, new NBTSizeTracker(Long.MAX_VALUE)).getTag("data"); } catch (Exception e) { return contents; } for (int i = 0; i < stackList.tagCount(); ++i) { NBTTagCompound nbtStack = stackList.getCompoundTagAt(i); contents.add(ItemStack.loadItemStackFromNBT(nbtStack)); } } } return contents; }
@Nullable /** * Reads a compressed NBTTagCompound from this buffer */ public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException { int i = this.readerIndex(); byte b0 = this.readByte(); if (b0 == 0) { return null; } else { this.readerIndex(i); try { return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L)); } catch (IOException ioexception) { throw new EncoderException(ioexception); } } }
public NBTTagCompound readNBT(final ByteBuf data) { final short length = data.readShort(); if (length <= 0) { return null; } final byte[] bytes = new byte[length]; data.readBytes(bytes); try { return CompressedStreamTools.func_152457_a(bytes, NBTSizeTracker.field_152451_a); } catch (IOException e) { e.printStackTrace(); return null; } }
public static NBTTagCompound readNBTTagCompoundFromBuffer(ByteBuf buf) throws IOException { int i = buf.readerIndex(); byte b0 = buf.readByte(); if (b0 == 0) { return null; } else { buf.readerIndex(i); return CompressedStreamTools.read(new ByteBufInputStream(buf), new NBTSizeTracker(2097152L)); } }
public static ItemStackData fromBytes(CompressedDataInput cdi) throws IOException { ItemStackData newData = new ItemStackData(); ItemStack itemstack = ItemStackTools.getEmptyStack(); int i = cdi.readShort(); if (i >= 0) { int j = cdi.readVariable(); int k = cdi.readShort(); itemstack = new ItemStack(Item.getItemById(i), j, k); NBTTagCompound nbt = null; byte b0 = cdi.readByte(); if (b0 == 0) { nbt = null; } else { try { nbt = CompressedStreamTools.read(cdi, new NBTSizeTracker(2097152L)); } catch (Exception e) { System.out.println("Error Loading NBT to " + itemstack.getDisplayName()); } } itemstack.setTagCompound(nbt); } newData.stack = itemstack; newData.isCrafting = cdi.readBoolean(); return newData; }
public static FluidStackData fromBytes(CompressedDataInput cdi) throws IOException { FluidStackData newData = new FluidStackData(); FluidStack fluidstack = null; int i = cdi.readShort(); if (i >= 0) { NBTTagCompound nbt = null; byte b0 = cdi.readByte(); if (b0 == 0) { nbt = null; } else { try { nbt = CompressedStreamTools.read(cdi, new NBTSizeTracker(2097152L)); } catch (Exception e) { System.out.println("Error Loading Fluid NBT"); } } if(nbt !=null)fluidstack = FluidStack.loadFluidStackFromNBT(nbt); } newData.stack = fluidstack; if(newData.stack == null)return null; return newData; }
public <T extends NBTBase> T readNBT() { final byte type = this.readByte(); if (type == -1) { return null; } final T nbt = (T)NBTBase.func_150284_a(type); try { nbt.func_152446_a((DataInput)this.getDataInputStream(), 0, NBTSizeTracker.field_152451_a); } catch (IOException e) { throw new RuntimeException(e); } return nbt; }
@Override public void fromBytes(ByteBuf buf) { isMultipart = buf.readBoolean(); isConfiguration = buf.readBoolean(); if (isMultipart || isConfiguration) partPos = buf.readInt(); try { tag = CompressedStreamTools.read(new ByteBufInputStream(buf), NBTSizeTracker.INFINITE); } catch (Exception e) { TMLogger.bigCatching(e, "Exception caught during the reading of an NBTTagCompound from ByteBuf in."); tag = new NBTTagCompound(); tag.setBoolean("ERROR", true); } pos = TomsModUtils.readBlockPosFromPacket(buf); }
static public ItemStack readStack(DataInput input, NBTSizeTracker tracker) throws IOException { ItemStack is = ItemStack.loadItemStackFromNBT(readTag(input, tracker)); if (is == null || is.getItem() == null) { return null; } return is; }
public static NBTTagCompound readNBTTagCompound(ByteBuf dataIn) { try { short size = dataIn.readShort(); if (size < 0) { return null; } else { byte[] buffer = new byte[size]; dataIn.readBytes(buffer); return CompressedStreamTools.func_152457_a(buffer, NBTSizeTracker.field_152451_a); } } catch (IOException e) { FMLCommonHandler.instance().raiseException(e, "Custom Packet", true); return null; } }
public NBTTagCompound readNBTTagCompoundFromBuffer(ByteBuf dat) throws IOException { short short1 = dat.readShort(); if (short1 < 0) { return null; } byte[] abyte = new byte[short1]; dat.readBytes(abyte); return CompressedStreamTools.func_152457_a(abyte, NBTSizeTracker.field_152451_a); }
public static ItemStack readStack(DataInput input, NBTSizeTracker tracker) throws IOException{ ItemStack is = ItemStack.loadItemStackFromNBT(readTag(input, tracker)); if ((is == null) || (is.getItem() == null)) { return null; } return is; }
public static NBTTagCompound readNBT(ByteBuf input) { try { byte[] buffer = new byte[input.readInt()]; input.readBytes(buffer); return CompressedStreamTools.func_152457_a(buffer, new NBTSizeTracker(2097152L)); } catch(Exception e) { return null; } }
public NBTTagCompound getNBTTag() { try { return CompressedStreamTools.func_152456_a(input, new NBTSizeTracker(Long.MAX_VALUE)); } catch (Exception e) { e.printStackTrace(); } return null; }
@Override public void fromBytes(ByteBuf buf) { int size = buf.readInt(); for (int i = 0; i < size; i++) { String key = StringHelper.readFromBuffer(buf); byte providerId = buf.readByte(); AbstractData.AbstractDataProvider<? extends AbstractData> provider = AbstractData.Registry.getProvider(providerId); if(provider == null) { Gadomancy.log.warn("Provider for ID " + providerId + " doesn't exist! Skipping..."); continue; } NBTTagCompound cmp; short compoundLength = buf.readShort(); byte[] abyte = new byte[compoundLength]; buf.readBytes(abyte); try { cmp = CompressedStreamTools.func_152457_a(abyte, new NBTSizeTracker(2097152L)); } catch (IOException e) { Gadomancy.log.warn("Provider Compound of " + providerId + " threw an IOException! Skipping..."); Gadomancy.log.warn("Exception message: " + e.getMessage()); continue; } AbstractData dat = provider.provideNewInstance(); dat.readRawFromPacket(cmp); data.put(key, dat); } }
public static NBTTagCompound readNBT(ByteBuf dat) throws IOException { short short1 = dat.readShort(); if (short1 < 0) return null; else { byte[] abyte = new byte[short1]; dat.readBytes(abyte); //return CompressedStreamTools.decompress(abyte); return CompressedStreamTools.func_152457_a(abyte, NBTSizeTracker.field_152451_a); } }
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException { short short1 = this.readShort(); if (short1 < 0) { return null; } else { byte[] abyte = new byte[short1]; this.readBytes(abyte); return CompressedStreamTools.func_152457_a(abyte, new NBTSizeTracker(2097152L)); } }
/** * Reads a compressed NBTTagCompound from this buffer * @see PacketBuffer.readNBTTagCompoundFromBuffer() */ private static NBTTagCompound readNBTTagCompoundFromBuffer(ByteBuf buf) throws IOException { short short1 = buf.readShort(); if (short1 < 0) { return null; } else { byte[] abyte = new byte[short1]; buf.readBytes(abyte); return decompress(abyte, new NBTSizeTracker(2097152L)); } }
public static NBTTagCompound decompress(byte[] p_152457_0_, NBTSizeTracker p_152457_1_) throws IOException { DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(p_152457_0_)))); NBTTagCompound nbttagcompound; try { nbttagcompound = CompressedStreamTools.read(datainputstream, p_152457_1_); } finally { datainputstream.close(); } return nbttagcompound; }
static public NBTTagCompound readTag(DataInput input, NBTSizeTracker tracker) throws IOException { return CompressedStreamTools.read(input, tracker); }
public static NBTSizeTracker newTracker() { return new NBTSizeTracker(MAX_TAG_SIZE); }
public static NBTTagCompound readTag(DataInput input, NBTSizeTracker tracker) throws IOException{ return CompressedStreamTools.func_152456_a(input, tracker); }
public static NBTTagCompound readTag(DataInput input) throws IOException{ return readTag(input, NBTSizeTracker.field_152451_a); }
public static ItemStack readStack(DataInput input) throws IOException{ return readStack(input, NBTSizeTracker.field_152451_a); }
public NBTTagCompound getTagCompound() { try { return CompressedStreamTools.func_152457_a(compound, NBTSizeTracker.field_152451_a); } catch(Exception e) { return null; } }