Jump to content

Recommended Posts

Posted

I am currently the coder for the Realistic Animal Products and Drops Mod(http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2389704-realistic-animal-products-and-drops-mod).  I fixed my problem with the horses, but I am now having a separate small problem.  How do I change sugar to be edible?  I've tried overriding it, but none of the code from other problems' solutions has helped.

Posted

I replied to the OP's post on minecraftforum.net:

Use Forge events.

 

PlayerInteractEvent

is fired when a player right clicks, check that the player is holding Sugar and the

Action

is

RIGHT_CLICK_AIR

then do what

ItemFood#onItemRightClick

does: check that the player can eat and then set the item in use.

Item#getMaxItemUseDuration

returns 0, so use the duration that

ItemFood#getMaxItemUseDuration

returns instead (32).

 

PlayerUseItemEvent.Finish

is fired when a player finishes using an item, check that the used item is Sugar and then do what

ItemFood#onItemUseFinish

does. You'll need to use

FoodStats#addStats(int, float)

instead of

FoodStats#addStats(ItemFood, ItemStack)

since the player didn't actually use an

ItemFood

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.