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

The following are Jave code examples for showing how to use heal() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Halloween   File: ItemMegaCandy.java   View Source Code Vote up 5 votes
@Override
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player)
{
	player.heal(5.0F);

	List<EntityCurse> entities = world.getEntitiesWithinAABB(EntityCurse.class, player.getEntityBoundingBox().grow(4.0D, 4.0D, 4.0D));
	for (EntityCurse entity : entities)
	{
		if (entity.victim == player)
		{
			entity.setDead();
		}
	}
}
 
Example 2
Project: Mods   File: ItemSoldierBackpack.java   View Source Code Vote up 5 votes
@Override
public void onArmorTick(World world, final EntityPlayer player, ItemStack itemStack) {
	if (!world.isRemote) {
		if (player.ticksExisted % 20 == 0) {
			float heal = TF2Attribute.getModifier("Health Regen", itemStack, 0, player);
			if(heal > 0) {
				int lastHitTime = player.ticksExisted - player.getEntityData().getInteger("lasthit");
				if (lastHitTime >= 120)
					player.heal(heal);
				else if(lastHitTime >= 60)
					player.heal(TF2Util.lerp(heal, heal/4f, (lastHitTime-60)/60f));
				else
					player.heal(heal/4f);
			}
		}
		if (player.ticksExisted % 5 == 0 && itemStack.getTagCompound().getBoolean("Active")) {
			itemStack.getTagCompound().setFloat("Rage",
					Math.max(0,
							itemStack.getTagCompound().getFloat("Rage")
									- 1 / (TF2Attribute.getModifier("Buff Duration", itemStack,
											getData(itemStack).getInt(PropertyType.DURATION), player) - 20)));
			if (itemStack.getTagCompound().getFloat("Rage") <= 0)
				itemStack.getTagCompound().setBoolean("Active", false);
			for (EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class,
					player.getEntityBoundingBox().grow(10, 10, 10), new Predicate<EntityLivingBase>() {

						@Override
						public boolean apply(EntityLivingBase input) {
							// TODO Auto-generated method stub
							return TF2Util.isOnSameTeam(player, input);
						}

					}))
				living.addPotionEffect(new PotionEffect(this.getBuff(itemStack), 25));

		}
		if (player.isCreative())
			itemStack.getTagCompound().setFloat("Rage", 1);
	}
}
 
Example 3
Project: harshencastle   File: BloodyEarring.java   View Source Code Vote up 4 votes
@Override
public void onTick(EntityPlayer player, int tick) {
	if(tick % 140 == 0)
		player.heal(2f);
}
 
Example 4
Project: DecompiledMinecraft   File: FoodStats.java   View Source Code Vote up 4 votes
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    if (player.worldObj.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(3.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
Example 5
Project: DecompiledMinecraft   File: FoodStats.java   View Source Code Vote up 4 votes
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    if (player.worldObj.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(3.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
Example 6
Project: BaseClient   File: FoodStats.java   View Source Code Vote up 4 votes
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    if (player.worldObj.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(3.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
Example 7
Project: BaseClient   File: FoodStats.java   View Source Code Vote up 4 votes
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    if (player.worldObj.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(3.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
Example 8
Project: Backmemed   File: FoodStats.java   View Source Code Vote up 4 votes
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.world.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    boolean flag = player.world.getGameRules().getBoolean("naturalRegeneration");

    if (flag && this.foodSaturationLevel > 0.0F && player.shouldHeal() && this.foodLevel >= 20)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 10)
        {
            float f = Math.min(this.foodSaturationLevel, 6.0F);
            player.heal(f / 6.0F);
            this.addExhaustion(f);
            this.foodTimer = 0;
        }
    }
    else if (flag && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(6.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}
 
Example 9
Project: CustomWorldGen   File: FoodStats.java   View Source Code Vote up 4 votes
/**
 * Handles the food game logic.
 */
public void onUpdate(EntityPlayer player)
{
    EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
    this.prevFoodLevel = this.foodLevel;

    if (this.foodExhaustionLevel > 4.0F)
    {
        this.foodExhaustionLevel -= 4.0F;

        if (this.foodSaturationLevel > 0.0F)
        {
            this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
        }
        else if (enumdifficulty != EnumDifficulty.PEACEFUL)
        {
            this.foodLevel = Math.max(this.foodLevel - 1, 0);
        }
    }

    boolean flag = player.worldObj.getGameRules().getBoolean("naturalRegeneration");

    if (flag && this.foodSaturationLevel > 0.0F && player.shouldHeal() && this.foodLevel >= 20)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 10)
        {
            float f = Math.min(this.foodSaturationLevel, 4.0F);
            player.heal(f / 4.0F);
            this.addExhaustion(f);
            this.foodTimer = 0;
        }
    }
    else if (flag && this.foodLevel >= 18 && player.shouldHeal())
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            player.heal(1.0F);
            this.addExhaustion(4.0F);
            this.foodTimer = 0;
        }
    }
    else if (this.foodLevel <= 0)
    {
        ++this.foodTimer;

        if (this.foodTimer >= 80)
        {
            if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
            {
                player.attackEntityFrom(DamageSource.starve, 1.0F);
            }

            this.foodTimer = 0;
        }
    }
    else
    {
        this.foodTimer = 0;
    }
}