Java Code Examples for net.minecraft.entity.player.EntityPlayer#onDeath()

The following examples show how to use net.minecraft.entity.player.EntityPlayer#onDeath() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public static void hurtPlayer(EntityPlayer user, int energySyphoned)
{
    if (energySyphoned < 100 && energySyphoned > 0)
    {
        if (!user.capabilities.isCreativeMode)
        {
            user.setHealth((user.getHealth() - 1));

            if (user.getHealth() <= 0.0005f)
            {
                user.onDeath(DamageSource.generic);
            }
        }
    } else if (energySyphoned >= 100)
    {
        if (!user.capabilities.isCreativeMode)
        {
            for (int i = 0; i < ((energySyphoned + 99) / 100); i++)
            {
                user.setHealth((user.getHealth() - 1));

                if (user.getHealth() <= 0.0005f)
                {
                    user.onDeath(DamageSource.generic);
                    break;
                }
            }
        }
    }
}
 
Example 2
private void hurtPlayer(EntityPlayer user, int energySyphoned)
{
    if (energySyphoned < 100 && energySyphoned > 0)
    {
        if (!user.capabilities.isCreativeMode)
        {
            user.setHealth((user.getHealth() - 1));
            if (user.getHealth() <= 0.0005f)
            {
                user.func_110142_aN().func_94547_a(new DamageSource("blooderp"), 1, 1);
                user.onDeath(new DamageSource("blooderp"));
            }
        }
    } else if (energySyphoned >= 100)
    {
        if (!user.capabilities.isCreativeMode)
        {
            for (int i = 0; i < ((energySyphoned + 99) / 100); i++)
            {
                user.setHealth((user.getHealth() - 1));
                if (user.getHealth() <= 0.0005f)
                {
                    user.func_110142_aN().func_94547_a(new DamageSource("blooderp"), 1, 1);
                    user.onDeath(new DamageSource("blooderp"));
                    break;
                }
            }
        }
    }
}
 
Example 3
public boolean syphonHealth(EntityPlayer player){
    if(player.getHealth() > 3){
        player.setHealth(player.getHealth() - 3);
        return true;
    }
    else if(player.getHealth() > 0){
        player.func_110142_aN().func_94547_a(new DamageSource("blooderp"), 3, 3);
        player.setHealth(0);
        player.onDeath(new DamageSource("blooderp"));
        return true;
    }
    else
        return false;
}
 
Example 4
public static void hurtPlayer(EntityPlayer user, int energySyphoned)
{
    if (energySyphoned < 100 && energySyphoned > 0)
    {
        if (!user.capabilities.isCreativeMode)
        {
            user.setHealth((user.getHealth() - 1));

            if (user.getHealth() <= 0.0005f)
            {
                user.onDeath(DamageSource.generic);
            }
        }
    } else if (energySyphoned >= 100)
    {
        if (!user.capabilities.isCreativeMode)
        {
            for (int i = 0; i < ((energySyphoned + 99) / 100); i++)
            {
                user.setHealth((user.getHealth() - 1));

                if (user.getHealth() <= 0.0005f)
                {
                    user.onDeath(DamageSource.generic);
                    break;
                }
            }
        }
    }
}