Search in sources :

Example 6 with ListNBT

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;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 7 with ListNBT

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;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 8 with ListNBT

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);
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 9 with ListNBT

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));
    }
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 10 with ListNBT

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;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) TubeStack(com.bluepowermod.container.stack.TubeStack)

Aggregations

CompoundNBT (net.minecraft.nbt.CompoundNBT)13 ListNBT (net.minecraft.nbt.ListNBT)13 TubeStack (com.bluepowermod.container.stack.TubeStack)1 FireworkRocketEntity (net.minecraft.entity.projectile.FireworkRocketEntity)1 ItemStack (net.minecraft.item.ItemStack)1