Search in sources :

Example 96 with NbtList

use of net.minecraft.nbt.NbtList in project bewitchment by MoriyaShiine.

the class DemonEntity method writeCustomDataToNbt.

@Override
public void writeCustomDataToNbt(NbtCompound nbt) {
    super.writeCustomDataToNbt(nbt);
    nbt.putBoolean("Male", dataTracker.get(MALE));
    if (!offers.isEmpty()) {
        NbtList offersList = new NbtList();
        for (DemonTradeOffer offer : offers) {
            offersList.add(offer.toTag());
        }
        nbt.put("Offers", offersList);
    }
    nbt.putInt("TradeResetTimer", tradeResetTimer);
}
Also used : NbtList(net.minecraft.nbt.NbtList)

Example 97 with NbtList

use of net.minecraft.nbt.NbtList in project bewitchment by MoriyaShiine.

the class ContractsComponent method readFromNbt.

@Override
public void readFromNbt(NbtCompound tag) {
    NbtList contractsList = tag.getList("Contracts", NbtType.COMPOUND);
    for (int i = 0; i < contractsList.size(); i++) {
        NbtCompound contractCompound = contractsList.getCompound(i);
        addContract(new Contract.Instance(BWRegistries.CONTRACTS.get(new Identifier(contractCompound.getString("Contract"))), contractCompound.getInt("Duration"), contractCompound.getInt("Cost")));
    }
}
Also used : Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) Contract(moriyashiine.bewitchment.api.registry.Contract)

Example 98 with NbtList

use of net.minecraft.nbt.NbtList in project bewitchment by MoriyaShiine.

the class ContractsComponent method toNbtContract.

@SuppressWarnings("ConstantConditions")
public NbtList toNbtContract() {
    NbtList contractsTag = new NbtList();
    for (Contract.Instance instance : getContracts()) {
        NbtCompound contractCompound = new NbtCompound();
        contractCompound.putString("Contract", BWRegistries.CONTRACTS.getId(instance.contract).toString());
        contractCompound.putInt("Duration", instance.duration);
        contractCompound.putInt("Cost", instance.cost);
        contractsTag.add(contractCompound);
    }
    return contractsTag;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) Contract(moriyashiine.bewitchment.api.registry.Contract)

Example 99 with NbtList

use of net.minecraft.nbt.NbtList in project bewitchment by MoriyaShiine.

the class CursesComponent method readFromNbt.

@Override
public void readFromNbt(NbtCompound tag) {
    NbtList cursesList = tag.getList("Curses", NbtType.COMPOUND);
    for (int i = 0; i < cursesList.size(); i++) {
        NbtCompound curseCompound = cursesList.getCompound(i);
        addCurse(new Curse.Instance(BWRegistries.CURSES.get(new Identifier(curseCompound.getString("Curse"))), curseCompound.getInt("Duration")));
    }
}
Also used : Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) Curse(moriyashiine.bewitchment.api.registry.Curse) NbtList(net.minecraft.nbt.NbtList)

Example 100 with NbtList

use of net.minecraft.nbt.NbtList in project bewitchment by MoriyaShiine.

the class BWUniversalWorldState method writeNbt.

@Override
public NbtCompound writeNbt(NbtCompound nbt) {
    NbtList pledgesToRemoveList = new NbtList();
    for (UUID uuid : this.pledgesToRemove) {
        NbtCompound pledgeCompound = new NbtCompound();
        pledgeCompound.putUuid("UUID", uuid);
        pledgesToRemoveList.add(pledgeCompound);
    }
    nbt.put("PledgesToRemove", pledgesToRemoveList);
    NbtList familiarsList = new NbtList();
    for (Pair<UUID, NbtCompound> pair : this.familiars) {
        NbtCompound familiarCompound = new NbtCompound();
        familiarCompound.putUuid("Player", pair.getLeft());
        familiarCompound.put("Familiar", pair.getRight());
        familiarsList.add(familiarCompound);
    }
    nbt.put("Familiars", familiarsList);
    return nbt;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) UUID(java.util.UUID)

Aggregations

NbtList (net.minecraft.nbt.NbtList)146 NbtCompound (net.minecraft.nbt.NbtCompound)79 NbtElement (net.minecraft.nbt.NbtElement)45 Identifier (net.minecraft.util.Identifier)37 ItemStack (net.minecraft.item.ItemStack)25 NbtString (net.minecraft.nbt.NbtString)16 LiteralText (net.minecraft.text.LiteralText)12 BlockPos (net.minecraft.util.math.BlockPos)11 Block (net.minecraft.block.Block)9 List (java.util.List)8 Item (net.minecraft.item.Item)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 IOException (java.io.IOException)6 Items (net.minecraft.item.Items)6 NbtIo (net.minecraft.nbt.NbtIo)6 StatusEffect (net.minecraft.entity.effect.StatusEffect)5 Text (net.minecraft.text.Text)5 Comparator (java.util.Comparator)4 Blocks (net.minecraft.block.Blocks)4 EntityType (net.minecraft.entity.EntityType)4