modder819 Posted July 10, 2018 Posted July 10, 2018 (edited) I'm trying to create a "lemonade" potion. I'd like it to look yellow, and not shimmer (the way that a water bottle looks, except yellow instead of blue). It should boost health when drunk. I looked but couldn't find any info about creating potions in the MinecraftForge documentation. I tried doing something like this: @Mod(modid=modId, name="Lemonade Mod", version="1.0") public class LemonadeMod { ... private static final Potion POTION_LEMONADE = new PotionHealth(false, 0xFF_FF_FF_55); private static final PotionType POTION_TYPE_LEMONADE = new PotionType("lemonade", new PotionEffect(POTION_LEMONADE)); ... @Mod.EventBusSubscriber public static class RegistrationHandler { @SubscribeEvent public static void registerPotions(RegistryEvent.Register<Potion> event) { event.getRegistry().register(POTION_LEMONADE.setRegistryName("lemonade")); } @SubscribeEvent public static void registerPotionTypes(RegistryEvent.Register<PotionType> event) { event.getRegistry().register(POTION_TYPE_LEMONADE.setRegistryName("lemonade")); } } } This created a new potion, but it shimmered (enchantment glint?). Do I need to create a subclass of ItemPotion and override the hasEffect method? If so, how do I associate the PotionType with an instance of my ItemPotion subclass? Edited July 10, 2018 by modder819 incomplete Quote
aw_wolfe Posted July 10, 2018 Posted July 10, 2018 If you use the lemonade as a potion, the built in system will add others... I think extended lemonade, splash lemonade, etc. Would it be better to make the lemonade a "normal" item? Override public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } This will also deal with the shimmer issue. Then you can simply set up a brewing recipe to produce your lemonade. Quote
modder819 Posted July 11, 2018 Author Posted July 11, 2018 I created my own item, and overrode getItemUseAction, but right-clicking had no effect. So then I also overrode onItemRightClick, using the code from the ItemPotion class: public class ItemLemonade extends Item { @Override public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { playerIn.setActiveHand(handIn); return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } } Now right-clicking does an animation when I've equipped the potion, but it's a different animation from the one with a regular potion (the potion just goes up and down in the character's right hand instead of centering like a potion). How do I recreate the animation of a regular potion? Also, how do I add in the sound effect that occurs when drinking a regular potion? Quote
aw_wolfe Posted July 11, 2018 Posted July 11, 2018 I think your issue was the time of use of the item was too short and the animation sound didn't play. These 3 overrides from ItemPotion work for me in a new Item. @Override public int getMaxItemUseDuration(ItemStack stack) { return 32; } @Override public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { playerIn.setActiveHand(handIn); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } 1 Quote
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.