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;
}
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));
}
}
}
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"));
}
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);
}
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;
}
Aggregations