/** (abstract) Protected helper method to read subclass entity data from NBT. */
  public void readEntityFromNBT(NBTTagCompound tagCompund) {
    super.readEntityFromNBT(tagCompund);
    this.setEatingHaystack(tagCompund.getBoolean("EatingHaystack"));
    this.func_110242_l(tagCompund.getBoolean("Bred"));
    this.setChested(tagCompund.getBoolean("ChestedHorse"));
    this.setHasReproduced(tagCompund.getBoolean("HasReproduced"));
    this.setHorseType(tagCompund.getInteger("Type"));
    this.setHorseVariant(tagCompund.getInteger("Variant"));
    this.setTemper(tagCompund.getInteger("Temper"));
    this.setHorseTamed(tagCompund.getBoolean("Tame"));

    if (tagCompund.hasKey("OwnerUUID", 8)) {
      this.func_152120_b(tagCompund.getString("OwnerUUID"));
    }

    IAttributeInstance iattributeinstance =
        this.getAttributeMap().getAttributeInstanceByName("Speed");

    if (iattributeinstance != null) {
      this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
          .setBaseValue(iattributeinstance.getBaseValue() * 0.25D);
    }

    if (this.isChested()) {
      NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
      this.func_110226_cD();

      for (int i = 0; i < nbttaglist.tagCount(); ++i) {
        NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
        int j = nbttagcompound1.getByte("Slot") & 255;

        if (j >= 2 && j < this.horseChest.getSizeInventory()) {
          this.horseChest.setInventorySlotContents(
              j, ItemStack.loadItemStackFromNBT(nbttagcompound1));
        }
      }
    }

    ItemStack itemstack;

    if (tagCompund.hasKey("ArmorItem", 10)) {
      itemstack = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("ArmorItem"));

      if (itemstack != null && func_146085_a(itemstack.getItem())) {
        this.horseChest.setInventorySlotContents(1, itemstack);
      }
    }

    if (tagCompund.hasKey("SaddleItem", 10)) {
      itemstack = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("SaddleItem"));

      if (itemstack != null && itemstack.getItem() == Items.saddle) {
        this.horseChest.setInventorySlotContents(0, itemstack);
      }
    } else if (tagCompund.getBoolean("Saddle")) {
      this.horseChest.setInventorySlotContents(0, new ItemStack(Items.saddle));
    }

    this.func_110232_cE();
  }
Exemplo n.º 2
0
  protected void updateAITasks() {
    IAttributeInstance iattributeinstance =
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);

    if (this.isAngry()) {
      if (!this.isChild() && !iattributeinstance.hasModifier(ATTACK_SPEED_BOOST_MODIFIER)) {
        iattributeinstance.applyModifier(ATTACK_SPEED_BOOST_MODIFIER);
      }

      --this.angerLevel;
    } else if (iattributeinstance.hasModifier(ATTACK_SPEED_BOOST_MODIFIER)) {
      iattributeinstance.removeModifier(ATTACK_SPEED_BOOST_MODIFIER);
    }

    if (this.randomSoundDelay > 0 && --this.randomSoundDelay == 0) {
      this.playSound(
          "mob.zombiepig.zpigangry",
          this.getSoundVolume() * 2.0F,
          ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 1.8F);
    }

    if (this.angerLevel > 0 && this.angerTargetUUID != null && this.getAITarget() == null) {
      EntityPlayer entityplayer = this.worldObj.getPlayerEntityByUUID(this.angerTargetUUID);
      this.setRevengeTarget(entityplayer);
      this.attackingPlayer = entityplayer;
      this.recentlyHit = this.getRevengeTimer();
    }

    super.updateAITasks();
  }
 @Override
 /**
  * Resets the task
  */
 public void resetTask()
 {
     this.field_179448_g = null;
     this.field_179449_j.setScreaming(false);
     IAttributeInstance iattributeinstance = this.field_179449_j.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
     iattributeinstance.removeModifier(EntityChaoticEnderman.attackingSpeedBoostModifier);
     super.resetTask();
 }
