Search in sources :

Example 51 with NbtCompound

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;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) Curse(moriyashiine.bewitchment.api.registry.Curse) NbtList(net.minecraft.nbt.NbtList)

Example 52 with NbtCompound

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;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Example 53 with NbtCompound

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);
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Example 54 with NbtCompound

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;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound)

Example 55 with NbtCompound

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;
}
Also used : Item(net.minecraft.item.Item) Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) ItemStack(net.minecraft.item.ItemStack)

Aggregations

NbtCompound (net.minecraft.nbt.NbtCompound)318 NbtList (net.minecraft.nbt.NbtList)93 ItemStack (net.minecraft.item.ItemStack)69 NbtElement (net.minecraft.nbt.NbtElement)28 IOException (java.io.IOException)25 LiteralText (net.minecraft.text.LiteralText)24 Identifier (net.minecraft.util.Identifier)24 Inject (org.spongepowered.asm.mixin.injection.Inject)21 BlockPos (net.minecraft.util.math.BlockPos)20 NbtString (net.minecraft.nbt.NbtString)16 File (java.io.File)13 HashMap (java.util.HashMap)10 List (java.util.List)9 Text (net.minecraft.text.Text)9 Vec3d (net.minecraft.util.math.Vec3d)9 Map (java.util.Map)8 Items (net.minecraft.item.Items)8 TranslatableText (net.minecraft.text.TranslatableText)8 HashSet (java.util.HashSet)7 BlockEntity (net.minecraft.block.entity.BlockEntity)7