2
1
Fork 1
mirror of https://github.com/ACGaming/Spackenmobs synced 2024-06-10 22:48:54 +02:00
Spackenmobs/src/main/java/mod/acgaming/spackenmobs/items/ModItemFoodDrink.java
2021-09-13 19:03:13 +02:00

37 lines
1.1 KiB
Java

package mod.acgaming.spackenmobs.items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class ModItemFoodDrink extends ModItemFoodBase
{
PotionEffect effect;
public ModItemFoodDrink(String name, int amount, float saturation, boolean isAnimalFood, PotionEffect effect)
{
super(name, amount, saturation, isAnimalFood);
setAlwaysEdible();
this.effect = effect;
}
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
if (!worldIn.isRemote)
{
player.addPotionEffect(new PotionEffect(effect.getPotion(), effect.getDuration(), effect.getAmplifier(), effect.getIsAmbient(), effect.doesShowParticles()));
player.inventory.addItemStackToInventory(new ItemStack(Items.GLASS_BOTTLE));
}
}
@Override
public EnumAction getItemUseAction(ItemStack stack)
{
return EnumAction.DRINK;
}
}