Exemplo n.º 4
0
 protected void applyEntityAttributes() {
   super.applyEntityAttributes();
   getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
   getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D);
   getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(20.0D);
   getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(300.0D);
   if ((this.worldObj != null) && (!this.worldObj.isRemote)) {
     IAttributeInstance iattributeinstance =
         getEntityAttribute(SharedMonsterAttributes.movementSpeed);
     iattributeinstance.applyModifier(babySpeedBoostModifier);
   }
 }
Exemplo n.º 5
0
  public void removeAttributesModifiersFromEntity(
      EntityLivingBase p_111187_1_, BaseAttributeMap p_111187_2_, int p_111187_3_) {
    Iterator var4 = this.attributeModifierMap.entrySet().iterator();

    while (var4.hasNext()) {
      Entry var5 = (Entry) var4.next();
      IAttributeInstance var6 = p_111187_2_.getAttributeInstance((IAttribute) var5.getKey());

      if (var6 != null) {
        var6.removeModifier((AttributeModifier) var5.getValue());
      }
    }
  }
Exemplo n.º 6
0
  public void l(boolean flag0) {
    this.H().b(12, Byte.valueOf((byte) (flag0 ? 1 : 0)));
    if (this.o != null && !this.o.D) {
      IAttributeInstance iattributeinstance = this.a(SharedMonsterAttributes.d);

      iattributeinstance.c(bk);
      if (flag0) {
        iattributeinstance.b(bk);
      }
    }

    this.n(flag0);
  }
  /** Set whether this zombie is a child. */
  public void setChild(boolean par1) {
    this.getDataWatcher().updateObject(12, Byte.valueOf((byte) (par1 ? 1 : 0)));

    if (this.worldObj != null && !this.worldObj.isRemote) {
      IAttributeInstance iattributeinstance =
          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
      iattributeinstance.removeModifier(babySpeedBoostModifier);

      if (par1) {
        iattributeinstance.applyModifier(babySpeedBoostModifier);
      }
    }

    this.func_146071_k(par1);
  }
        @Override
        /**
         * Updates the task
         */
        public void updateTask()
        {
            if (this.field_179448_g != null)
            {
                if (--this.field_179450_h <= 0)
                {
                    this.targetEntity = this.field_179448_g;
                    this.field_179448_g = null;
                    super.startExecuting();
                    this.field_179449_j.playSound("mob.endermen.stare", 1.0F, 1.0F);
                    this.field_179449_j.setScreaming(true);
                    IAttributeInstance iattributeinstance = this.field_179449_j.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
                    iattributeinstance.applyModifier(EntityChaoticEnderman.attackingSpeedBoostModifier);
                }
            }
            else
            {
                if (this.targetEntity != null)
                {
                	this.targetEntity.addPotionEffect(new PotionEffect(9, 10, 1));
                    if (this.targetEntity instanceof EntityPlayer && this.field_179449_j.shouldAttackPlayer((EntityPlayer)this.targetEntity))
                    {
                        if (this.targetEntity.getDistanceSqToEntity(this.field_179449_j) < 16.0D)
                        {
                            this.field_179449_j.teleportRandomly();
                        }

                        this.field_179451_i = 0;
                    }
                    else if (this.targetEntity.getDistanceSqToEntity(this.field_179449_j) > 256.0D && this.field_179451_i++ >= 30 && this.field_179449_j.teleportToEntity(this.targetEntity))
                    {
                        this.field_179451_i = 0;
                    }
                }

                super.updateTask();
            }
        }
Exemplo n.º 9
0
  public void applyAttributesModifiersToEntity(
      EntityLivingBase p_111185_1_, BaseAttributeMap p_111185_2_, int p_111185_3_) {
    Iterator var4 = this.attributeModifierMap.entrySet().iterator();

    while (var4.hasNext()) {
      Entry var5 = (Entry) var4.next();
      IAttributeInstance var6 = p_111185_2_.getAttributeInstance((IAttribute) var5.getKey());

      if (var6 != null) {
        AttributeModifier var7 = (AttributeModifier) var5.getValue();
        var6.removeModifier(var7);
        var6.applyModifier(
            new AttributeModifier(
                var7.getID(),
                this.getName() + " " + p_111185_3_,
                this.func_111183_a(p_111185_3_, var7),
                var7.getOperation()));
      }
    }
  }
