Interface IIngredient

All Superinterfaces:
CommandStringDisplayable
All Known Subinterfaces:
IItemStack
All Known Implementing Classes:
IIngredientAny, IIngredientEmpty, IIngredientList, TagIngredient, WrappingIIngredient

@ZenRegister public interface IIngredient extends CommandStringDisplayable
The CraftTweaker Ingredient class which is used to power our recipes and ItemStack matching.
DocParam:
this invalid input: '<'tag:item:minecraft:wool>
  • Field Details

    • INGREDIENT_ID

      static final net.minecraft.resources.ResourceLocation INGREDIENT_ID
    • CODEC

      static final com.mojang.serialization.Codec<IIngredient> CODEC
    • STREAM_CODEC

      static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,IIngredient> STREAM_CODEC
  • Method Details

    • matches

      boolean matches(IItemStack stack)
      Does the given stack match the ingredient?
      Parameters:
      stack - The stack to check
      DocParam:
      stack invalid input: '<'item:minecraft:iron_ingot>
    • isEmpty

      default boolean isEmpty()
      Checks if this ingredient is empty.
      Returns:
      true if empty, false otherwise
    • contains

      default boolean contains(IIngredient ingredient)
      Does the ingredient contain the given ingredient?
      Parameters:
      ingredient - The ingredient to check
      DocParam:
      ingredient (invalid input: '<'item:minecraft:iron_ingot> | invalid input: '<'item:minecraft:gold_ingot>)
    • asVanillaIngredient

      net.minecraft.world.item.crafting.Ingredient asVanillaIngredient()
      Create a Vanilla ingredient matching this one.
    • getRemainingItem

      default IItemStack getRemainingItem(IItemStack stack)
      When this ingredient stack is crafted, what will remain in the grid? Does not check if the stack matches though! Used e.g. in Crafting Table recipes.
      Parameters:
      stack - The stack to provide for this ingredient.
      DocParam:
      stack invalid input: '<'item:minecraft:iron_ingot>
    • getCommandString

      String getCommandString()
      Returns the BEP to get this stack
      Specified by:
      getCommandString in interface CommandStringDisplayable
    • getItems

      IItemStack[] getItems()
    • setBurnTime

      default void setBurnTime(int time)
      Sets the burn time of this ingredient, for use in the furnace and other machines
      Parameters:
      time - the new burn time
      DocParam:
      time 500
    • clearTooltip

      default void clearTooltip(boolean leaveName)
    • addTooltip

      default void addTooltip(net.minecraft.network.chat.Component content)
    • addShiftTooltip

      default void addShiftTooltip(net.minecraft.network.chat.Component content, net.minecraft.network.chat.Component showMessage)
    • modifyTooltip

      default void modifyTooltip(ITooltipFunction function)
    • modifyShiftTooltip

      default void modifyShiftTooltip(ITooltipFunction shiftedFunction, ITooltipFunction unshiftedFunction)
    • removeTooltip

      default void removeTooltip(String regex)
    • addGlobalAttributeModifier

      @Deprecated(forRemoval=true) default void addGlobalAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, net.minecraft.resources.ResourceLocation id, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method no longer works and is deprecated, it is left in so it doesn't cause breaking changes. Please use Item Components instead.
    • removeGlobalAttribute

      @Deprecated(forRemoval=true) default void removeGlobalAttribute(net.minecraft.world.entity.ai.attributes.Attribute attribute, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method no longer works and is deprecated, it is left in so it doesn't cause breaking changes. Please use Item Components instead.
    • removeGlobalAttributeModifier

      @Deprecated(forRemoval=true) default void removeGlobalAttributeModifier(String uuid, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method no longer works and is deprecated, it is left in so it doesn't cause breaking changes. Please use Item Components instead.
    • removeGlobalAttributeModifier

      @Deprecated(forRemoval=true) default void removeGlobalAttributeModifier(UUID uuid, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This method no longer works and is deprecated, it is left in so it doesn't cause breaking changes. Please use Item Components instead.
    • fromIngredient

      static IIngredient fromIngredient(net.minecraft.world.item.crafting.Ingredient ingredient)
    • asMapData

      default MapData asMapData()
    • asIData

      default IData asIData()
    • or

      default IIngredientList or(IIngredient other)
    • mul

      default IIngredientWithAmount mul(int amount)
      Use this in contexts where machines accept more than one item to state that fact.
    • asIIngredientWithAmount

      default IIngredientWithAmount asIIngredientWithAmount()
      Used implicitly when a machine can accept more than one item but you only provide one.
    • transformers

      IngredientTransformers transformers()
    • transformReplace

      default IIngredient transformReplace(IItemStack replaceWith)
    • transformDamage

      default IIngredient transformDamage(int amount)
    • transformCustom

      default IIngredient transformCustom(String uid, Function<IItemStack,IItemStack> function)
    • reuse

      default IIngredient reuse()
    • transform

      default IIngredient transform(IIngredientTransformer transformer)
    • conditions

      IngredientConditions conditions()
    • onlyDamaged

      default IIngredient onlyDamaged()
    • onlyDamagedAtLeast

      default IIngredient onlyDamagedAtLeast(int minDamage)
    • onlyDamagedAtMost

      default IIngredient onlyDamagedAtMost(int maxDamage)
    • anyDamage

      default IIngredient anyDamage()
    • onlyIf

      default IIngredient onlyIf(String uid, Predicate<IItemStack> function)
    • condition

      default IIngredient condition(IIngredientCondition condition)
      Use this if you already have the condition from another ingredient