Search in sources :

Example 1 with ListNBT

use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.

the class TileRegulator method load.

@Override
public void load(BlockState state, CompoundNBT tag) {
    super.load(state, tag);
    color = TubeColor.values()[tag.getByte("filterColor")];
    mode = tag.getByte("mode");
    fuzzySetting = tag.getByte("fuzzySetting");
    ListNBT tagList = tag.getList("Items", 10);
    inventory = NonNullList.withSize(27, ItemStack.EMPTY);
    for (int i = 0; i < tagList.size(); ++i) {
        CompoundNBT tagCompound = tagList.getCompound(i);
        byte slot = tagCompound.getByte("Slot");
        if (slot >= 0 && slot < inventory.size()) {
            inventory.set(slot, ItemStack.of(tagCompound));
        }
    }
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 2 with ListNBT

use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.

the class TileSortingMachine method save.

@Override
public CompoundNBT save(CompoundNBT tag) {
    super.save(tag);
    tag.putByte("pullMode", (byte) pullMode.ordinal());
    tag.putByte("sortMode", (byte) sortMode.ordinal());
    tag.putInt("savedPulses", savedPulses);
    int[] colorArray = new int[colors.length];
    for (int i = 0; i < colorArray.length; i++) {
        colorArray[i] = colors[i].ordinal();
    }
    tag.putIntArray("colors", colorArray);
    tag.putIntArray("fuzzySettings", fuzzySettings);
    ListNBT tagList = new ListNBT();
    for (int currentIndex = 0; currentIndex < inventory.size(); ++currentIndex) {
        if (!inventory.get(currentIndex).isEmpty()) {
            CompoundNBT tagCompound = new CompoundNBT();
            tagCompound.putByte("Slot", (byte) currentIndex);
            inventory.get(currentIndex).save(tagCompound);
            tagList.add(tagCompound);
        }
    }
    tag.put("Items", tagList);
    return tag;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 3 with ListNBT

use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.

the class TileProjectTable 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);
    tagList = new ListNBT();
    for (int currentIndex = 0; currentIndex < craftingGrid.size(); ++currentIndex) {
        CompoundNBT tagCompound = new CompoundNBT();
        tagCompound.putByte("Slot", (byte) currentIndex);
        craftingGrid.get(currentIndex).save(tagCompound);
        tagList.add(tagCompound);
    }
    tag.put("CraftingGrid", tagList);
    return tag;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 4 with ListNBT

use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.

the class TileProjectTable method load.

@Override
public void load(BlockState blockState, CompoundNBT tag) {
    super.load(blockState, tag);
    ListNBT tagList = tag.getList("Items", 10);
    inventory = NonNullList.withSize(19, ItemStack.EMPTY);
    for (int i = 0; i < tagList.size(); ++i) {
        CompoundNBT tagCompound = tagList.getCompound(i);
        byte slot = tagCompound.getByte("Slot");
        if (slot >= 0 && slot < inventory.size()) {
            inventory.set(slot, ItemStack.of(tagCompound));
        }
    }
    tagList = tag.getList("CraftingGrid", 10);
    craftingGrid = NonNullList.withSize(9, ItemStack.EMPTY);
    for (int i = 0; i < tagList.size(); ++i) {
        CompoundNBT tagCompound = tagList.getCompound(i);
        byte slot = tagCompound.getByte("Slot");
        if (slot >= 0 && slot < craftingGrid.size()) {
            craftingGrid.set(slot, ItemStack.of(tagCompound));
        }
    }
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 5 with ListNBT

use of net.minecraft.nbt.ListNBT in project BluePower by Qmunity.

the class TileCircuitTable method load.

@Override
public void load(BlockState state, CompoundNBT tag) {
    super.load(state, tag);
    ListNBT tagList = tag.getList("Items", 10);
    inventory = NonNullList.withSize(24, ItemStack.EMPTY);
    for (int i = 0; i < tagList.size(); ++i) {
        CompoundNBT tagCompound = tagList.getCompound(i);
        byte slot = tagCompound.getByte("Slot");
        if (slot >= 0 && slot < inventory.size()) {
            inventory.set(slot, ItemStack.of(tagCompound));
        }
    }
    textboxString = tag.getString("textboxString");
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

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