Java Code Examples for net.minecraft.entity.ai.attributes.IAttributeInstance#getBaseValue()

The following examples show how to use net.minecraft.entity.ai.attributes.IAttributeInstance#getBaseValue() . 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: DebugUtil.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlayerTickClient(PlayerTickEvent evt) {
  if (evt.side != Side.CLIENT || evt.phase != Phase.END) {
    return;
  }
  RayTraceResult mo = Minecraft.getMinecraft().objectMouseOver;
  if (mo != null && mo.entityHit != null && mo.entityHit instanceof EntityLivingBase) {
    EntityLivingBase el = (EntityLivingBase) mo.entityHit;
    if (el != lastMouseOver) {
      double baseAttack = 0;
      double attack = 0;
      IAttributeInstance damAtt = el.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE);
      if (damAtt != null) {
        baseAttack = damAtt.getBaseValue();
        attack = damAtt.getAttributeValue();
      }
      System.out.println("DebugUtil.onPlayerTickClient: Health: " + el.getMaxHealth() + " Base Damage: " + baseAttack + " Damage: " + attack);
    }
    lastMouseOver = el;
  } else {
    lastMouseOver = null;
  }

}
 
Example 2
Source File: MobSpawnEventHandler.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
protected void addjustBaseHealth(EntityLivingBase ent, double healthModifier) {
  IAttributeInstance att = ent.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH);
  if (att == null) {
    return;
  }
  double curValue = att.getBaseValue();
  // only change in incs of 2 so we dont have 1/2 hearts
  double newValue = (curValue * healthModifier) / 2;
  if (healthModifier >= 1) {
    newValue = Math.ceil(newValue);
  } else {
    newValue = Math.floor(newValue);
  }
  newValue = Math.floor(newValue * 2.0);
  if (newValue < 2) {
    newValue = curValue;
  }
  att.setBaseValue(newValue);
  ent.setHealth((float) newValue);
  // System.out.println("MobSpawnEventHandler.addjustBaseHealth: Base health
  // changed from: " + curValue + " to " + newValue);
}
 
Example 3
Source File: MobSpawnEventHandler.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
protected void adjustBaseAttack(EntityLivingBase ent, double attackModifier) {
  IAttributeInstance att = ent.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ATTACK_DAMAGE);
  if (att == null) {
    return;
  }
  double curValue = att.getBaseValue();
  double newValue = curValue * attackModifier;
  att.setBaseValue(newValue);
  // System.out.println("MobSpawnEventHandler.adjustBaseAttack: base attack
  // changed from " + curValue + " to " + newValue);
}