use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.
the class TileCircuitTable method save.
@Override
public CompoundNBT save(CompoundNBT tag) {
super.save(tag);
ListNBT tagList = new ListNBT();
for (int currentIndex = 0; currentIndex < inventory.size(); ++currentIndex) {
CompoundNBT tagCompound = new CompoundNBT();
tagCompound.putByte("Slot", (byte) currentIndex);
inventory.get(currentIndex).save(tagCompound);
tagList.add(tagCompound);
}
tag.put("Items", tagList);
tag.putString("textboxString", textboxString);
return tag;
}
use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.
the class InventoryItem method readFromNBT.
protected void readFromNBT() {
reading = true;
ListNBT itemList = (ListNBT) ((CompoundNBT) item.getTag().get("Inventory")).get("Items");
for (int i = 0; i < itemList.size(); i++) {
CompoundNBT slotEntry = itemList.getCompound(i);
int j = slotEntry.getByte("Slot") & 0xff;
if (j >= 0 && j < getContainerSize()) {
setItem(j, ItemStack.of(slotEntry));
}
}
reading = false;
}
use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.
the class InventoryItem method writeToNBT.
protected void writeToNBT() {
if (item.getTag() == null) {
item.setTag(new CompoundNBT());
}
ListNBT itemList = new ListNBT();
for (int i = 0; i < getContainerSize(); i++) {
if (!getItem(i).isEmpty()) {
CompoundNBT slotEntry = new CompoundNBT();
slotEntry.putByte("Slot", (byte) i);
getItem(i).save(slotEntry);
itemList.add(slotEntry);
}
}
CompoundNBT inventory = new CompoundNBT();
inventory.put("Items", itemList);
item.getTag().put("Inventory", inventory);
}
use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.
the class TileMachineBase method load.
@Override
public void load(BlockState state, CompoundNBT compound) {
super.load(state, compound);
ListNBT nbttaglist = compound.getList("ItemBuffer", 10);
for (int i = 0; i < nbttaglist.size(); ++i) {
CompoundNBT nbttagcompound1 = nbttaglist.getCompound(i);
internalItemStackBuffer.add(TubeStack.loadFromNBT(nbttagcompound1));
}
}
use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.
the class TileMachineBase method save.
@Override
public CompoundNBT save(CompoundNBT compound) {
super.save(compound);
ListNBT nbttaglist = new ListNBT();
for (TubeStack tubeStack : internalItemStackBuffer) {
if (tubeStack != null) {
CompoundNBT nbttagcompound1 = new CompoundNBT();
tubeStack.writeToNBT(nbttagcompound1);
nbttaglist.add(nbttagcompound1);
}
}
compound.put("ItemBuffer", nbttaglist);
return compound;
}
Aggregations