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.

  1. Navigate to the Foods.java class.

  2. Scroll down to the bottom, after the last-registered food but before the setup() method.

  3. Create a new Food object as a constant (public static final)

    1. The group should always be FOODS

    2. The ItemStack should point to the stack you made in step 1

    3. RecipeTypes.BAKING is for food made in the 3x3 oven. RecipeTypes.FINISHING is for foods made in the Finishing Counter.

    4. The methods RecipeTypes#createFoodFinishingRecipe() and RecipeTypes#createFoodBakingRecipe() act as both recipe registration in the two custom machines as well as returning the ItemStack[] that is required for Slimefun's guide display.

    5. 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 the simplePlayerEffect method, if you want to make a Consumer that makes a player teleport somewhere, you can!

    6. Always use the builder method .buildRegister(Cultivation.getInstance()) when finished.

  4. For your recipe, you have access to every item within the addon.

    1. If you want a Produce item, like Kale, for example, you access it via CultivationStacks.KALE

    2. If you want a By-Product item, like Boiled Kale, for example, you access it via Products.KALE.getBoiledItem()

    3. If you want an Ingredient Item (this is an item made by crafting previously) for example Mayonnaise, use Ingredients.MAYONNAISE.getItem()

    4. If you want a vanilla Minecraft item, use new ItemStack(Material.CARROT)

Last updated