Java 类net.minecraft.nbt.NBTSizeTracker 实例源码

项目:DecompiledMinecraft    文件:PacketBuffer.java   
/**
 * 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));
    }
}
项目:DecompiledMinecraft    文件:PacketBuffer.java   
/**
 * 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));
    }
}
项目:BaseClient    文件:PacketBuffer.java   
/**
 * 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));
    }
}
项目:BaseClient    文件:PacketBuffer.java   
/**
 * 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));
    }
}
项目:CustomWorldGen    文件:PacketBuffer.java   
/**
 * 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);
        }
    }
}
项目:CodeChickenLib    文件:MCDataUtils.java   
@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?");
    }
}
项目:Gadomancy    文件:ItemArcanePackage.java   
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;
}
项目:ExpandedRailsMod    文件:PacketBuffer.java   
/**
 * 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);
        }
    }
}
项目:Backmemed    文件:PacketBuffer.java   
@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);
            }
        }
    }
项目:ExtraUtilities    文件:XUPacketBase.java   
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;
    }
}
项目:CrystalMod    文件:ByteBufUtils.java   
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));
    }
}
项目:CrystalMod    文件:ItemStorage.java   
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;
}
项目:CrystalMod    文件:FluidStorage.java   
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;
}
项目:ThermosRebased    文件:WritableBuf.java   
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;
}
项目:Toms-Mod    文件:MessageNBT.java   
@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);
}
项目:Factorization    文件:DataUtil.java   
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;
}
项目:EnderCore    文件:NetworkUtil.java   
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;
  }
}
项目:JABBA    文件:BarrelPacketHandler.java   
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);
}
项目:MHuanterMod    文件:DataUtil.java   
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;
}
项目:vsminecraft    文件:PacketHandler.java   
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;
    }
}
项目:SasaLib    文件:SasaPacket.java   
public NBTTagCompound getNBTTag()
{
    try
    {
        return CompressedStreamTools.func_152456_a(input, new NBTSizeTracker(Long.MAX_VALUE));
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
项目:Gadomancy    文件:PacketSyncData.java   
@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);
    }
}
项目:enderutilities    文件:ByteBufUtilsEU.java   
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));
    }
}
项目:Quantum-Anomalies    文件:NetworkHandler.java   
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);
    }
}
项目:Cauldron    文件:PacketBuffer.java   
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));
    }
}
项目:Cauldron    文件:PacketBuffer.java   
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));
    }
}
项目:ProgressiveAutomation    文件:PartialTileNBTUpdateMessage.java   
/**
 * 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));
    }
}
项目:ProgressiveAutomation    文件:PartialTileNBTUpdateMessage.java   
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;
}
项目:Factorization    文件:DataUtil.java   
static public NBTTagCompound readTag(DataInput input, NBTSizeTracker tracker) throws IOException {
    return CompressedStreamTools.read(input, tracker);
}
项目:Factorization    文件:DataUtil.java   
public static NBTSizeTracker newTracker() {
    return new NBTSizeTracker(MAX_TAG_SIZE);
}
项目:MHuanterMod    文件:DataUtil.java   
public static NBTTagCompound readTag(DataInput input, NBTSizeTracker tracker)
        throws IOException{
    return CompressedStreamTools.func_152456_a(input, tracker);
}
项目:MHuanterMod    文件:DataUtil.java   
public static NBTTagCompound readTag(DataInput input)
        throws IOException{
    return readTag(input, NBTSizeTracker.field_152451_a);
}
项目:MHuanterMod    文件:DataUtil.java   
public static ItemStack readStack(DataInput input)
        throws IOException{
    return readStack(input, NBTSizeTracker.field_152451_a);
}
项目:endernet    文件:EnderID.java   
public NBTTagCompound getTagCompound() {
    try {
        return CompressedStreamTools.func_152457_a(compound, NBTSizeTracker.field_152451_a);
    } catch(Exception e) { return null; }
}