use of net.minecraft.nbt.NBTSizeTracker in project RecurrentComplex by Ivorforce.
the class RCPacketBuffer method readBigTag.
@Nullable
public NBTTagCompound readBigTag() 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 * 4));
} catch (IOException ioexception) {
throw new EncoderException(ioexception);
}
}
}
use of net.minecraft.nbt.NBTSizeTracker in project Railcraft by Railcraft.
the class RailcraftInputStream method readNBT.
@Nullable
public NBTTagCompound readNBT() throws IOException {
mark(1);
byte b = readByte();
NBTTagCompound nbt = null;
if (b != 0) {
reset();
try (DataInputStream nbtStream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(this)))) {
nbt = CompressedStreamTools.read(nbtStream, new NBTSizeTracker(2097152L));
}
}
return nbt;
}
use of net.minecraft.nbt.NBTSizeTracker in project BluePower by Qmunity.
the class ItemStackDatabase method loadItemStacks.
public List<ItemStack> loadItemStacks() {
if (cache == null) {
File targetLocation = new File(saveLocation);
List<ItemStack> stacks = new ArrayList<ItemStack>();
if (targetLocation.exists()) {
File[] files = targetLocation.listFiles();
for (File file : files) {
try {
FileInputStream fos = new FileInputStream(file);
DataInputStream dos = new DataInputStream(fos);
short short1 = dos.readShort();
byte[] abyte = new byte[short1];
dos.read(abyte);
NBTTagCompound tag = CompressedStreamTools.func_152457_a(abyte, new NBTSizeTracker(2097152L));
ItemStack stack = new ItemStack(Items.stick);
stack.readFromNBT(tag);
if (stack.getItem() != null) {
stacks.add(stack);
} else {
BluePower.log.error("Couldn't retrieve an itemstack with item id: " + tag.getShort("id"));
Item item = GameRegistry.findItem(tag.getString("owner"), tag.getString("name"));
if (item != null) {
ItemStack backupStack = new ItemStack(item, stack.stackSize, tag.getShort("Damage"));
if (stack.hasTagCompound()) {
backupStack.setTagCompound(stack.getTagCompound());
}
stacks.add(backupStack);
BluePower.log.info("Successfully retrieved stack via its name: " + tag.getString("owner") + ":" + tag.getString("name"));
} else {
BluePower.log.error("Couldn't retrieve the item via its name: " + tag.getString("owner") + ":" + tag.getString("name"));
}
}
dos.close();
} catch (IOException e) {
BluePower.log.error("Exception : " + e);
}
}
}
cache = stacks;
}
return cache;
}
Aggregations