Class NBTIngredient

java.lang.Object
net.minecraft.world.item.crafting.Ingredient
net.neoforged.neoforge.common.crafting.NBTIngredient
All Implemented Interfaces:
Predicate<ItemStack>

public class NBTIngredient extends Ingredient
Ingredient that matches the given items, performing either a strict or a partial NBT test.

Strict NBT ingredients will only match items that have exactly the provided tag, while partial ones will match if the item's tags contain all of the elements of the provided one, while allowing for additional elements to exist.

  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<NBTIngredient> CODEC
    • CODEC_NONEMPTY

      public static final com.mojang.serialization.Codec<NBTIngredient> CODEC_NONEMPTY
    • strict

      private final boolean strict
  • Constructor Details

    • NBTIngredient

      protected NBTIngredient(Set<Item> items, CompoundTag tag, boolean strict)
  • Method Details

    • areStacksEqual

      protected boolean areStacksEqual(ItemStack left, ItemStack right)
      Overrides:
      areStacksEqual in class Ingredient
    • synchronizeWithContents

      public boolean synchronizeWithContents()
      Description copied from class: Ingredient
      Returns if true, this ingredient will be synchronized using its contents, as in vanilla, otherwise it will be synchronized via the codec.
      Overrides:
      synchronizeWithContents in class Ingredient
      Returns:
      if true, this ingredient will be synchronized using its contents, as in vanilla, otherwise it will be synchronized via the codec
    • compareStacksWithNBT

      private static boolean compareStacksWithNBT(ItemStack left, ItemStack right)
    • of

      public static NBTIngredient of(boolean strict, CompoundTag nbt, ItemLike... items)
      Creates a new ingredient matching any item from the list, containing the given NBT
    • of

      public static NBTIngredient of(boolean strict, ItemStack stack)
      Creates a new ingredient matching the given item, containing the given NBT
    • getContainedItems

      public Set<Item> getContainedItems()
    • getTag

      public CompoundTag getTag()
    • isSimple

      public boolean isSimple()
      Overrides:
      isSimple in class Ingredient
    • isStrict

      public boolean isStrict()