use of net.minecraft.nbt.NbtCompound in project ProbablyChests by ReillyGregorio.
the class PCChestMimic method writeCustomDataToNbt.
public void writeCustomDataToNbt(NbtCompound nbt) {
super.writeCustomDataToNbt(nbt);
nbt.putBoolean("wasOnGround", this.onGroundLastTick);
nbt.putBoolean("grounded", this.isOnGround());
nbt.putBoolean("jumping", this.isJumping());
nbt.putBoolean("idle", this.isIdle());
nbt.putBoolean("flying", this.isFlying());
nbt.putBoolean("sleeping", this.isSleeping());
NbtList listnbt = new NbtList();
for (int i = 0; i < this.inventory.size(); ++i) {
ItemStack itemstack = this.inventory.getStack(i);
NbtCompound compoundnbt = new NbtCompound();
compoundnbt.putByte("Slot", (byte) i);
itemstack.writeNbt(compoundnbt);
listnbt.add(compoundnbt);
}
nbt.put("Inventory", listnbt);
}
use of net.minecraft.nbt.NbtCompound in project ProbablyChests by ReillyGregorio.
the class PCChestMimicPet method readCustomDataFromNbt.
public void readCustomDataFromNbt(NbtCompound nbt) {
super.readCustomDataFromNbt(nbt);
this.onGroundLastTick = nbt.getBoolean("wasOnGround");
this.setIsGrounded(nbt.getBoolean("grounded"));
this.setIsJumping(nbt.getBoolean("jumping"));
this.setIsIdle(nbt.getBoolean("idle"));
this.setIsFlying(nbt.getBoolean("flying"));
this.setIsSleeping(nbt.getBoolean("sleeping"));
NbtList listnbt = nbt.getList("Inventory", 10);
for (int i = 0; i < listnbt.size(); ++i) {
NbtCompound compoundnbt = listnbt.getCompound(i);
int j = compoundnbt.getByte("Slot") & 255;
this.inventory.setStack(j, ItemStack.fromNbt(compoundnbt));
}
}
use of net.minecraft.nbt.NbtCompound in project ProbablyChests by ReillyGregorio.
the class Config method toJson.
private JsonObject toJson(NbtCompound tag) {
JsonObject json = new JsonObject();
NbtCompound defaults = getDefaults();
json.addProperty("pot_spawn_chance", getFloatOrDefault(tag, "pot_spawn_chance", defaults));
json.addProperty("chest_spawn_chance", getFloatOrDefault(tag, "chest_spawn_chance", defaults));
json.addProperty("surface_chest_spawn_chance", getFloatOrDefault(tag, "surface_chest_spawn_chance", defaults));
json.addProperty("mimic_chance", getFloatOrDefault(tag, "mimic_chance", defaults));
json.addProperty("easier_mimics", getBooleanOrDefault(tag, "easier_mimics", defaults));
json.addProperty("spawn_natural_mimics", getBooleanOrDefault(tag, "spawn_natural_mimics", defaults));
json.addProperty("natural_mimic_spawn_rate_modifier", getFloatOrDefault(tag, "natural_mimic_spawn_rate_modifier", defaults));
json.addProperty("allow_pet_mimics", getBooleanOrDefault(tag, "allow_pet_mimics", defaults));
// json.addProperty("max_pet_mimics", getIntOrDefault(tag, "max_pet_mimics", defaults));
createFile(json, difference > 0);
difference = 0;
return json;
}
use of net.minecraft.nbt.NbtCompound in project Astromine by Mixinors.
the class WorldHoloBridgeComponent method writeToNbt.
/**
* Serializes this {@link WorldHoloBridgeComponent} to a {@link NbtCompound}.
*/
@Override
public void writeToNbt(NbtCompound tag) {
var dataTag = new NbtList();
for (var entry : entries.long2ObjectEntrySet()) {
var pointTag = new NbtCompound();
var vecs = new long[entry.getValue().size()];
var i = 0;
for (var vec : entry.getValue()) {
vecs[i++] = BlockPos.asLong(vec.getX(), vec.getY(), vec.getZ());
}
pointTag.putLong("Positions", entry.getLongKey());
pointTag.put("Vectors", new NbtLongArray(vecs));
dataTag.add(pointTag);
}
tag.put("Data", dataTag);
}
use of net.minecraft.nbt.NbtCompound in project More-Weaponry by DakotaPride.
the class IronBoltEntity method writeCustomDataToNbt.
public void writeCustomDataToNbt(NbtCompound nbt) {
super.writeCustomDataToNbt(nbt);
if (this.potion != Potions.EMPTY) {
nbt.putString("Potion", Registry.POTION.getId(this.potion).toString());
}
if (this.colorSet) {
nbt.putInt("Color", this.getColor());
}
if (!this.effects.isEmpty()) {
NbtList nbtList = new NbtList();
Iterator var3 = this.effects.iterator();
while (var3.hasNext()) {
StatusEffectInstance statusEffectInstance = (StatusEffectInstance) var3.next();
nbtList.add(statusEffectInstance.writeNbt(new NbtCompound()));
}
nbt.put("CustomPotionEffects", nbtList);
}
}
Aggregations