use of net.minecraft.nbt.NbtCompound in project bewitchment by MoriyaShiine.
the class CursesComponent method toNbtCurse.
@SuppressWarnings("ConstantConditions")
public NbtList toNbtCurse() {
NbtList cursesList = new NbtList();
for (Curse.Instance instance : getCurses()) {
NbtCompound curseCompound = new NbtCompound();
curseCompound.putString("Curse", BWRegistries.CURSES.getId(instance.curse).toString());
curseCompound.putInt("Duration", instance.duration);
cursesList.add(curseCompound);
}
return cursesList;
}
use of net.minecraft.nbt.NbtCompound in project WK by witches-kitchen.
the class BrewingBarrelBlockEntity method toInitialChunkDataNbt.
@Override
public NbtCompound toInitialChunkDataNbt() {
final NbtCompound data = new NbtCompound();
writeNbt(data);
return data;
}
use of net.minecraft.nbt.NbtCompound in project WK by witches-kitchen.
the class BrewingBarrelBlockEntity method writeNbt.
@Override
protected void writeNbt(NbtCompound nbt) {
super.writeNbt(nbt);
NbtCompound clientData = new NbtCompound();
Inventories.writeNbt(clientData, this.clientInventoryManager.getStacks());
nbt.put("ClientInventory", clientData);
nbt.putInt("Timer", this.timer);
nbt.putBoolean("HasWater", this.hasWater);
nbt.putBoolean("HasFinished", this.hasFinished);
}
use of net.minecraft.nbt.NbtCompound in project WK by witches-kitchen.
the class FluidTank method writeStorage.
/**
* Writes the content of this tank.
* Must be written from {@link net.minecraft.block.entity.BlockEntity#writeNbt(NbtCompound)}
*
* @return {@link NbtCompound} that contains the data of the {@link FluidStack} of the tank
*/
@Override
public NbtCompound writeStorage() {
final NbtCompound data = new NbtCompound();
this.stack.writeToNbt(data);
return data;
}
use of net.minecraft.nbt.NbtCompound in project WK by witches-kitchen.
the class RecipeUtil method deserializeStack.
/**
* Deserializes a {@link ItemStack} from Json.
* Supports "count" and "nbt" fields.
*
* @param object JsonObject
* @return brand-new Item deserialized
*/
public static ItemStack deserializeStack(JsonObject object) {
final Identifier id = new Identifier(JsonHelper.getString(object, "item"));
final Item item = Registry.ITEM.get(id);
if (Items.AIR == item) {
throw new IllegalStateException("Invalid item: " + item);
}
int count = 1;
if (object.has("count")) {
count = JsonHelper.getInt(object, "count");
}
final ItemStack stack = new ItemStack(item, count);
if (object.has("nbt")) {
final NbtCompound tag = (NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, object.get("nbt"));
stack.setNbt(tag);
}
return stack;
}
Aggregations