Awesome_Spider Posted March 3, 2017 Share Posted March 3, 2017 I would like to, when the player drinks a water bottle, add hydration to an already attached capability on the player. I found an event called LivingEntityUseItemEvent that has a few sub-events. I think the one I want is Finish but I'm not entirely sure. I want the water bottle to be consumed by the player, but I also want to add to the capability when the player is done drinking it. Would this be the right event? My second question is what is the water bottle called in the Minecraft code? Is it under the potion? Quote Link to comment Share on other sites More sharing options...
Draco18s Posted March 3, 2017 Share Posted March 3, 2017 3 hours ago, Awesome_Spider said: My second question is what is the water bottle called in the Minecraft code? Is it under the potion? Yes. Potions use an NBT "Potion" tag to indicate the potion type. http://minecraft.gamepedia.com/Potion#Data_values 1 Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Awesome_Spider Posted March 3, 2017 Author Share Posted March 3, 2017 Thanks. I would have thought it would just be a damage value. Quote Link to comment Share on other sites More sharing options...
Choonster Posted March 4, 2017 Share Posted March 4, 2017 (edited) LivingEntityUseItemEvent.Finish is fired when an entity finishes using an item (i.e. uses it for its full duration), directly after Item#onItemUseFinish is called. This is probably the event you want. If the entity was using a potion, the stack size will have already been reduced by 1 when the event is fired. If the stack was empty after this (i.e. stack size was reduced to 0), it will have been replaced by an ItemStack of Items.GLASS_BOTTLE. If you want access to the original ItemStack, you'd need to subscribe to LivingEntityUseItemEvent.Tick and store a copy of it (not the original) in a capability attached to the entity (if it's a potion). The PotionUtils class has several methods that read PotionEffects from potion item NBT. Edited March 4, 2017 by Choonster 1 Quote 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. Link to comment Share on other sites More sharing options...
Awesome_Spider Posted March 4, 2017 Author Share Posted March 4, 2017 Thanks for the detailed replay. I'll try that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.