I'm going to assume you're using the Forge API, given the parameters you listed.
EntityLiving
is an abstract type representing living entities like players and mobs. When it is passed into your block break event, it indicates the entity which broke the block. It's not guaranteed to be a player, so you need to try to cast it to the subtype that represents a player:
EntityPlayerif( playerpar7EntityLiving =instanceof (EntityPlayer ) par7EntityLiving;{
if( EntityPlayer player != null (EntityPlayer) {par7EntityLiving;
player.addExperience(-1);
// OR
player.addExperienceLevel(-1);
}
If the playerinstanceof
is nullcheck fails, then the cast failed because the parameter did not represent an EntityPlayer
object and the block break was caused by something else.