Interface IIngredient
- All Superinterfaces:
CommandStringDisplayable
- All Known Subinterfaces:
ForgeItemStack,IItemStack
- All Known Implementing Classes:
IIngredientAny,IIngredientConditioned,IIngredientEmpty,IIngredientList,IIngredientTransformed,MCItemStack,MCItemStackMutable,TagIngredient,WrappingIIngredient
The CraftTweaker Ingredient class which is used to power our recipes and ItemStack matching.
- DocParam:
- this <tag:items:minecraft:wool>
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddGlobalAttributeModifier(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.default voidaddGlobalAttributeModifier(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.default voidaddGlobalAttributeModifier(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.default voidaddShiftTooltip(net.minecraft.network.chat.Component content, net.minecraft.network.chat.Component showMessage) default voidaddTooltip(net.minecraft.network.chat.Component content) default IIngredientConditioned<IIngredient>default IDataasIData()default IIngredientWithAmountUsed implicitly when a machine can accept more than one item but you only provide one.default MapDatanet.minecraft.world.item.crafting.IngredientCreate a Vanilla ingredient matching this one.default voidclearTooltip(boolean leaveName) default booleancontains(IIngredient ingredient) Does the ingredient contain the given ingredient?static IIngredientfromIngredient(net.minecraft.world.item.crafting.Ingredient ingredient) Returns the BEP to get this stackgetItems()default IItemStackgetRemainingItem(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.default booleanisEmpty()Checks if this ingredient is empty.default booleanmatches(IItemStack stack) Does the given stack match the ingredient?booleanmatches(IItemStack stack, boolean ignoreDamage) Does the given stack match the ingredient?default voidmodifyShiftTooltip(ITooltipFunction shiftedFunction, ITooltipFunction unshiftedFunction) default voidmodifyTooltip(ITooltipFunction function) default IIngredientWithAmountmul(int amount) Use this in contexts where machines accept more than one item to state that fact.default IIngredientConditioned<IIngredient>only(IIngredientCondition<IIngredient> condition) Use this if you already have the condition from another ingredientdefault IIngredientConditioned<IIngredient>default IIngredientConditioned<IIngredient>onlyDamagedAtLeast(int minDamage) default IIngredientConditioned<IIngredient>onlyDamagedAtMost(int maxDamage) default IIngredientConditioned<IIngredient>onlyIf(String uid, Predicate<IItemStack> function) default IIngredientListor(IIngredient other) default voidremoveGlobalAttribute(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.default voidremoveGlobalAttributeModifier(String uuid, net.minecraft.world.entity.EquipmentSlot[] slotTypes) Removes all AttributeModifiers who's ID is the same as the given uuid from this IIngredient.default voidremoveGlobalAttributeModifier(UUID uuid, net.minecraft.world.entity.EquipmentSlot[] slotTypes) Removes all AttributeModifiers who's ID is the same as the given uuid from this IIngredient.default voidremoveTooltip(String regex) default IIngredientTransformed<IIngredient>reuse()default voidsetBurnTime(int time) Sets the burn time of this ingredient, for use in the furnace and other machinesdefault IIngredientTransformed<IIngredient>transform(IIngredientTransformer<IIngredient> transformer) Use this if you already have the transformer from another ingredientdefault IIngredientTransformed<IIngredient>transformCustom(String uid, Function<IItemStack, IItemStack> function) default IIngredientTransformed<IIngredient>transformDamage(int amount) default IIngredientTransformed<IIngredient>transformReplace(IItemStack replaceWith)
-
Method Details
-
matches
Does the given stack match the ingredient?- Parameters:
stack- The stack to check- DocParam:
- stack <item:minecraft:iron_ingot>
-
matches
Does the given stack match the ingredient?- Parameters:
stack- The stack to checkignoreDamage- 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
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
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:
getCommandStringin interfaceCommandStringDisplayable
-
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
-
modifyShiftTooltip
default void modifyShiftTooltip(ITooltipFunction shiftedFunction, ITooltipFunction unshiftedFunction) -
removeTooltip
-
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
-
asMapData
-
asIData
-
or
-
mul
Use this in contexts where machines accept more than one item to state that fact. -
asIIngredientWithAmount
Used implicitly when a machine can accept more than one item but you only provide one. -
transformReplace
-
transformDamage
-
transformCustom
default IIngredientTransformed<IIngredient> transformCustom(String uid, Function<IItemStack, IItemStack> function) -
reuse
-
transform
default IIngredientTransformed<IIngredient> transform(IIngredientTransformer<IIngredient> transformer) Use this if you already have the transformer from another ingredient -
onlyDamaged
-
onlyDamagedAtLeast
-
onlyDamagedAtMost
-
anyDamage
-
onlyIf
-
only
Use this if you already have the condition from another ingredient
-