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

The following examples show how to use net.minecraft.entity.EntityLivingBase#getMaxHealth() . 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: GokiStats   File: StatReaper.java    License: MIT License 5 votes vote down vote up
@Override
public boolean isEffectiveOn(Object... obj) {
    if (obj[0] != null) {
        if (!(obj[0] instanceof EntityPlayer)) {
            if ((obj[0] instanceof EntityLivingBase)) {
                EntityLivingBase target = (EntityLivingBase) obj[0];

                return target.getMaxHealth() <= GokiConfig.support.reaperLimit;
            }
        }
    }
    return false;
}
 
Example 3
@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 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
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 6
@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
Source Project: ForgeHax   File: ESP.java    License: MIT License 4 votes vote down vote up
@Override
public double draw(
  SurfaceBuilder builder,
  EntityLivingBase living,
  double topX,
  double topY,
  double botX,
  double botY,
  double width,
  double height) {
  float hp =
    MathHelper.clamp(living.getHealth(), 0, living.getMaxHealth()) / living.getMaxHealth();
  double x = topX - (HEALTHBAR_WIDTH / 2);
  double y = topY - HEALTHBAR_HEIGHT - 2;
  int color =
    (living.getHealth() + living.getAbsorptionAmount() > living.getMaxHealth())
      ? Colors.YELLOW.toBuffer()
      : Color.of(
        (int) ((255 - hp) * 255),
        (int) (255 * hp),
        0,
        255).toBuffer(); // if above 20 hp bar is yellow
  
  builder
    .reset() // clean up from previous uses
    .push()
    .task(SurfaceBuilder::enableBlend)
    .task(SurfaceBuilder::disableTexture2D)
    .beginQuads()
    .color(Colors.BLACK.toBuffer())
    .rectangle(x, y, HEALTHBAR_WIDTH, HEALTHBAR_HEIGHT)
    .end()
    .reset()
    .beginQuads()
    .color(color)
    .rectangle(
      x + 1.D, y + 1.D, ((double) HEALTHBAR_WIDTH - 2.D) * hp, HEALTHBAR_HEIGHT - 2.D)
    .end()
    .task(SurfaceBuilder::disableBlend)
    .task(SurfaceBuilder::enableTexture2D)
    .pop();
  
  return HEALTHBAR_HEIGHT + 1.D;
}