Search in sources :

Example 96 with CompoundNBT

use of net.minecraft.nbt.CompoundNBT 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 97 with CompoundNBT

use of net.minecraft.nbt.CompoundNBT 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 98 with CompoundNBT

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

the class TileBlulectricFurnace method load.

/**
 * This function gets called whenever the world/chunk loads
 */
@Override
public void load(BlockState blockState, CompoundNBT tCompound) {
    super.load(blockState, tCompound);
    CompoundNBT tc = tCompound.getCompound("inventory");
    inventory = ItemStack.of(tc);
    outputInventory = ItemStack.of(tCompound.getCompound("outputInventory"));
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT)

Example 99 with CompoundNBT

use of net.minecraft.nbt.CompoundNBT 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)

Example 100 with CompoundNBT

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

the class DateEventHandler method getFireworkCharge.

private static ItemStack getFireworkCharge() {
    ItemStack charge = new ItemStack(Items.FIREWORK_STAR);
    CompoundNBT nbttagcompound = new CompoundNBT();
    CompoundNBT nbttagcompound1 = new CompoundNBT();
    byte b0 = 0;
    ArrayList<Integer> arraylist = new ArrayList<Integer>();
    arraylist.add(MinecraftColor.values()[rand.nextInt(16)].getHex());
    if (rand.nextBoolean())
        nbttagcompound1.putBoolean("Flicker", true);
    if (rand.nextBoolean())
        nbttagcompound1.putBoolean("Trail", true);
    b0 = (byte) rand.nextInt(5);
    int[] aint = new int[arraylist.size()];
    for (int j2 = 0; j2 < aint.length; ++j2) {
        aint[j2] = arraylist.get(j2);
    }
    nbttagcompound1.putIntArray("Colors", aint);
    nbttagcompound1.putByte("Type", b0);
    nbttagcompound.put("Explosion", nbttagcompound1);
    charge.setTag(nbttagcompound);
    return charge;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

CompoundNBT (net.minecraft.nbt.CompoundNBT)119 ItemStack (net.minecraft.item.ItemStack)33 ListNBT (net.minecraft.nbt.ListNBT)15 Nonnull (javax.annotation.Nonnull)12 PlayerEntity (net.minecraft.entity.player.PlayerEntity)10 ResourceLocation (net.minecraft.util.ResourceLocation)8 BlockPos (net.minecraft.util.math.BlockPos)8 TileEntity (net.minecraft.tileentity.TileEntity)7 StringTextComponent (net.minecraft.util.text.StringTextComponent)7 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)6 DimensionType (net.minecraft.world.dimension.DimensionType)6 TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)5 Block (net.minecraft.block.Block)5 BlockState (net.minecraft.block.BlockState)5 ArrayList (java.util.ArrayList)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 SUpdateTileEntityPacket (net.minecraft.network.play.server.SUpdateTileEntityPacket)4 LongItemStack (com.cjm721.overloaded.storage.stacks.intint.LongItemStack)3 Nullable (javax.annotation.Nullable)3 IItemProvider (net.minecraft.util.IItemProvider)3