java类net.minecraft.nbt.NBTSizeTracker的实例源码

PacketBuffer.java 文件源码 项目:DecompiledMinecraft 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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));
    }
}
PacketBuffer.java 文件源码 项目:DecompiledMinecraft 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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));
    }
}
PacketBuffer.java 文件源码 项目:BaseClient 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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));
    }
}
PacketBuffer.java 文件源码 项目:BaseClient 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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));
    }
}
PacketBuffer.java 文件源码 项目:CustomWorldGen 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
MCDataUtils.java 文件源码 项目:CodeChickenLib 阅读 19 收藏 0 点赞 0 评论 0
@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?");
    }
}
ItemArcanePackage.java 文件源码 项目:Gadomancy 阅读 17 收藏 0 点赞 0 评论 0
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;
}
PacketBuffer.java 文件源码 项目:ExpandedRailsMod 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
PacketBuffer.java 文件源码 项目:Backmemed 阅读 20 收藏 0 点赞 0 评论 0
@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);
            }
        }
    }
XUPacketBase.java 文件源码 项目:ExtraUtilities 阅读 20 收藏 0 点赞 0 评论 0
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;
    }
}
ByteBufUtils.java 文件源码 项目:CrystalMod 阅读 22 收藏 0 点赞 0 评论 0
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));
    }
}
ItemStorage.java 文件源码 项目:CrystalMod 阅读 18 收藏 0 点赞 0 评论 0
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;
}
FluidStorage.java 文件源码 项目:CrystalMod 阅读 20 收藏 0 点赞 0 评论 0
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;
}
WritableBuf.java 文件源码 项目:ThermosRebased 阅读 16 收藏 0 点赞 0 评论 0
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;
}
MessageNBT.java 文件源码 项目:Toms-Mod 阅读 19 收藏 0 点赞 0 评论 0
@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);
}
DataUtil.java 文件源码 项目:Factorization 阅读 19 收藏 0 点赞 0 评论 0
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;
}
NetworkUtil.java 文件源码 项目:EnderCore 阅读 31 收藏 0 点赞 0 评论 0
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;
  }
}
BarrelPacketHandler.java 文件源码 项目:JABBA 阅读 20 收藏 0 点赞 0 评论 0
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);
}
DataUtil.java 文件源码 项目:MHuanterMod 阅读 20 收藏 0 点赞 0 评论 0
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;
}
PacketHandler.java 文件源码 项目:vsminecraft 阅读 17 收藏 0 点赞 0 评论 0
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;
    }
}
SasaPacket.java 文件源码 项目:SasaLib 阅读 15 收藏 0 点赞 0 评论 0
public NBTTagCompound getNBTTag()
{
    try
    {
        return CompressedStreamTools.func_152456_a(input, new NBTSizeTracker(Long.MAX_VALUE));
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
PacketSyncData.java 文件源码 项目:Gadomancy 阅读 17 收藏 0 点赞 0 评论 0
@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);
    }
}
ByteBufUtilsEU.java 文件源码 项目:enderutilities 阅读 20 收藏 0 点赞 0 评论 0
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));
    }
}
NetworkHandler.java 文件源码 项目:Quantum-Anomalies 阅读 29 收藏 0 点赞 0 评论 0
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);
    }
}
PacketBuffer.java 文件源码 项目:Cauldron 阅读 20 收藏 0 点赞 0 评论 0
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));
    }
}
PacketBuffer.java 文件源码 项目:Cauldron 阅读 22 收藏 0 点赞 0 评论 0
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));
    }
}
PartialTileNBTUpdateMessage.java 文件源码 项目:ProgressiveAutomation 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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));
    }
}
PartialTileNBTUpdateMessage.java 文件源码 项目:ProgressiveAutomation 阅读 19 收藏 0 点赞 0 评论 0
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;
}
DataUtil.java 文件源码 项目:Factorization 阅读 21 收藏 0 点赞 0 评论 0
static public NBTTagCompound readTag(DataInput input, NBTSizeTracker tracker) throws IOException {
    return CompressedStreamTools.read(input, tracker);
}
DataUtil.java 文件源码 项目:Factorization 阅读 19 收藏 0 点赞 0 评论 0
public static NBTSizeTracker newTracker() {
    return new NBTSizeTracker(MAX_TAG_SIZE);
}


问题


面经


文章

微信
公众号

扫码关注公众号