Exemplo n.º 10
0
 @Override
 public boolean onItemUse(
     ItemStack par1ItemStack,
     EntityPlayer par2EntityPlayer,
     World par3World,
     int par4,
     int par5,
     int par6,
     int par7,
     float par8,
     float par9,
     float par10) {
   EntityPlayer player = par2EntityPlayer;
   ExtendedPlayer props = ExtendedPlayer.get(player);
   if (!player.capabilities.isCreativeMode) {
     float maxHealth = player.getMaxHealth();
     IAttributeInstance attrMaxHealth =
         player.getEntityAttribute(SharedMonsterAttributes.maxHealth);
     if (attrMaxHealth.getAttributeValue() < dblMaxHealthLimit
         && props.getMaxHealth() < dblMaxHealthLimit) {
       maxHealth += healthIncreaseAmount;
       player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
       player.setHealth(maxHealth);
       props.setMaxHealth(maxHealth);
       par1ItemStack.damageItem(2, par2EntityPlayer);
       if (!player.worldObj.isRemote) {
         ZollernHelper.addChatMessage(
             player,
             EnumChatFormatting.GOLD
                 + "+"
                 + this.healthIncreaseAmount
                 + " Max Health! Total: "
                 + props.getMaxHealth());
       }
     } else {
       ZollernHelper.addChatMessage(player, "Max health cannot exceed " + dblMaxHealthLimit + ".");
     }
   }
   return true;
 }
Exemplo n.º 11
0
  private void updateEntityAttributes() {
    this.abilityThreshold = calculateAbilityThreshold();

    IAttributeInstance moveSpeed = getEntityAttribute(SharedMonsterAttributes.movementSpeed);
    IAttributeInstance maxHealth = getEntityAttribute(SharedMonsterAttributes.maxHealth);

    // Only set the base value if it's not equal to what we expect.
    if (moveSpeed.getBaseValue() != getMovementSpeed()) {
      moveSpeed.setBaseValue(getMovementSpeed());
    }

    if (maxHealth.getBaseValue() != getMaximumHealth()) {
      maxHealth.setBaseValue(getMaximumHealth());
      setHealth(getMaximumHealth());
    }
  }
Exemplo n.º 12
0
  public void recalculateHealth(EntityPlayer player, TPlayerStats stats) {
    Side side = FMLCommonHandler.instance().getEffectiveSide();

    if (inventory[4] != null || inventory[5] != null || inventory[6] != null) {
      int bonusHP = 0;
      for (int i = 4; i < 7; i++) {
        ItemStack stack = inventory[i];
        if (stack != null && stack.getItem() instanceof IHealthAccessory) {
          bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
        }
      }
      int prevHealth = stats.bonusHealth;
      stats.bonusHealth = bonusHP;

      int healthChange = bonusHP - prevHealth;
      if (healthChange != 0) {
        IAttributeInstance attributeinstance =
            player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
        try {
          attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
        } catch (Exception e) {
        }
        attributeinstance.applyModifier(
            new AttributeModifier(globalID, "tconstruct.heartCanister", bonusHP, 0));
      }
    } else if (parent != null && parent.get() != null) {
      int prevHealth = stats.bonusHealth;
      int bonusHP = 0;
      stats.bonusHealth = bonusHP;
      int healthChange = bonusHP - prevHealth;
      if (healthChange != 0) {
        IAttributeInstance attributeinstance =
            player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth);
        try {
          attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
        } catch (Exception e) {
        }
      }
    }
  }
