Interface IIngredient

All Superinterfaces:
CommandStringDisplayable
All Known Subinterfaces:
ForgeItemStack, IItemStack
All Known Implementing Classes:
IIngredientAny, IIngredientConditioned, IIngredientEmpty, IIngredientList, IIngredientTransformed, MCItemStack, MCItemStackMutable, TagIngredient, WrappingIIngredient

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

    • matches

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

      boolean matches(IItemStack stack, boolean ignoreDamage)
      Does the given stack match the ingredient?
      Parameters:
      stack - The stack to check
      ignoreDamage - Should damage be checked?
      DocParam:
      stack <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 (<item:minecraft:iron_ingot> | <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 <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

      default void addGlobalAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Adds an AttributeModifier to this IIngredient. Attributes added with this method appear on all ItemStacks that match this IIngredient, regardless of how or when the ItemStack was made, if you want to have the attribute on a single specific ItemStack (such as a specific Diamond Sword made in a recipe), then you should use IItemStack#withAttributeModifier
      Parameters:
      attribute - The Attribute of the modifier.
      name - The name of the modifier.
      value - The value of the modifier.
      operation - The operation of the modifier.
      slotTypes - What slots the modifier is valid for.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>, name "Extra Power", value 10, operation AttributeOperation.ADDITION, slotTypes [<constant:minecraft:equipmentslot:chest>]
    • addGlobalAttributeModifier

      default void addGlobalAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, String uuid, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Adds an AttributeModifier to this IIngredient using a specific UUID. The UUID can be used to override an existing attribute on an ItemStack with this new modifier. You can use `/ct hand attributes` to get the UUID of the attributes on an ItemStack. Attributes added with this method appear on all ItemStacks that match this IIngredient, regardless of how or when the ItemStack was made, if you want to have the attribute on a single specific ItemStack (such as a specific Diamond Sword made in a recipe), then you should use IItemStack#withAttributeModifier
      Parameters:
      uuid - The unique identifier of the modifier to replace.
      attribute - The Attribute of the modifier.
      name - The name of the modifier.
      value - The value of the modifier.
      operation - The operation of the modifier.
      slotTypes - What slots the modifier is valid for.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>, uuid "8c1b5535-9f79-448b-87ae-52d81480aaa3", name "Extra Power", value 10, operation AttributeOperation.ADDITION, slotTypes [<constant:minecraft:equipmentslot:chest>]
    • addGlobalAttributeModifier

      default void addGlobalAttributeModifier(net.minecraft.world.entity.ai.attributes.Attribute attribute, UUID uuid, String name, double value, net.minecraft.world.entity.ai.attributes.AttributeModifier.Operation operation, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Adds an AttributeModifier to this IIngredient using a specific UUID. The UUID can be used to override an existing attribute on an ItemStack with this new modifier. You can use `/ct hand attributes` to get the UUID of the attributes on an ItemStack. Attributes added with this method appear on all ItemStacks that match this IIngredient, regardless of how or when the ItemStack was made, if you want to have the attribute on a single specific ItemStack (such as a specific Diamond Sword made in a recipe), then you should use IItemStack#withAttributeModifier
      Parameters:
      uuid - The unique identifier of the modifier to replace.
      attribute - The Attribute of the modifier.
      name - The name of the modifier.
      value - The value of the modifier.
      operation - The operation of the modifier.
      slotTypes - What slots the modifier is valid for.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>, uuid IItemStack.BASE_ATTACK_DAMAGE_UUID, name "Extra Power", value 10, operation AttributeOperation.ADDITION, slotTypes [<constant:minecraft:equipmentslot:chest>]
    • removeGlobalAttribute

      default void removeGlobalAttribute(net.minecraft.world.entity.ai.attributes.Attribute attribute, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Removes all AttributeModifiers that use the given Attribute from this IIngredient. Attributes removed with this method are removed from ItemStacks that match this IIngredient, regardless of how or when the ItemStack was made, if you want to remove the attribute on a single specific ItemStack (such as a specific Diamond Sword made in a recipe), then you should use IItemStack#withoutAttribute. This method can only remove default Attributes from an ItemStack, it is still possible that an ItemStack can override it.
      Parameters:
      attribute - The attribute to remove.
      slotTypes - The slot types to remove it from.
      DocParam:
      attribute <attribute:minecraft:generic.attack_damage>, slotTypes [<constant:minecraft:equipmentslot:chest>]
    • removeGlobalAttributeModifier

      default void removeGlobalAttributeModifier(String uuid, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Removes all AttributeModifiers who's ID is the same as the given uuid from this IIngredient.
      Parameters:
      uuid - The unique id of the AttributeModifier to remove.
      slotTypes - The slot types to remove it from.
      DocParam:
      uuid "8c1b5535-9f79-448b-87ae-52d81480aaa3", slotTypes [<constant:minecraft:equipmentslot:chest>]
    • removeGlobalAttributeModifier

      default void removeGlobalAttributeModifier(UUID uuid, net.minecraft.world.entity.EquipmentSlot[] slotTypes)
      Removes all AttributeModifiers who's ID is the same as the given uuid from this IIngredient.
      Parameters:
      uuid - The unique id of the AttributeModifier to remove.
      slotTypes - The slot types to remove it from.
      DocParam:
      uuid IItemStack.BASE_ATTACK_DAMAGE_UUID, slotTypes [<constant:minecraft:equipmentslot:chest>]
    • 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.
    • transformReplace

      default IIngredientTransformed<IIngredient> transformReplace(IItemStack replaceWith)
    • transformDamage

      default IIngredientTransformed<IIngredient> transformDamage(int amount)
    • transformCustom

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

    • transform

      Use this if you already have the transformer from another ingredient
    • onlyDamaged

      default IIngredientConditioned<IIngredient> onlyDamaged()
    • onlyDamagedAtLeast

      default IIngredientConditioned<IIngredient> onlyDamagedAtLeast(int minDamage)
    • onlyDamagedAtMost

      default IIngredientConditioned<IIngredient> onlyDamagedAtMost(int maxDamage)
    • anyDamage

      default IIngredientConditioned<IIngredient> anyDamage()
    • onlyIf

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

      Use this if you already have the condition from another ingredient