Search in sources :

Example 66 with CompoundNBT

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

Example 67 with CompoundNBT

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();
    }
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) Nonnull(javax.annotation.Nonnull)

Example 68 with CompoundNBT

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

Example 69 with CompoundNBT

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

Example 70 with CompoundNBT

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

Aggregations

CompoundNBT (net.minecraft.nbt.CompoundNBT)119 ItemStack (net.minecraft.item.ItemStack)33 ListNBT (net.minecraft.nbt.ListNBT)15 Nonnull (javax.annotation.Nonnull)12 PlayerEntity (net.minecraft.entity.player.PlayerEntity)10 ResourceLocation (net.minecraft.util.ResourceLocation)8 BlockPos (net.minecraft.util.math.BlockPos)8 TileEntity (net.minecraft.tileentity.TileEntity)7 StringTextComponent (net.minecraft.util.text.StringTextComponent)7 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)6 DimensionType (net.minecraft.world.dimension.DimensionType)6 TileBPMultipart (com.bluepowermod.tile.TileBPMultipart)5 Block (net.minecraft.block.Block)5 BlockState (net.minecraft.block.BlockState)5 ArrayList (java.util.ArrayList)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 SUpdateTileEntityPacket (net.minecraft.network.play.server.SUpdateTileEntityPacket)4 LongItemStack (com.cjm721.overloaded.storage.stacks.intint.LongItemStack)3 Nullable (javax.annotation.Nullable)3 IItemProvider (net.minecraft.util.IItemProvider)3