How to mak a honey bottle type food item [custom code] (MCreator 2023.4 | Forge 1.20.1)

Started by GamerDragon525 on

Topic category: User side tutorials

Last seen on 03:35, 1. May 2024
Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to mak a honey bottle type food item [custom code] (MCreator 2023.4 | Forge 1.20.1)
Fri, 01/26/2024 - 10:03 (edited)

The title pretty much sums it all up, in this tutorial I will show you how to make a honey bottle type food item with all the proper item animations and sound effects just like the real deal! :D

Please do keep in mind that this will require editing the code of your custom food item and locking the code, but with that being said it's incredibly easy in terms of actual code itself, only basic copy/pasting and some basic understanding of programing languages in general is required.

 

first step is to just create your food item as usual, just make sure to set "item animation" to "drink"  as shown here:

image1

And set the "eating item result" to a bottle (or any other item that you wish) as shown here:

image2

this will make it so that a bottle (or the item you chose) will remain in your inventory after eating the food item

 

After you've made your food item, make sure to test it in-game and add any other desired features and or procedures before moving on to the next step, as it will be hard to add anything else after the next step in this tutorial (which will involve locking/editing the code).

Now go to your workspace where your food item is located and open it's item.java file as shown here:

image3

Once inside the file copy/past the following: 

" import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents; "  inside the file in the location shown here:

image4

As well as the following:

" @Override
public SoundEvent getDrinkingSound() {
      return SoundEvents.HONEY_DRINK;
   }
   
@Override
   public SoundEvent getEatingSound() {
      return SoundEvents.HONEY_DRINK;
   } " 

 inside the file in the location shown here:

image5

After this just simply close the file (making sure to hit save and to lock the item's code), after this you're done and can check the results in-game!! :D

Hope this little tutorial helps some of you, I really don't know much about how java-script works or even how to use it so when I figured this out I thought that I should share it as a tutorial! :]

Also please let me know how it goes if you end up trying this for yourself as I really want to know if I did a good enough job at explaining things! :P

Edited by GamerDragon525 on Fri, 01/26/2024 - 10:03
Last seen on 12:15, 2. May 2024
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nothing to add, just wanted…
Tue, 04/30/2024 - 15:35

Nothing to add, just wanted to say it works just fine for me on 1.18.2 (2022.2)