Search in sources :

Example 11 with ListNBT

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

the class TileRegulator method save.

@Override
public CompoundNBT save(CompoundNBT tag) {
    super.save(tag);
    tag.putByte("filterColor", (byte) color.ordinal());
    tag.putByte("mode", (byte) mode);
    tag.putByte("fuzzySetting", (byte) fuzzySetting);
    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);
    return tag;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 12 with ListNBT

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

the class TileSortingMachine method load.

@Override
public void load(BlockState state, CompoundNBT tag) {
    super.load(state, tag);
    pullMode = PullMode.values()[tag.getByte("pullMode")];
    sortMode = SortMode.values()[tag.getByte("sortMode")];
    savedPulses = tag.getInt("savedPulses");
    int[] colorArray = tag.getIntArray("colors");
    for (int i = 0; i < colorArray.length; i++) {
        colors[i] = TubeColor.values()[colorArray[i]];
    }
    if (tag.contains("fuzzySettings"))
        fuzzySettings = tag.getIntArray("fuzzySettings");
    ListNBT tagList = tag.getList("Items", 10);
    inventory = NonNullList.withSize(40, 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 13 with ListNBT

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

the class DateEventHandler method spawnFirework.

public static void spawnFirework(World world, double x, double y, double z) {
    ItemStack rocket = new ItemStack(Items.FIREWORK_ROCKET);
    ItemStack itemstack1 = getFireworkCharge();
    CompoundNBT nbttagcompound = new CompoundNBT();
    CompoundNBT nbttagcompound1 = new CompoundNBT();
    ListNBT nbttaglist = new ListNBT();
    if (!itemstack1.isEmpty() && itemstack1.getItem() == Items.FIREWORK_STAR && itemstack1.hasTag() && itemstack1.getTag().hasUUID("Explosion")) {
        nbttaglist.add(itemstack1.getTag().getCompound("Explosion"));
    }
    nbttagcompound1.put("Explosions", nbttaglist);
    nbttagcompound1.putByte("Flight", (byte) 2);
    nbttagcompound.put("Fireworks", nbttagcompound1);
    rocket.setTag(nbttagcompound);
    FireworkRocketEntity entity = new FireworkRocketEntity(world, x, y, z, rocket);
    world.addFreshEntity(entity);
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) FireworkRocketEntity(net.minecraft.entity.projectile.FireworkRocketEntity) ItemStack(net.minecraft.item.ItemStack)

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