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

Started by GamerDragon525 on

Topic category: User side tutorials

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 2022.2 - 2023.4 | Forge 1.18.2 - 1.20.1)
Tue, 09/24/2024 - 00:12 (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 Tue, 09/24/2024 - 00:12
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)

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Phrogue Nice! I’m glad to…
Tue, 09/24/2024 - 00:11

@Phrogue Nice! I’m glad to hear that this tutorial worked for you! :]

And I’ll be sure to update the title to contain the versions that it can work with, so it can hopefully help even more people in the future! :P

And also, thank you for your input, I really appreciate it!! :D