Exemplo n.º 13
0
  public void onLivingUpdate() {
    if (!this.onGround && this.motionY < 0.0D) {
      this.motionY *= 0.8D;
    }

    for (int var5 = 0; var5 < 2; ++var5) {
      // "witchMagic"
      this.worldObj.spawnParticle(
          EnumParticleTypes.SPELL_WITCH,
          this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width,
          this.posY + this.rand.nextDouble() * (double) this.height,
          this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width,
          0.0D,
          0.0D,
          0.0D);
    }

    EntitySpider mob;
    if (this.getHealth() < EntityAttributes.maxHealth2 * 0.75F
        && this.getHealth() > 0.0F
        && this.spawn == 0
        && !this.worldObj.isRemote) {
      mob = new EntitySpider(this.worldObj);
      mob.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
      // mob.onSpawnWithEgg((IEntityLivingData)null);
      mob.onInitialSpawn(
          this.worldObj.getDifficultyForLocation(new BlockPos(mob)), (IEntityLivingData) null);
      this.worldObj.spawnEntityInWorld(mob);
      this.spawn = 1;
    }

    if (this.getHealth() < EntityAttributes.maxHealth2 * 0.25F
        && this.getHealth() > 0.0F
        && this.spawn == 1
        && !this.worldObj.isRemote) {
      mob = new EntitySpider(this.worldObj);
      mob.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
      // mob.onSpawnWithEgg((IEntityLivingData)null);
      mob.onInitialSpawn(
          this.worldObj.getDifficultyForLocation(new BlockPos(mob)), (IEntityLivingData) null);
      this.worldObj.spawnEntityInWorld(mob);
      this.spawn = 2;
    }

    if (!this.worldObj.isRemote) {
      if (this.getAggressive()) {
        if (this.witchAttackTimer-- <= 0) {
          this.setAggressive(false);
          ItemStack var6 = this.getHeldItem();
          this.setCurrentItemOrArmor(0, (ItemStack) null);
          if (var6 != null && var6.getItem() == Items.potionitem) {
            List var2 = Items.potionitem.getEffects(var6);
            if (var2 != null) {
              Iterator var3 = var2.iterator();

              while (var3.hasNext()) {
                PotionEffect var4 = (PotionEffect) var3.next();
                this.addPotionEffect(new PotionEffect(var4));
              }
            }
          }

          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
              .removeModifier(field_110185_bq);
        }
      } else {
        short var7 = -1;
        if (this.rand.nextFloat() < 0.15F
            && this.isInsideOfMaterial(Material.water)
            && !this.isPotionActive(Potion.waterBreathing)) {
          var7 = 8237;
        } else if (this.rand.nextFloat() < 0.15F
            && this.isBurning()
            && !this.isPotionActive(Potion.fireResistance)) {
          var7 = 16307;
        } else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) {
          var7 = 16341;
        } else if (this.rand.nextFloat() < 0.25F
            && this.getAttackTarget() != null
            && !this.isPotionActive(Potion.moveSpeed)
            && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D) {
          var7 = 16274;
        } else if (this.rand.nextFloat() < 0.25F
            && this.getAttackTarget() != null
            && !this.isPotionActive(Potion.moveSpeed)
            && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D) {
          var7 = 16274;
        }

        if (var7 > -1) {
          this.setCurrentItemOrArmor(0, new ItemStack(Items.potionitem, 1, var7));
          this.witchAttackTimer = this.getHeldItem().getMaxItemUseDuration();
          this.setAggressive(true);
          IAttributeInstance iattributeinstance =
              this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
          iattributeinstance.removeModifier(field_110185_bq);
          iattributeinstance.applyModifier(field_110185_bq);
        }
      }

      if (this.rand.nextFloat() < 7.5E-4F) {
        this.worldObj.setEntityState(this, (byte) 15);
      }
    }

    super.onLivingUpdate();
  }
