Skip to content

Commit

Permalink
Fixed absorption bar rendering incorrectly and adde3d a config for ab…
Browse files Browse the repository at this point in the history
…sorption bar color
  • Loading branch information
Tfarcenim committed Mar 27, 2019
1 parent ae142a2 commit 90d88ba
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 1.12/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "0.1.1"
version = "0.1.2"
group = "com.tfar.classicbar" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "classicbar"

Expand Down
2 changes: 2 additions & 0 deletions 1.12/src/main/java/tfar/classicbar/config/ModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public static class ConfigColors {
public String oxygenBarColor = "#00E6E6";
@Config.Name("Saturation Bar Color")
public String saturationBarColor = "#FFCC00";
@Config.Name("Absorption Bar Color")
public String absorptionBarColor = "#D4AF37";

public class AdvancedColors {
@Config.Comment("Colors must be specified in #RRGGBB format")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public void forceUpdate() {
@SubscribeEvent(priority = EventPriority.LOW)
public void renderHealthBarMount(RenderGameOverlayEvent.Pre event) {


Entity renderViewEnity = this.mc.getRenderViewEntity();
if (event.getType() != RenderGameOverlayEvent.ElementType.HEALTHMOUNT
|| event.isCanceled()
Expand All @@ -50,19 +49,19 @@ public void renderHealthBarMount(RenderGameOverlayEvent.Pre event) {
int scaledHeight = event.getResolution().getScaledHeight();
//Push to avoid lasting changes
;
event.setCanceled(true);

updateCounter = mc.ingameGUI.getUpdateCounter();

EntityPlayer player = (EntityPlayer) mc.getRenderViewEntity();

if (player.getRidingEntity() == null)return;
if (!(player.getRidingEntity() instanceof EntityLivingBase))return;

EntityLivingBase mount = (EntityLivingBase) player.getRidingEntity();
if (mount.isDead)return;
event.setCanceled(true);
double mountHealth = mount.getHealth();


boolean highlight = healthUpdateCounter > (long) updateCounter && (healthUpdateCounter - (long) updateCounter) / 3L % 2L == 1L;

if (mountHealth < this.mountHealth && player.hurtResistantTime > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public class HealthBarRenderer {
public HealthBarRenderer() {
}

public void forceUpdate() {
forceUpdateIcons = true;
}

@SubscribeEvent//(priority = EventPriority.LOW)
public void renderHealthBar(RenderGameOverlayEvent.Pre event) {
Entity renderViewEntity = this.mc.getRenderViewEntity();
Expand Down Expand Up @@ -103,11 +99,12 @@ public void renderHealthBar(RenderGameOverlayEvent.Pre event) {
else drawTexturedModalRect(xStart, yStart - 10, 0, 0, 81, 9);

int a1 = getStringLength((int)absorb+"");
GlStateManager.color(0.831f, 0.686f, 0.215f, 1);
cU.color2Gl(cU.hex2Color(colors.absorptionBarColor));
drawTexturedModalRect(xStart + 1, yStart - 9, 1, 10, getWidth(absorb, maxHealth), 7);
int a2 = general.displayIcons ? 1 : 0;
int a3 = (int)absorb;
drawStringOnHUD(a3 + "", xStart - a1 - 9 * a2 - 5, yStart - 11, 0xD4AF37, 0);
int c = cU.colorToText(cU.hex2Color(colors.absorptionBarColor));
drawStringOnHUD(a3 + "", xStart - a1 - 9 * a2 - 5, yStart - 11, c, 0);
}
int i1 = getStringLength(h1+"");
int i2 = general.displayIcons ? 1 : 0;
Expand Down Expand Up @@ -147,7 +144,7 @@ public void renderHealthBar(RenderGameOverlayEvent.Pre event) {

private void drawScaledBar(double absorb, double maxHealth, float x, float y) {
int i = getWidth(absorb,maxHealth);
drawTexturedModalRect(x+1, y, 0, 0, i, 9);
drawTexturedModalRect(x+i,y+1,0,1,1,7);
drawTexturedModalRect(x, y, 0, 0, i+1, 9);
drawTexturedModalRect(x+i+1,y+1,0,1,1,7);
}
}

0 comments on commit 90d88ba

Please sign in to comment.