protected void renderHealthMount(int width, int height) { EntityPlayer player = (EntityPlayer) mc.getRenderViewEntity(); Entity tmp = player.ridingEntity; if (!(tmp instanceof EntityLivingBase)) return; bind(icons); if (pre(HEALTHMOUNT)) return; boolean unused = false; int left_align = width / 2 + 91; mc.mcProfiler.endStartSection("mountHealth"); GlStateManager.enableBlend(); EntityLivingBase mount = (EntityLivingBase) tmp; int health = (int) Math.ceil((double) mount.getHealth()); float healthMax = mount.getMaxHealth(); int hearts = (int) (healthMax + 0.5F) / 2; if (hearts > 30) hearts = 30; final int MARGIN = 52; final int BACKGROUND = MARGIN + (unused ? 1 : 0); final int HALF = MARGIN + 45; final int FULL = MARGIN + 36; for (int heart = 0; hearts > 0; heart += 20) { int top = height - right_height; int rowCount = Math.min(hearts, 10); hearts -= rowCount; for (int i = 0; i < rowCount; ++i) { int x = left_align - i * 8 - 9; drawTexturedModalRect(x, top, BACKGROUND, 9, 9, 9); if (i * 2 + 1 + heart < health) drawTexturedModalRect(x, top, FULL, 9, 9, 9); else if (i * 2 + 1 + heart == health) drawTexturedModalRect(x, top, HALF, 9, 9, 9); } right_height += 10; } GlStateManager.disableBlend(); post(HEALTHMOUNT); }
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); }