Exemplo n.º 14
0
  public void renderHealth(int width, int height) {
    bind(icons);
    if (pre(HEALTH)) return;
    mc.mcProfiler.startSection("health");
    GlStateManager.enableBlend();

    EntityPlayer player = (EntityPlayer) this.mc.getRenderViewEntity();
    int health = MathHelper.ceiling_float_int(player.getHealth());
    boolean highlight =
        healthUpdateCounter > (long) updateCounter
            && (healthUpdateCounter - (long) updateCounter) / 3L % 2L == 1L;

    if (health < this.playerHealth && player.hurtResistantTime > 0) {
      this.lastSystemTime = Minecraft.getSystemTime();
      this.healthUpdateCounter = (long) (this.updateCounter + 20);
    } else if (health > this.playerHealth && player.hurtResistantTime > 0) {
      this.lastSystemTime = Minecraft.getSystemTime();
      this.healthUpdateCounter = (long) (this.updateCounter + 10);
    }

    if (Minecraft.getSystemTime() - this.lastSystemTime > 1000L) {
      this.playerHealth = health;
      this.lastPlayerHealth = health;
      this.lastSystemTime = Minecraft.getSystemTime();
    }

    this.playerHealth = health;
    int healthLast = this.lastPlayerHealth;

    IAttributeInstance attrMaxHealth = player.getEntityAttribute(SharedMonsterAttributes.maxHealth);
    float healthMax = (float) attrMaxHealth.getAttributeValue();
    float absorb = player.getAbsorptionAmount();

    int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F);
    int rowHeight = Math.max(10 - (healthRows - 2), 3);

    this.rand.setSeed((long) (updateCounter * 312871));

    int left = width / 2 - 91;
    int top = height - left_height;
    left_height += (healthRows * rowHeight);
    if (rowHeight != 10) left_height += 10 - rowHeight;

    int regen = -1;
    if (player.isPotionActive(Potion.regeneration)) {
      regen = updateCounter % 25;
    }

    final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0);
    final int BACKGROUND = (highlight ? 25 : 16);
    int MARGIN = 16;
    if (player.isPotionActive(Potion.poison)) MARGIN += 36;
    else if (player.isPotionActive(Potion.wither)) MARGIN += 72;
    float absorbRemaining = absorb;

    for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) {
      // int b0 = (highlight ? 1 : 0);
      int row = MathHelper.ceiling_float_int((float) (i + 1) / 10.0F) - 1;
      int x = left + i % 10 * 8;
      int y = top - row * rowHeight;

      if (health <= 4) y += rand.nextInt(2);
      if (i == regen) y -= 2;

      drawTexturedModalRect(x, y, BACKGROUND, TOP, 9, 9);

      if (highlight) {
        if (i * 2 + 1 < healthLast) drawTexturedModalRect(x, y, MARGIN + 54, TOP, 9, 9); // 6
        else if (i * 2 + 1 == healthLast) drawTexturedModalRect(x, y, MARGIN + 63, TOP, 9, 9); // 7
      }

      if (absorbRemaining > 0.0F) {
        if (absorbRemaining == absorb && absorb % 2.0F == 1.0F)
          drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9); // 17
        else drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9); // 16
        absorbRemaining -= 2.0F;
      } else {
        if (i * 2 + 1 < health) drawTexturedModalRect(x, y, MARGIN + 36, TOP, 9, 9); // 4
        else if (i * 2 + 1 == health) drawTexturedModalRect(x, y, MARGIN + 45, TOP, 9, 9); // 5
      }
    }

    GlStateManager.disableBlend();
    mc.mcProfiler.endSection();
    post(HEALTH);
  }
Exemplo n.º 15
0
 public static float getMcBonusDmg(EntityLivingBase entity) {
   IAttributeInstance attackDamage =
       entity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
   return (float) Math.max(attackDamage.getAttributeValue() - attackDamage.getBaseValue(), 0);
 }
