resonant-induction/archive/java/resonantinduction/old/core/misc/ItemFarmEgg.java
2014-01-11 17:44:07 +08:00

42 lines
1 KiB
Java

package resonantinduction.old.core.misc;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemFarmEgg extends Item
{
public ItemFarmEgg(int par1)
{
super(par1);
this.maxStackSize = 16;
this.setCreativeTab(CreativeTabs.tabMaterials);
this.setHasSubtypes(true);
this.setUnlocalizedName("egg");
this.setTextureName("egg");
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
* world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (!player.capabilities.isCreativeMode)
{
--itemStack.stackSize;
}
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote)
{
world.spawnEntityInWorld(new EntityFarmEgg(world, player, itemStack.getItemDamage()));
}
return itemStack;
}
}