Just a quick note, I am very new to modding (literally started my first-ever mod yesterday), but I'm relatively experienced in Java.
I am attempting to create custom food items using a class that extends ItemFood. I overrode the onItemUseFinish method in my new class, keeping it exactly the same as in ItemFood but changing the sound that is played when the player eats the food. However, despite this sound playing just fine when the player finishes eating the food (exactly how it's supposed to work), the "random.eat" crunching sound is still played on repeat while holding down the food item.
Basically, I want to stop this sound from playing, but I did a bit of digging and found that the method that plays the sound, updateItemUse, is located in the EntityPlayer class (activated by an EnumAction.EAT returned by the ItemFood class), and I have no idea how to create a class that extends EntityPlayer.
I tried overriding EnumAction.EAT with EnumAction.NONE in the getItemUseAction method, but this also removes the eating animation, which I would still like to keep, just with either no sound or a custom sound.
If anyone could tell me how to either (A) create a class that extends EntityPlayer such that it can be modified and used only for my custom items, or (B) transfer the code that's triggered by EnumAction.EAT into my custom food class without any of the other default "food code" breaking, it would be a huge help. Thank you!
(Also, if there's any other way I could change the eating sound for specific food items, I would love to hear them. The two methods above are just the ones that I though of.)
Nevermind, I decided that for the purposes of my mod it was better for food items to be consumed instantly, therefore bypassing the need to maintain the animation.
Just a quick note, I am very new to modding (literally started my first-ever mod yesterday), but I'm relatively experienced in Java.
I am attempting to create custom food items using a class that extends ItemFood. I overrode the onItemUseFinish method in my new class, keeping it exactly the same as in ItemFood but changing the sound that is played when the player eats the food. However, despite this sound playing just fine when the player finishes eating the food (exactly how it's supposed to work), the "random.eat" crunching sound is still played on repeat while holding down the food item.
Basically, I want to stop this sound from playing, but I did a bit of digging and found that the method that plays the sound, updateItemUse, is located in the EntityPlayer class (activated by an EnumAction.EAT returned by the ItemFood class), and I have no idea how to create a class that extends EntityPlayer.
I tried overriding EnumAction.EAT with EnumAction.NONE in the getItemUseAction method, but this also removes the eating animation, which I would still like to keep, just with either no sound or a custom sound.
If anyone could tell me how to either (A) create a class that extends EntityPlayer such that it can be modified and used only for my custom items, or (B) transfer the code that's triggered by EnumAction.EAT into my custom food class without any of the other default "food code" breaking, it would be a huge help. Thank you!
(Also, if there's any other way I could change the eating sound for specific food items, I would love to hear them. The two methods above are just the ones that I though of.)
Nevermind, I decided that for the purposes of my mod it was better for food items to be consumed instantly, therefore bypassing the need to maintain the animation.
Thanks anyway.