Exemplo n.º 16
0
 public static float getAttackCooldown(EntityLivingBase entity) {
   IAttributeInstance attr = entity.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED);
   double val = null != attr ? attr.getAttributeValue() : 4;
   return (float) (1 / val * 20);
 }
  /* HUD */
  @SubscribeEvent
  public void renderHealthbar(RenderGameOverlayEvent.Pre event) {
    if (!Loader.isModLoaded("tukmc_Vz")) // Loader check to avoid conflicting
    // with a GUI mod (thanks Vazkii!)
    {
      if (event.type == ElementType.HEALTH) {
        updateCounter++;

        ScaledResolution scaledresolution =
            new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
        int scaledWidth = scaledresolution.getScaledWidth();
        int scaledHeight = scaledresolution.getScaledHeight();
        int xBasePos = scaledWidth / 2 - 91;
        int yBasePos = scaledHeight - 39;

        boolean highlight = mc.thePlayer.hurtResistantTime / 3 % 2 == 1;

        if (mc.thePlayer.hurtResistantTime < 10) {
          highlight = false;
        }

        IAttributeInstance attrMaxHealth =
            this.mc.thePlayer.getEntityAttribute(SharedMonsterAttributes.maxHealth);
        int health = MathHelper.ceiling_float_int(mc.thePlayer.getHealth());
        int healthLast = MathHelper.ceiling_float_int(mc.thePlayer.prevHealth);
        float healthMax = (float) attrMaxHealth.getAttributeValue();
        if (healthMax > 20) healthMax = 20;
        float absorb = this.mc.thePlayer.getAbsorptionAmount();

        int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F);
        int rowHeight = Math.max(10 - (healthRows - 2), 3);

        this.rand.setSeed((long) (updateCounter * 312871));

        int left = scaledWidth / 2 - 91;
        int top = scaledHeight - GuiIngameForge.left_height;

        int regen = -1;
        if (mc.thePlayer.isPotionActive(Potion.regeneration)) {
          regen = updateCounter % 25;
        }

        final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0);
        final int BACKGROUND = (highlight ? 25 : 16);
        int MARGIN = 16;
        if (mc.thePlayer.isPotionActive(Potion.poison)) MARGIN += 36;
        else if (mc.thePlayer.isPotionActive(Potion.wither)) MARGIN += 72;
        float absorbRemaining = absorb;

        for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) {
          int b0 = (highlight ? 1 : 0);
          int row = MathHelper.ceiling_float_int((float) (i + 1) / 10.0F) - 1;
          int x = left + i % 10 * 8;
          int y = top - row * rowHeight;

          if (health <= 4) y += rand.nextInt(2);
          if (i == regen) y -= 2;

          drawTexturedModalRect(x, y, BACKGROUND, TOP, 9, 9);

          if (highlight) {
            if (i * 2 + 1 < healthLast) drawTexturedModalRect(x, y, MARGIN + 54, TOP, 9, 9); // 6
            else if (i * 2 + 1 == healthLast)
              drawTexturedModalRect(x, y, MARGIN + 63, TOP, 9, 9); // 7
          }

          if (absorbRemaining > 0.0F) {
            if (absorbRemaining == absorb && absorb % 2.0F == 1.0F)
              drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9); // 17
            else drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9); // 16
            absorbRemaining -= 2.0F;
          } else {
            if (i * 2 + 1 < health) drawTexturedModalRect(x, y, MARGIN + 36, TOP, 9, 9); // 4
            else if (i * 2 + 1 == health) drawTexturedModalRect(x, y, MARGIN + 45, TOP, 9, 9); // 5
          }
        }

        PotionEffect potion = mc.thePlayer.getActivePotionEffect(Potion.wither);
        if (potion != null) return;
        potion = mc.thePlayer.getActivePotionEffect(Potion.poison);
        if (potion != null) return;

        // Extra hearts
        this.mc.getTextureManager().bindTexture(hearts);

        int hp = MathHelper.ceiling_float_int(this.mc.thePlayer.getHealth());
        for (int iter = 0; iter < hp / 20; iter++) {
          int renderHearts = (hp - 20 * (iter + 1)) / 2;
          if (renderHearts > 10) renderHearts = 10;
          for (int i = 0; i < renderHearts; i++) {
            this.drawTexturedModalRect(xBasePos + 8 * i, yBasePos, 0 + 18 * iter, 0, 8, 8);
          }
          if (hp % 2 == 1 && renderHearts < 10) {
            this.drawTexturedModalRect(
                xBasePos + 8 * renderHearts, yBasePos, 9 + 18 * iter, 0, 8, 8);
          }
        }

        this.mc.getTextureManager().bindTexture(icons);
        GuiIngameForge.left_height += 10;
        if (absorb > 0) GuiIngameForge.left_height += 10;

        event.setCanceled(true);
        if (event.type == ElementType.CROSSHAIRS && gs.thirdPersonView != 0) {
          event.setCanceled(true);
        }
      }
    }
  }
