/**
* Copyright (c) Lambda Innovation Team, 2013
* 版权许可:LambdaCraft 制作小组, 2013.
* http://lambdacraft.cn/
*
* The mod is open-source. It is distributed under the terms of the
* Lambda Innovation Open Source License. It grants rights to read, modify, compile
* or run the code. It does *NOT* grant the right to redistribute this software
* or its modifications in any form, binary or source, except if expressively
* granted by the copyright holder.
*
* 本Mod是完全开源的,你允许参考、使用、引用其中的任何代码段,但不允许将其用于商业用途,在引用的时候,必须注明原作者。
*/
package cn.dawn47.equipment.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import cn.dawn47.core.item.DWGenericItem;
/**
* @author WeAthFolD
*
*/
public class ItemSuperDrink extends DWGenericItem {
/**
* @param par1
*/
public ItemSuperDrink() {
super();
setIAndU("superdrink");
}
@Override
public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer player)
{
if (!player.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
if (!par2World.isRemote)
{
player.addPotionEffect(new PotionEffect(Potion.heal.getId(), 240));
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.getId(), 240, 2));
player.addPotionEffect(new PotionEffect(Potion.jump.getId(), 240, 2));
}
return par1ItemStack;
}
/**
* How long it takes to use or consume an item
*/
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 32;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.drink;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
}