Java Code Examples for net.minecraft.entity.EntityLivingBase#heal()

The following examples show how to use net.minecraft.entity.EntityLivingBase#heal() . 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 check out the related API usage on the sidebar.
Example 1
Source Project: TofuCraftReload   File: ItemTofuForceCore.java    License: MIT License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
    super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);

    if (entityIn instanceof EntityLivingBase) {
        EntityLivingBase entityLivingBase = (EntityLivingBase) entityIn;

        if (entityLivingBase.ticksExisted % 400 == 0 && isUsable(stack)) {
            if (entityLivingBase.getHealth() < entityLivingBase.getMaxHealth()) {
                if (getEnergy(stack) >= 5) {
                    drain(stack, 5, false);

                } else {
                    stack.damageItem(1, (EntityLivingBase) entityIn);
                }
                entityLivingBase.heal(1);
            }
        }
    }
}
 
Example 2
Source Project: TofuCraftReload   File: BlockSoyMilk.java    License: MIT License 6 votes vote down vote up
@Override
public void onEntityCollidedWithBlock(World par1World, BlockPos pos, IBlockState state, Entity par5Entity)
{
    if (!par1World.isRemote)
    {
        int heat = this.getHeatStrength(par1World, pos);
        if (par5Entity instanceof EntityLivingBase)
        {
            EntityLivingBase entityLiving = (EntityLivingBase)par5Entity;
            if (entityLiving.ticksExisted % 20 == 0)
            {
            	switch (heat) {
	case 1:
		entityLiving.heal(1f);
		break;
	case 2:
		entityLiving.attackEntityFrom(DamageSource.ON_FIRE, 1f);
		break;
	default:
		break;
	}
            }
        }
    }
}
 
Example 3
Source Project: TofuCraftReload   File: ItemDiamondTofuSword.java    License: MIT License 5 votes vote down vote up
@Override
public boolean hitEntity(ItemStack itemStack, EntityLivingBase targetEntity, EntityLivingBase attacker)
{
    // Drain
    Float healthBeforeAttack = (float) attacker.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    float damage = healthBeforeAttack - targetEntity.getHealth();
    if (damage > 0.0f)
    {
        int lvl = EnchantmentHelper.getEnchantmentLevel(EnchantmentLoader.Drain, itemStack);
        attacker.heal(damage * (lvl * 0.1f + 0.1f));
    }
    return super.hitEntity(itemStack, targetEntity, attacker);
}
 
Example 4
@Override
public void performEffect(EntityLivingBase target, int par2) {
	if (target instanceof ITaintedMob) {
		target.heal(1);
	} else
	if (!target.isEntityUndead() && !(target instanceof EntityPlayer))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
	else
	if (!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer)))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
}
 
Example 5
@Override
public void performEffect(EntityLivingBase target, int par2) {
	if (target instanceof ITaintedMob) {
		target.heal(1);
	} else
	if (!target.isEntityUndead() && !(target instanceof EntityPlayer))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
	else
	if (!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer)))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
}
 
Example 6
Source Project: GardenCollection   File: PotionFluxTaint.java    License: MIT License 5 votes vote down vote up
@Override
public void performEffect(EntityLivingBase target, int par2) {
	if (target instanceof ITaintedMob) {
		target.heal(1);
	} else
	if (!target.isEntityUndead() && !(target instanceof EntityPlayer))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
	else
	if (!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer)))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
}
 
Example 7
@Override
public void performEffect(EntityLivingBase target, int par2) {
	if (target instanceof ITaintedMob) {
		target.heal(1);
	} else
	if (!target.isEntityUndead() && !(target instanceof EntityPlayer))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
	else
	if (!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer)))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
}
 
Example 8
@Override
public void performEffect(EntityLivingBase target, int par2) {
	if (target instanceof ITaintedMob) {
		target.heal(1);
	} else
	if (!target.isEntityUndead() && !(target instanceof EntityPlayer))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
	else
	if (!target.isEntityUndead() && (target.getMaxHealth() > 1 || (target instanceof EntityPlayer)))
       {
		target.attackEntityFrom(DamageSourceThaumcraft.taint, 1);
       } 
}