Exemplo n.º 18
0
  private void func_180477_d(ScaledResolution p_180477_1_) {
    if (this.mc.func_175606_aa() instanceof EntityPlayer) {
      EntityPlayer var2 = (EntityPlayer) this.mc.func_175606_aa();
      int var3 = MathHelper.ceiling_float_int(var2.getHealth());
      boolean var4 =
          this.field_175191_F > (long) this.updateCounter
              && (this.field_175191_F - (long) this.updateCounter) / 3L % 2L == 1L;

      if (var3 < this.field_175194_C && var2.hurtResistantTime > 0) {
        this.field_175190_E = Minecraft.getSystemTime();
        this.field_175191_F = (long) (this.updateCounter + 20);
      } else if (var3 > this.field_175194_C && var2.hurtResistantTime > 0) {
        this.field_175190_E = Minecraft.getSystemTime();
        this.field_175191_F = (long) (this.updateCounter + 10);
      }

      if (Minecraft.getSystemTime() - this.field_175190_E > 1000L) {
        this.field_175194_C = var3;
        this.field_175189_D = var3;
        this.field_175190_E = Minecraft.getSystemTime();
      }

      this.field_175194_C = var3;
      int var5 = this.field_175189_D;
      this.rand.setSeed((long) (this.updateCounter * 312871));
      boolean var6 = false;
      FoodStats var7 = var2.getFoodStats();
      int var8 = var7.getFoodLevel();
      int var9 = var7.getPrevFoodLevel();
      IAttributeInstance var10 = var2.getEntityAttribute(SharedMonsterAttributes.maxHealth);
      int var11 = p_180477_1_.getScaledWidth() / 2 - 91;
      int var12 = p_180477_1_.getScaledWidth() / 2 + 91;
      int var13 = p_180477_1_.getScaledHeight() - 39;
      float var14 = (float) var10.getAttributeValue();
      float var15 = var2.getAbsorptionAmount();
      int var16 = MathHelper.ceiling_float_int((var14 + var15) / 2.0F / 10.0F);
      int var17 = Math.max(10 - (var16 - 2), 3);
      int var18 = var13 - (var16 - 1) * var17 - 10;
      float var19 = var15;
      int var20 = var2.getTotalArmorValue();
      int var21 = -1;

      if (var2.isPotionActive(Potion.regeneration)) {
        var21 = this.updateCounter % MathHelper.ceiling_float_int(var14 + 5.0F);
      }

      this.mc.mcProfiler.startSection("armor");
      int var22;
      int var23;

      for (var22 = 0; var22 < 10; ++var22) {
        if (var20 > 0) {
          var23 = var11 + var22 * 8;

          if (var22 * 2 + 1 < var20) {
            this.drawTexturedModalRect(var23, var18, 34, 9, 9, 9);
          }

          if (var22 * 2 + 1 == var20) {
            this.drawTexturedModalRect(var23, var18, 25, 9, 9, 9);
          }

          if (var22 * 2 + 1 > var20) {
            this.drawTexturedModalRect(var23, var18, 16, 9, 9, 9);
          }
        }
      }

      this.mc.mcProfiler.endStartSection("health");
      int var25;
      int var26;
      int var27;

      for (var22 = MathHelper.ceiling_float_int((var14 + var15) / 2.0F) - 1; var22 >= 0; --var22) {
        var23 = 16;

        if (var2.isPotionActive(Potion.poison)) {
          var23 += 36;
        } else if (var2.isPotionActive(Potion.wither)) {
          var23 += 72;
        }

        byte var24 = 0;

        if (var4) {
          var24 = 1;
        }

        var25 = MathHelper.ceiling_float_int((float) (var22 + 1) / 10.0F) - 1;
        var26 = var11 + var22 % 10 * 8;
        var27 = var13 - var25 * var17;

        if (var3 <= 4) {
          var27 += this.rand.nextInt(2);
        }

        if (var22 == var21) {
          var27 -= 2;
        }

        byte var28 = 0;

        if (var2.worldObj.getWorldInfo().isHardcoreModeEnabled()) {
          var28 = 5;
        }

        this.drawTexturedModalRect(var26, var27, 16 + var24 * 9, 9 * var28, 9, 9);

        if (var4) {
          if (var22 * 2 + 1 < var5) {
            this.drawTexturedModalRect(var26, var27, var23 + 54, 9 * var28, 9, 9);
          }

          if (var22 * 2 + 1 == var5) {
            this.drawTexturedModalRect(var26, var27, var23 + 63, 9 * var28, 9, 9);
          }
        }

        if (var19 > 0.0F) {
          if (var19 == var15 && var15 % 2.0F == 1.0F) {
            this.drawTexturedModalRect(var26, var27, var23 + 153, 9 * var28, 9, 9);
          } else {
            this.drawTexturedModalRect(var26, var27, var23 + 144, 9 * var28, 9, 9);
          }

          var19 -= 2.0F;
        } else {
          if (var22 * 2 + 1 < var3) {
            this.drawTexturedModalRect(var26, var27, var23 + 36, 9 * var28, 9, 9);
          }

          if (var22 * 2 + 1 == var3) {
            this.drawTexturedModalRect(var26, var27, var23 + 45, 9 * var28, 9, 9);
          }
        }
      }

      Entity var34 = var2.ridingEntity;
      int var36;

      if (var34 == null) {
        this.mc.mcProfiler.endStartSection("food");

        for (var23 = 0; var23 < 10; ++var23) {
          var36 = var13;
          var25 = 16;
          byte var38 = 0;

          if (var2.isPotionActive(Potion.hunger)) {
            var25 += 36;
            var38 = 13;
          }

          if (var2.getFoodStats().getSaturationLevel() <= 0.0F
              && this.updateCounter % (var8 * 3 + 1) == 0) {
            var36 = var13 + (this.rand.nextInt(3) - 1);
          }

          if (var6) {
            var38 = 1;
          }

          var27 = var12 - var23 * 8 - 9;
          this.drawTexturedModalRect(var27, var36, 16 + var38 * 9, 27, 9, 9);

          if (var6) {
            if (var23 * 2 + 1 < var9) {
              this.drawTexturedModalRect(var27, var36, var25 + 54, 27, 9, 9);
            }

            if (var23 * 2 + 1 == var9) {
              this.drawTexturedModalRect(var27, var36, var25 + 63, 27, 9, 9);
            }
          }

          if (var23 * 2 + 1 < var8) {
            this.drawTexturedModalRect(var27, var36, var25 + 36, 27, 9, 9);
          }

          if (var23 * 2 + 1 == var8) {
            this.drawTexturedModalRect(var27, var36, var25 + 45, 27, 9, 9);
          }
        }
      } else if (var34 instanceof EntityLivingBase) {
        this.mc.mcProfiler.endStartSection("mountHealth");
        EntityLivingBase var35 = (EntityLivingBase) var34;
        var36 = (int) Math.ceil((double) var35.getHealth());
        float var37 = var35.getMaxHealth();
        var26 = (int) (var37 + 0.5F) / 2;

        if (var26 > 30) {
          var26 = 30;
        }

        var27 = var13;

        for (int var39 = 0; var26 > 0; var39 += 20) {
          int var29 = Math.min(var26, 10);
          var26 -= var29;

          for (int var30 = 0; var30 < var29; ++var30) {
            byte var31 = 52;
            byte var32 = 0;

            if (var6) {
              var32 = 1;
            }

            int var33 = var12 - var30 * 8 - 9;
            this.drawTexturedModalRect(var33, var27, var31 + var32 * 9, 9, 9, 9);

            if (var30 * 2 + 1 + var39 < var36) {
              this.drawTexturedModalRect(var33, var27, var31 + 36, 9, 9, 9);
            }

            if (var30 * 2 + 1 + var39 == var36) {
              this.drawTexturedModalRect(var33, var27, var31 + 45, 9, 9, 9);
            }
          }

          var27 -= 10;
        }
      }

      this.mc.mcProfiler.endStartSection("air");

      if (var2.isInsideOfMaterial(Material.water)) {
        var23 = this.mc.thePlayer.getAir();
        var36 = MathHelper.ceiling_double_int((double) (var23 - 2) * 10.0D / 300.0D);
        var25 = MathHelper.ceiling_double_int((double) var23 * 10.0D / 300.0D) - var36;

        for (var26 = 0; var26 < var36 + var25; ++var26) {
          if (var26 < var36) {
            this.drawTexturedModalRect(var12 - var26 * 8 - 9, var18, 16, 18, 9, 9);
          } else {
            this.drawTexturedModalRect(var12 - var26 * 8 - 9, var18, 25, 18, 9, 9);
          }
        }
      }

      this.mc.mcProfiler.endSection();
    }
  }