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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#onDeath() . 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 check out the related API usage on the sidebar.
Example 1
Source File: SoulNetworkHandler.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
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
Source File: ItemDivineOrb.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
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
Source File: BloodStaffUpdate.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
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
Source File: SoulNetworkHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
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;
                }
            }
        }
    }
}