Minecraft Forge 1.14.X Tutorial: Creating Food

Hello Explorers,

Seen some people struggling with this and i've not seen many people do a tutorial on it so far, so this is a little tutorial to give you the basic run down on how to create foods in forge 1.14, i'm using 1.14.3.

This tutorial is going to assume you have a forge environment setup, you've made some blocks and items and know how to setup the JSONs and textures for the relative items as really that's all you need to learn to make food and then apply the extra logic from this tutorial!

So first thing you need to do create your item, so for me that involves:

1. Adding my item to my ModItemsList or ModItems, whatever format you're using:


2. Register the item is your Event-subscriber and give it the basic item properties, so your ItemGroup:


3. Create the item Json and Textures and put them in the correct folders:


4. Check the item works in game and loads properly:



What these steps will get you to do is have an item that looks like a food but you can't do anything with it yet, so once you've gotten that far, we can move onto the main part of the tutorial that involves creating food!

This is where it can get surprising easy! so you have your item setup, it loads, its textured but you want the player to be able to eat it! 

All you need to do now, is in the "Item.Properties()" add: .food():

There is still one more step we need to do to get the food item working but from Minecrafts point of view, simply putting this tag in the item properties tells the game that the item is food. However, we need to fill that .food with something! Now if you are simply happy with the default Minecraft values of a food, simply add "Foods.DRIED_KELP" into .food():




As my food is dried fruit, I'd want it to give the same health and saturation and eating speed as kelp, because vanilla Minecraft has so many foods and values, you could probably get away without the final step here and use all the default values and change "Foods.DRIED_KELP" to whatever food  that matches yours! So if you're happy with that, go off my young culinary Modders and make all the delicious Minecraft foods! 


Now, if you're still here, I'm assuming you want to create different valued foods or have more control or even to create unique and interesting food properties! well you're in luck, that is still very much possible and only requires a little bit of work to get done, basically you need to make your own Foods.class.

So somewhere in your project folder, create a new class folder called: ModFoods.class with mod being the name of your mod.

I originally copied the Foods.class from Minecraft, stripped away all the original foods and added my own, this gave me the basic structure for the file and also included the builder to make stew items, your file should look something like this: 



After that is completed, all you need to do is simply is go back to your item properties and change Foods.DRIED_KELP to ModFoods.DRIED_FRUITS:



Phew! Job done! Simply load Minecraft and test the food items, if you want to make your testing easier, in the Foods file, add ".setAlwaysEdible()" so that you can eat the food with full hunger/saturation! 

Hope this is helpful! If you liked the tutorial, want more, need help or have suggestions, leave a comment or catch me on twitter: Twitter 

Subscribe for more Updates.

See you in my next post!

@DriscollCreations

Get the mod here: Explorercraft


Comments

  1. Hey, can you make a tutorial on creating a custom trident as well? I wanna try later, but I'm already overwhelmed by looking at it.

    Gonna want to make a custom shape and texture for the trident too, so if you can cover that as well that would be awesome!

    ReplyDelete
  2. Hi, I'm getting an error and I wonder whether you could help, it is: "the method food(food) is undefined for the type item".
    Thanks in advance.

    ReplyDelete
  3. Where did you find the "setup" method?

    ReplyDelete
    Replies
    1. I think he followed this Tutorial: https://cadiboo.github.io/tutorials/1.15.1/forge/1.5-first-item/

      Where setup is a custom register method

      Delete

Post a Comment

Popular Posts