Class Ingredient

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

public final class Ingredient extends Object implements Predicate<ItemStack>
  • Field Details

    • EMPTY

      public static final Ingredient EMPTY
    • CONTENTS_STREAM_CODEC

      public static final StreamCodec<RegistryFriendlyByteBuf,Ingredient> CONTENTS_STREAM_CODEC
    • values

      private final Ingredient.Value[] values
    • itemStacks

      @Nullable private ItemStack[] itemStacks
    • stackingIds

      @Nullable private it.unimi.dsi.fastutil.ints.IntList stackingIds
    • customIngredient

      @Nullable private ICustomIngredient customIngredient
    • CODEC

      public static final com.mojang.serialization.Codec<Ingredient> CODEC
      This codec allows both the {...} and [{...}, {...}, ...] syntax. [] is allowed for empty ingredients, and will only match empty stacks.
    • CODEC_NONEMPTY

      public static final com.mojang.serialization.Codec<Ingredient> CODEC_NONEMPTY
      Same as CODEC except that empty ingredients ([]) are not allowed.
    • MAP_CODEC_NONEMPTY

      public static final com.mojang.serialization.MapCodec<Ingredient> MAP_CODEC_NONEMPTY
      This is a codec that only allows the {...} syntax. Array ingredients are serialized using the CompoundIngredient custom ingredient type: { "type": "neoforge:compound", "ingredients": [{...}, {...}, ...] }.
    • LIST_CODEC

      public static final com.mojang.serialization.Codec<List<Ingredient>> LIST_CODEC
    • LIST_CODEC_NONEMPTY

      public static final com.mojang.serialization.Codec<List<Ingredient>> LIST_CODEC_NONEMPTY
  • Constructor Details

  • Method Details

    • getItems

      public ItemStack[] getItems()
    • test

      public boolean test(@Nullable ItemStack p_43914_)
      Specified by:
      test in interface Predicate<ItemStack>
    • getStackingIds

      public it.unimi.dsi.fastutil.ints.IntList getStackingIds()
    • isEmpty

      public boolean isEmpty()
      Returns true if this ingredient is explicitly chosen to be empty, i.e. using [].
    • hasNoItems

      public boolean hasNoItems()
      Returns true if this ingredient has an empty stack list. Unlike isEmpty(), this will catch "accidentally empty" ingredients, for example a tag ingredient that has an empty tag.
    • equals

      public boolean equals(Object p_301003_)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getValues

      public Ingredient.Value[] getValues()
      Retrieves the underlying values of this ingredient. If this is a custom ingredient, an exception is thrown.
    • isSimple

      public boolean isSimple()
    • getCustomIngredient

      @Nullable public ICustomIngredient getCustomIngredient()
    • isCustom

      public boolean isCustom()
    • fromValues

      public static Ingredient fromValues(Stream<? extends Ingredient.Value> p_43939_)
    • of

      public static Ingredient of()
    • of

      public static Ingredient of(ItemLike... p_43930_)
    • of

      public static Ingredient of(ItemStack... p_43928_)
    • of

      public static Ingredient of(Stream<ItemStack> p_43922_)
    • of

      public static Ingredient of(TagKey<Item> p_204133_)
    • codec

      @Deprecated private static com.mojang.serialization.Codec<Ingredient> codec(boolean p_301074_)
      Deprecated.