This works perfectly... the problem is to I can't see the potion countdown in my inventory, I only see its particles even though I added the texture's for the potion.
@SubscribeEvent
public void applyEffect(PlayerEvent.Clone player) {
if (player.isWasDeath())
if (ConfigHandler.noEating)
player.getEntityPlayer().addPotionEffect(new PotionEffect(ModPotions.appetite, ConfigHandler.noEatingTime));
}
@SubscribeEvent
public void itemInteract(PlayerInteractEvent.RightClickItem event) {
if (ConfigHandler.noEating)
if (event.getItemStack().getItemUseAction() == EnumAction.EAT)
if (event.getEntityPlayer().isPotionActive(ModPotions.appetite))
event.setCanceled(true);
}
PotionDefault Class
public class PotionDefault extends Potion
{
private static final ResourceLocation POTIONS_LOCATION = new ResourceLocation("keephunger:textures/potions/inventory.png");
protected PotionDefault(boolean isBadEffectIn, int liquidColorIn, int x, int y)
{
super(isBadEffectIn, liquidColorIn);
this.setIconIndex(x, y);
}
@Override
@SideOnly(Side.CLIENT)
public boolean hasStatusIcon()
{
Minecraft.getMinecraft().getTextureManager().bindTexture(POTIONS_LOCATION);
return super.hasStatusIcon();
}
}
No Appetite Effect
public class NoAppetiteEffect extends PotionDefault {
public NoAppetiteEffect(int id)
{
super(true, 0x8DCDA3, 1,1);
}
}
ModPotions Class
public class ModPotions {
public static Potion appetite;
public static void init()
{
appetite = registerPotion("appetite", new NoAppetiteEffect(26).setPotionName("potion.appetite"));
}
public static Potion registerPotion(String name, Potion potion)
{
GameRegistry.register(potion, new ResourceLocation(MainClass.MODID, name));
return potion;
}
public static PotionType registerPotionType(String name, PotionType potionType)
{
GameRegistry.register(potionType, new ResourceLocation(MainClass.MODID, name));
return potionType;
}
}