use of net.minecraft.nbt.CompoundNBT in project AgriCraft by AgriCraft.
the class IrrigationNetworkLayer method writeToTag.
public CompoundNBT writeToTag() {
CompoundNBT tag = new CompoundNBT();
tag.putDouble(AgriNBT.Y1, this.getMin());
tag.putDouble(AgriNBT.Y2, this.getMax());
tag.putInt(AgriNBT.LEVEL, this.getVolume());
return tag;
}
use of net.minecraft.nbt.CompoundNBT in project AgriCraft by AgriCraft.
the class TagUtil method addNbtData.
@Nonnull
private static Optional<ItemStack> addNbtData(@Nonnull ItemStack stack, @Nullable String tags) {
// Step 0. Validate.
Preconditions.checkNotNull(stack, "The itemstack to add NBT data to may not be null");
// Step 1. Abort if tags are null.
if (Strings.isNullOrEmpty(tags)) {
return Optional.of(stack);
}
// Step 2. Get the tag instance.
final CompoundNBT tag = stack.hasTag() ? stack.getTag() : new CompoundNBT();
// Step 3. Parse the tags.
try {
final CompoundNBT added = JsonToNBT.getTagFromJson(tags);
tag.merge(added);
stack.setTag(tag);
return Optional.of(stack);
} catch (CommandSyntaxException e) {
AgriCore.getLogger("agricraft").error("Unable to parse NBT Data: \"{0}\".\nCause: {1}", tags, e);
return Optional.empty();
}
}
use of net.minecraft.nbt.CompoundNBT in project Bookshelf by Darkhax-Minecraft.
the class SerializerEnchantmentData method writeNBT.
@Override
public INBT writeNBT(EnchantmentData toWrite) {
final CompoundNBT tag = new CompoundNBT();
tag.put("enchantment", Serializers.ENCHANTMENT.writeNBT(toWrite.enchantment));
tag.put("level", Serializers.INT.writeNBT(toWrite.level));
return tag;
}
use of net.minecraft.nbt.CompoundNBT in project Bookshelf by Darkhax-Minecraft.
the class SerializerVec3d method writeNBT.
@Override
public INBT writeNBT(Vector3d toWrite) {
final CompoundNBT tag = new CompoundNBT();
tag.putDouble("x", toWrite.x());
tag.putDouble("y", toWrite.y());
tag.putDouble("z", toWrite.z());
return tag;
}
use of net.minecraft.nbt.CompoundNBT in project Bookshelf by Darkhax-Minecraft.
the class SerializerUUID method writeNBT.
@Override
public INBT writeNBT(UUID toWrite) {
final CompoundNBT tag = new CompoundNBT();
tag.putUUID("id", toWrite);
return tag;
}
Aggregations