2: Creating the Food SlimefunItem
The SlimefunItem is the backbone to the item registered within Slimefun and is also the object that triggers the effects when the food is eaten.
Navigate to the
Foods.java
class.Scroll down to the bottom, after the last-registered food but before the setup() method.
Create a new Food object as a constant (public static final)
The group should always be
FOODS
The ItemStack should point to the stack you made in step 1
RecipeTypes.BAKING
is for food made in the 3x3 oven.RecipeTypes.FINISHING
is for foods made in the Finishing Counter.The methods
RecipeTypes#createFoodFinishingRecipe()
andRecipeTypes#createFoodBakingRecipe()
act as both recipe registration in the two custom machines as well as returning theItemStack[]
that is required for Slimefun's guide display.The final parameter is a
Consumer<Player>
object, which may be new to some. It basically allows you to create a series of actions that will happen to the player who eats the food. You are NOT limited to thesimplePlayerEffect
method, if you want to make a Consumer that makes a player teleport somewhere, you can!Always use the builder method
.buildRegister(Cultivation.getInstance())
when finished.
For your recipe, you have access to every item within the addon.
If you want a Produce item, like Kale, for example, you access it via
CultivationStacks.KALE
If you want a By-Product item, like Boiled Kale, for example, you access it via
Products.KALE.getBoiledItem()
If you want an Ingredient Item (this is an item made by crafting previously) for example Mayonnaise, use
Ingredients.MAYONNAISE.getItem()
If you want a vanilla Minecraft item, use
new ItemStack(Material.CARROT)
Last updated