Item Conditions
Link to item-conditions
Sometimes normal items won't cut it:
Sometimes we want to be able to specify recipes that only work when the input item fulfills some conditions.
Sometimes we want to be able to specify recipes that will produce a special item, be it with NBT-Tag or Damage value or otherwise.
Importing the package
Link to importing-the-package
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
import crafttweaker.item.IItemCondition;
Input Conditions
Link to input-conditions
These will affect the items that you can use to craft the resulting item. Remember, you can mix modifiers, to mix Damage and NBT-Tag, for example
ZenScript Copy<minecraft:iron_pickaxe>.onlyDamaged().withTag({display: {Lore: "Aren't we all butterflies?"}});
Damage
Link to damage
anyDamage
Link to anydamage
The input item's damage value does not matter for the recipe
ZenScript Copyitem.anyDamage()
onlyDamaged
Link to onlydamaged
The input item needs to be damaged
ZenScript Copyitem.onlyDamaged();
Damaged at least
Link to damaged-at-least
Input item's damage value needs to be at least the specified value
Value
is an int
ZenScript Copyitem.onlyDamageAtLeast(value);
Damage at most
Link to damage-at-most
Input item's damage value needs to be at max the specified value
Value
is an int
ZenScript Copyitem.onlyDamageAtMost(value);
Damage between
Link to damage-between
Input item's damage value needs to be between the speciefied value1
and value2
Value1
is an int
Value2
is an int
ZenScript Copyitem.onlyDamageBetween(value1, value2);
Get Items back or explicitly forbid an item's reusability
Link to get-items-back-or-explicitly-forbid-an-items-reusability
Sometimes you need a recipe where you get some of your input items back.
By applying transformDamage(int)
you can create such recipes.
transformDamage
Link to transformdamage
The input item will receive value
damage points and you will get it back, unless it breaks during the crafting process.
Value
is an int
ZenScript Copyitem.transformDamage(value);
NBT-Tags
Link to nbt-tags
Sometimes you want your ingredients to need a specific NBT-Tag. The recipe doesn't care if your item has NBT-Tags other than the ones specified, So a pickaxe with a specific lore may also be enchanted!
If you use withTag
jei will display it properly, if you use onlyWithTag
, jei will only display a tagless item!
Here's how you do it:
NBTTag
is your NBT Data
ZenScript Copyitem.withTag(NBTData);
item.onlyWithTag(NBTTag);
<minecraft.iron_pickaxe>.onlyWithTag({display: {Name: "Pickle the Pickleberry"}});
<minecraft.iron_pickaxe>.withTag({display: {Name: "Pickle the Pickleberry"}});
Output modifiers
Link to output-modifiers
If you can specify input conditions, it's not so hard to also define output conditions, or rather, output modifiers.
Damage
Link to damage-1
Your output item will have value
damage points.
Value
is an int.
ZenScript Copyitem.withDamage(value);
NBT-Tags
Link to nbt-tags-1
Your output item will have NBTTag
as NBT-Tag.
NBTTag
is your NBT Data
ZenScript Copyitem.withTag(NBTTag);
<minecraft:iron_pickaxe>.withTag({display: {Name: "Pickle the Pickleberry"}})
Registering own item Conditions
Link to registering-own-item-conditions
You can also add your own itemConditions. These are special functions that accept the item itself as single parameter.
ZenScript CopyconditionedItem = item.only(function(item) {return true;});
The function needs to return a bool that is true if the item matches the condition.