Skip to content

Commit

Permalink
Added more Config Options
Browse files Browse the repository at this point in the history
  • Loading branch information
sor1n committed May 19, 2020
1 parent 4a20803 commit 65496c9
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 10 deletions.
44 changes: 44 additions & 0 deletions src/main/java/net/torocraft/torohud/conf/HealthBarGuiConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,50 @@ public enum Skin {NONE, BASIC}
@Name("Show 3D Model of Entity")
public static boolean showEntityModel = true; // config.getBoolean("Show 3D Model of Entity", Configuration.CATEGORY_CLIENT, true, "Shows a 3D model of the entity being targeted");

// Health Config
@Name("Hide Health Number")
@Comment("Hide the health number")
public static boolean hideHealthNo = false;

@Name("Health Number X Offset")
public static int healthNoXOffset = 0;

@Name("Health Number Y Offset")
public static int healthNoYOffset = 0;

@Name("Health Bar X Offset")
public static int healthXOffset = 0;

@Name("Health Bar Y Offset")
public static int healthYOffset = 0;

@Name("Health Bar Scale")
public static float healthScale = 1f;

// Nameplate Config
@Name("Hide Nameplate")
public static boolean hideName = false;

@Name("Nameplate X Offset")
public static int nameXOffset = 0;

@Name("Nameplate Y Offset")
public static int nameYOffset = 0;

@Name("Nameplate Scale")
public static float nameScale = 1f;

// Armor Config
@Name("Hide Armor")
public static boolean hideArmor = false;

@Name("Armor X Offset")
public static int armorXOffset = 0;

@Name("Armor Y Offset")
public static int armorYOffset = 0;

// Overall GUI Config
@Name("Disable GUI")
public static boolean disableGui = false;

Expand Down
38 changes: 28 additions & 10 deletions src/main/java/net/torocraft/torohud/display/BarDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.torocraft.torohud.gui.HealthBars;
import net.torocraft.torohud.conf.HealthBarGuiConf;

public class BarDisplay extends AbstractEntityDisplay implements IDisplay {

Expand Down Expand Up @@ -43,21 +44,38 @@ public void render() {
String health = (int) Math.ceil(entity.getHealth()) + "/" + (int) entity.getMaxHealth();

GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
HealthBars.drawEntityHealthBarInGui(gui, entity, barX, barY);

mc.fontRenderer.drawStringWithShadow(name, barX, y + 2, 16777215);
barX += mc.fontRenderer.getStringWidth(name) + 5;
GlStateManager.pushMatrix();
GlStateManager.scale(HealthBarGuiConf.healthScale, HealthBarGuiConf.healthScale, HealthBarGuiConf.healthScale);
HealthBars.drawEntityHealthBarInGui(gui, entity, barX + HealthBarGuiConf.healthXOffset, barY + HealthBarGuiConf.healthXOffset);
GlStateManager.popMatrix();

if(!HealthBarGuiConf.hideName)
{
GlStateManager.pushMatrix();
GlStateManager.scale(HealthBarGuiConf.nameScale, HealthBarGuiConf.nameScale, HealthBarGuiConf.nameScale);
mc.fontRenderer.drawStringWithShadow(name, barX + HealthBarGuiConf.nameXOffset, y + 2 + HealthBarGuiConf.nameYOffset, 16777215);
GlStateManager.popMatrix();

barX += mc.fontRenderer.getStringWidth(name) + 5 + HealthBarGuiConf.nameXOffset;
}

renderHeartIcon(barX, y + 1);
barX += 10;
if(!HealthBarGuiConf.hideHealthNo)
{
renderHeartIcon(barX + HealthBarGuiConf.healthNoXOffset, y + 1 + HealthBarGuiConf.healthNoYOffset);
barX += 10 + HealthBarGuiConf.healthNoXOffset;

mc.fontRenderer.drawStringWithShadow(health, barX, y + 2, 0xe0e0e0);
barX += mc.fontRenderer.getStringWidth(health) + 5;
mc.fontRenderer.drawStringWithShadow(health, barX, y + 2, 0xe0e0e0);
barX += mc.fontRenderer.getStringWidth(health) + 5;
}

renderArmorIcon(barX, y + 1);
barX += 10;
if(!HealthBarGuiConf.hideArmor)
{
renderArmorIcon(barX + HealthBarGuiConf.armorXOffset, y + 1 + HealthBarGuiConf.armorYOffset);
barX += 10 + HealthBarGuiConf.armorXOffset;

mc.fontRenderer.drawStringWithShadow(entity.getTotalArmorValue() + "", barX, y + 2, 0xe0e0e0);
mc.fontRenderer.drawStringWithShadow(entity.getTotalArmorValue() + "", barX, y + 2, 0xe0e0e0);
}
}

private void renderArmorIcon(int x, int y) {
Expand Down

0 comments on commit 65496c9

Please sign in to comment.