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