I'm creating Minecraft mod with a pickaxe that takes away experience when you break a block. The method for taking away experience from a player is addExperience
on EntityPlayer
, so I need to get an instance of EntityPlayer
for the player using my pickaxe when the pickaxe breaks a block, so that I can remove the appropriate amount of experience.
My pickaxe class currently looks like this:
public class ExperiencePickaxe extends ItemPickaxe {
public ExperiencePickaxe(int ItemID, EnumToolMaterial material){
super(ItemID, material);
}
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
EntityPlayer e = new EntityPlayer(); // create an instance
e.addExperience(-1);
}
return true;
}
}
Obviously, I cannot actually create a new EntityPlayer
since it is an abstract class. How can I get access to the player using my pickaxe?