use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_18_R1 method deserialize.
private static InventoryHolder deserialize(NBTTagCompound tagCompound) {
InventoryHolder inventory = new InventoryHolder(getInt(tagCompound, "Size"), "Chest");
NBTTagList itemsList = getList(tagCompound, "Items", 10);
for (int i = 0; i < itemsList.size(); i++) {
NBTTagCompound nbtTagCompound = getCompound(itemsList, i);
inventory.setItem(getByte(nbtTagCompound, "Slot"), CraftItemStack.asBukkitCopy(ItemStack.a(nbtTagCompound)));
}
return inventory;
}
use of com.bgsoftware.wildchests.objects.inventory.InventoryHolder in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_18_R2 method deserialze.
@Override
public InventoryHolder[] deserialze(String serialized) {
byte[] buff;
if (serialized.toCharArray()[0] == '*') {
buff = Base64.getDecoder().decode(serialized.substring(1));
} else {
buff = new BigInteger(serialized, 32).toByteArray();
}
ByteArrayInputStream inputStream = new ByteArrayInputStream(buff);
InventoryHolder[] inventories = new InventoryHolder[0];
try {
NBTTagCompound tagCompound = NBTCompressedStreamTools.a(new DataInputStream(inputStream), NBTReadLimiter.a);
int length = getInt(tagCompound, "Length");
inventories = new InventoryHolder[length];
for (int i = 0; i < length; i++) {
if (contains(tagCompound, i + "")) {
NBTTagCompound nbtTagCompound = getCompound(tagCompound, i + "");
inventories[i] = deserialize(nbtTagCompound);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return inventories;
}
Aggregations