Class ItemNBTHelper

java.lang.Object
vazkii.botania.common.helper.ItemNBTHelper

public final class ItemNBTHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.world.item.ItemStack
    duplicateAndClearMana(net.minecraft.world.item.ItemStack stack)
     
    static @Nullable net.minecraft.nbt.Tag
    get(net.minecraft.world.item.ItemStack stack, String tag)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static boolean
    getBoolean(net.minecraft.world.item.ItemStack stack, String tag, boolean defaultExpected)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static byte
    getByte(net.minecraft.world.item.ItemStack stack, String tag, byte defaultExpected)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static @Nullable net.minecraft.nbt.CompoundTag
    getCompound(net.minecraft.world.item.ItemStack stack, String tag, boolean nullifyOnFail)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static double
    getDouble(net.minecraft.world.item.ItemStack stack, String tag, double defaultExpected)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static float
    getFloat(net.minecraft.world.item.ItemStack stack, String tag, float defaultExpected)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static int
    Returns the fullness of the mana item: 0 if empty, 1 if partially full, 2 if full.
    static int
    getInt(net.minecraft.world.item.ItemStack stack, String tag, int defaultExpected)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static int[]
    getIntArray(net.minecraft.world.item.ItemStack stack, String tag)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static @Nullable net.minecraft.nbt.ListTag
    getList(net.minecraft.world.item.ItemStack stack, String tag, int objtype, boolean nullifyOnFail)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static long
    getLong(net.minecraft.world.item.ItemStack stack, String tag, long defaultExpected)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static long[]
    getLongArray(net.minecraft.world.item.ItemStack stack, String tag)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static short
    getShort(net.minecraft.world.item.ItemStack stack, String tag, short defaultExpected)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static @Nullable String
    getString(net.minecraft.world.item.ItemStack stack, String tag, String defaultExpected)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static boolean
    matchTagAndManaFullness(net.minecraft.world.item.ItemStack stack1, net.minecraft.world.item.ItemStack stack2)
    Checks if two items are the same and have the same NBT.
    static void
    removeEntry(net.minecraft.world.item.ItemStack stack, String tag)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    renameTag(net.minecraft.nbt.CompoundTag nbt, String oldName, String newName)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static com.google.gson.JsonObject
    serializeStack(net.minecraft.world.item.ItemStack stack)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    set(net.minecraft.world.item.ItemStack stack, String tag, net.minecraft.nbt.Tag nbt)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setBoolean(net.minecraft.world.item.ItemStack stack, String tag, boolean b)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setByte(net.minecraft.world.item.ItemStack stack, String tag, byte b)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setCompound(net.minecraft.world.item.ItemStack stack, String tag, net.minecraft.nbt.CompoundTag cmp)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setDouble(net.minecraft.world.item.ItemStack stack, String tag, double d)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setFlag(net.minecraft.world.item.ItemStack stack, net.minecraft.core.component.DataComponentType<net.minecraft.util.Unit> component, boolean value)
     
    static void
    setFloat(net.minecraft.world.item.ItemStack stack, String tag, float f)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setInt(net.minecraft.world.item.ItemStack stack, String tag, int i)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setIntArray(net.minecraft.world.item.ItemStack stack, String tag, int[] val)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setIntNonZero(net.minecraft.world.item.ItemStack stack, net.minecraft.core.component.DataComponentType<Integer> component, int value)
     
    static void
    setList(net.minecraft.world.item.ItemStack stack, String tag, net.minecraft.nbt.ListTag list)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setLong(net.minecraft.world.item.ItemStack stack, String tag, long l)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setLongArray(net.minecraft.world.item.ItemStack stack, String tag, long[] val)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static <C extends Collection<?>>
    void
    setNonEmpty(net.minecraft.world.item.ItemStack stack, net.minecraft.core.component.DataComponentType<C> component, C collection)
     
    static <T> void
    setOptional(net.minecraft.world.item.ItemStack stack, net.minecraft.core.component.DataComponentType<? super T> component, T value)
     
    static void
    setShort(net.minecraft.world.item.ItemStack stack, String tag, short s)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setString(net.minecraft.world.item.ItemStack stack, String tag, String s)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static boolean
    verifyExistance(net.minecraft.world.item.ItemStack stack, String tag)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static boolean
    verifyType(net.minecraft.world.item.ItemStack stack, String tag, Class<? extends net.minecraft.nbt.Tag> tagClass)
    Deprecated, for removal: This API element is subject to removal in a future version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ItemNBTHelper

      public ItemNBTHelper()
  • Method Details

    • setIntNonZero

      public static void setIntNonZero(net.minecraft.world.item.ItemStack stack, net.minecraft.core.component.DataComponentType<Integer> component, int value)
    • setFlag

      public static void setFlag(net.minecraft.world.item.ItemStack stack, net.minecraft.core.component.DataComponentType<net.minecraft.util.Unit> component, boolean value)
    • setOptional

      public static <T> void setOptional(net.minecraft.world.item.ItemStack stack, net.minecraft.core.component.DataComponentType<? super T> component, @Nullable T value)
    • setNonEmpty

      public static <C extends Collection<?>> void setNonEmpty(net.minecraft.world.item.ItemStack stack, net.minecraft.core.component.DataComponentType<C> component, @Nullable C collection)
    • set

      @Deprecated(forRemoval=true) public static void set(net.minecraft.world.item.ItemStack stack, String tag, net.minecraft.nbt.Tag nbt)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setBoolean

      @Deprecated(forRemoval=true) public static void setBoolean(net.minecraft.world.item.ItemStack stack, String tag, boolean b)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setByte

      @Deprecated(forRemoval=true) public static void setByte(net.minecraft.world.item.ItemStack stack, String tag, byte b)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setShort

      @Deprecated(forRemoval=true) public static void setShort(net.minecraft.world.item.ItemStack stack, String tag, short s)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setInt

      @Deprecated(forRemoval=true) public static void setInt(net.minecraft.world.item.ItemStack stack, String tag, int i)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setIntArray

      @Deprecated(forRemoval=true) public static void setIntArray(net.minecraft.world.item.ItemStack stack, String tag, int[] val)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setLong

      @Deprecated(forRemoval=true) public static void setLong(net.minecraft.world.item.ItemStack stack, String tag, long l)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setLongArray

      @Deprecated(forRemoval=true) public static void setLongArray(net.minecraft.world.item.ItemStack stack, String tag, long[] val)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setFloat

      @Deprecated(forRemoval=true) public static void setFloat(net.minecraft.world.item.ItemStack stack, String tag, float f)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setDouble

      @Deprecated(forRemoval=true) public static void setDouble(net.minecraft.world.item.ItemStack stack, String tag, double d)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setCompound

      @Deprecated(forRemoval=true) public static void setCompound(net.minecraft.world.item.ItemStack stack, String tag, net.minecraft.nbt.CompoundTag cmp)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setString

      @Deprecated(forRemoval=true) public static void setString(net.minecraft.world.item.ItemStack stack, String tag, String s)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setList

      @Deprecated(forRemoval=true) public static void setList(net.minecraft.world.item.ItemStack stack, String tag, net.minecraft.nbt.ListTag list)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • removeEntry

      @Deprecated(forRemoval=true) public static void removeEntry(net.minecraft.world.item.ItemStack stack, String tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • verifyExistance

      @Deprecated(forRemoval=true) public static boolean verifyExistance(net.minecraft.world.item.ItemStack stack, String tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • verifyType

      @Deprecated(forRemoval=true) public static boolean verifyType(net.minecraft.world.item.ItemStack stack, String tag, Class<? extends net.minecraft.nbt.Tag> tagClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • get

      @Deprecated(forRemoval=true) @Nullable public static @Nullable net.minecraft.nbt.Tag get(net.minecraft.world.item.ItemStack stack, String tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getBoolean

      @Deprecated(forRemoval=true) public static boolean getBoolean(net.minecraft.world.item.ItemStack stack, String tag, boolean defaultExpected)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getByte

      @Deprecated(forRemoval=true) public static byte getByte(net.minecraft.world.item.ItemStack stack, String tag, byte defaultExpected)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getShort

      @Deprecated(forRemoval=true) public static short getShort(net.minecraft.world.item.ItemStack stack, String tag, short defaultExpected)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getInt

      @Deprecated(forRemoval=true) public static int getInt(net.minecraft.world.item.ItemStack stack, String tag, int defaultExpected)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getIntArray

      @Deprecated(forRemoval=true) public static int[] getIntArray(net.minecraft.world.item.ItemStack stack, String tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getLong

      @Deprecated(forRemoval=true) public static long getLong(net.minecraft.world.item.ItemStack stack, String tag, long defaultExpected)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getLongArray

      @Deprecated(forRemoval=true) public static long[] getLongArray(net.minecraft.world.item.ItemStack stack, String tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getFloat

      @Deprecated(forRemoval=true) public static float getFloat(net.minecraft.world.item.ItemStack stack, String tag, float defaultExpected)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getDouble

      @Deprecated(forRemoval=true) public static double getDouble(net.minecraft.world.item.ItemStack stack, String tag, double defaultExpected)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getCompound

      @Deprecated(forRemoval=true) @Nullable @Contract("_, _, false -> !null") public static @Nullable net.minecraft.nbt.CompoundTag getCompound(net.minecraft.world.item.ItemStack stack, String tag, boolean nullifyOnFail)
      Deprecated, for removal: This API element is subject to removal in a future version.
      If nullifyOnFail is true it'll return null if it doesn't find any compounds, otherwise it'll return a new one.
    • getString

      @Deprecated(forRemoval=true) @Nullable @Contract("_, _, !null -> !null") public static @Nullable String getString(net.minecraft.world.item.ItemStack stack, String tag, String defaultExpected)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getList

      @Deprecated(forRemoval=true) @Nullable @Contract("_, _, _, false -> !null") public static @Nullable net.minecraft.nbt.ListTag getList(net.minecraft.world.item.ItemStack stack, String tag, int objtype, boolean nullifyOnFail)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getFullness

      public static int getFullness(ManaItem item)
      Returns the fullness of the mana item: 0 if empty, 1 if partially full, 2 if full.
    • duplicateAndClearMana

      public static net.minecraft.world.item.ItemStack duplicateAndClearMana(net.minecraft.world.item.ItemStack stack)
    • matchTagAndManaFullness

      public static boolean matchTagAndManaFullness(net.minecraft.world.item.ItemStack stack1, net.minecraft.world.item.ItemStack stack2)
      Checks if two items are the same and have the same NBT. If they are `IManaItems`, their mana property is matched on whether they are empty, partially full, or full.
    • serializeStack

      @Deprecated(forRemoval=true) public static com.google.gson.JsonObject serializeStack(net.minecraft.world.item.ItemStack stack)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Serializes the given stack such that Recipe.CODEC would be able to read the result back TODO: probably not required anymore
    • renameTag

      @Deprecated(forRemoval=true) public static void renameTag(net.minecraft.nbt.CompoundTag nbt, String oldName, String newName)
      Deprecated, for removal: This API element is subject to removal in a future version.