Posted September 7, 20187 yr Hello everyone I need help please! In my mod I'm trying to make a drinkable Potion that heals player (more specifically an Estus Flask) but I'm in trouble with the code and functionality of the item, I know that I have to make a ItemFood for that and change the animation to EnumAction.DRINK but didn't work for me, if anyone could help me with the code of what to do next I will be very grateful. Thanks! This is my code so far: package com.xmorph.craftsoulsmod.items; import javax.annotation.Nonnull; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; public class ItemEstusFlask extends ItemFood { public ItemEstusFlask(String name, int amount, float saturation, boolean isWolfFood) { super(amount, saturation, isWolfFood); this.setAlwaysEdible(); this.setMaxStackSize(1); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(CreativeTabs.FOOD); } @Override @Nonnull public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } }
September 7, 20187 yr 24 minutes ago, XmorpH said: but didn't work for me This is just as ambiguous as telling a doctor it hurts. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
September 9, 20187 yr Author I know that I just created the item, and then I will have to put the heal parameters, but my problem is that in-game didn't show up the drink animation and I wonder if my code is missing something.
September 9, 20187 yr Author Well, I figured it out extending ItemFood and it worked as I want, only with the problem that the Potion Icon didn't show up. Now, if you can help me extending ItemPotion this time, I would be very grateful. Just to see what is best to do. Thanks again. Edited September 9, 20187 yr by XmorpH
September 10, 20187 yr Author It is because it's just one single "Potion" right? So extending ItemFood is better.
September 11, 20187 yr Author Why not? I want my item behavies like a vanilla instant health potion. The only thing I want is somebody help Here's my code extending ItemFood working: public class ItemCustomDrink extends ItemFood implements IHasModel { public ItemCustomDrink(String name, int amount, boolean isWolfFood) { super(amount, isWolfFood); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(CreativeTabs.BREWING); setAlwaysEdible(); setMaxStackSize(20); ModItems.ITEMS.add(this); } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } @Override public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } } And this is my Item: public class ItemEstusFlask extends ItemCustomDrink { public ItemEstusFlask(String name, int amount, boolean isWolfFood) { super(name, amount, isWolfFood); } @Override protected void onFoodEaten(ItemStack itemStack, World worldIn, EntityPlayer player) { if (!worldIn.isRemote) { player.addPotionEffect(new PotionEffect(MobEffects.INSTANT_HEALTH, 100, 1)); } } }
September 11, 20187 yr 40 minutes ago, XmorpH said: So there is an other way that I can make my item? Make your own class and override the methods that allow you to drink it and apply the potion effect. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
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.