Food Items
Link to food-items
This allows you to add food items to the game!
Create the Food Item Representation
Link to create-the-food-item-representation
Before you can add the item, you need to create a food item Representation which will allow you to set the properties of the item you want to add.
This is where the VanillaFactory comes in:
ZenScript Copymods.contenttweaker.VanillaFactory.createItemFood(String unlocalizedName, int healAmount);
Import the representation Package
Link to import-the-representation-package
It might be required for you to import the package if you encounter any issues, so better be safe than sorry and add the import.
import mods.contenttweaker.ItemFood;
ItemRepresentation Expansion
Link to itemrepresentation-expansion
The ItemFoodRepresentation class expands ItemRepresentation. That means all Methods and ZenProperties that are available for Items are also available for food items!
ZenProperties
Link to zenproperties
To get/set the properties you can either use the respecting ZenGetters/Setters or the ZenMethods:
ZenScript Copy//property name: healAmount
//ZenGetter
print(item.healAmount);
//ZenSetter
item.healAmount = 16;
//ZenMethods
item.getHealAmount();
item.setHealAmount(64);
Property | 类型 | Required | 默认值 | Description/Notes |
---|---|---|---|---|
Property healAmount | 类型 int | Required Yes | 默认值 | Description/Notes How many food points are restored when eaten? |
Property alwaysEdible | 类型 bool | Required No | 默认值 false | Description/Notes Can the food still be eaten if the user's food bar is full? |
Property wolfFood | 类型 bool | Required No | 默认值 false | Description/Notes Can the food be used to tame woves? |
Property saturation | 类型 float | Required No | 默认值 0.6 | Description/Notes The food's Saturation Value |
Property onItemFoodEaten | 类型 IItemFoodEaten | Required No | 默认值 null | Description/Notes Called when the food item is eaten |
Registering the item
Link to registering-the-item
You need to call this method to register the item in the game!
Otherwise nothing will happen!
After you have called this function, you cannot un-register the item or change any of it's properties!
ZenScript Copyitem.register();