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

The following examples show how to use net.minecraft.entity.EntityLivingBase#getMaxHealth() . 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: ItemTofuForceCore.java    From TofuCraftReload with 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 File: StatReaper.java    From GokiStats with 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
Source File: PotionFluxTaint.java    From AdvancedMod with GNU General Public License v3.0 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 4
Source File: PotionFluxTaint.java    From Chisel-2 with GNU General Public License v2.0 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 5
Source File: PotionFluxTaint.java    From GardenCollection with 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
Source File: PotionFluxTaint.java    From ForbiddenMagic with Do What The F*ck You Want To Public 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
Source File: PotionFluxTaint.java    From PneumaticCraft with GNU General Public License v3.0 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 8
Source File: ESP.java    From ForgeHax with 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;
}