diff --git a/src/main/java/net/torocraft/torohud/conf/HealthBarGuiConf.java b/src/main/java/net/torocraft/torohud/conf/HealthBarGuiConf.java new file mode 100644 index 0000000..2429658 --- /dev/null +++ b/src/main/java/net/torocraft/torohud/conf/HealthBarGuiConf.java @@ -0,0 +1,44 @@ +package net.torocraft.torohud.conf; + +import net.minecraftforge.common.config.Config; +import net.minecraftforge.common.config.Config.Comment; +import net.minecraftforge.common.config.Config.Name; +import net.minecraftforge.common.config.Config.RangeInt; +import net.torocraft.torohud.ToroHUD; +import net.torocraft.torohud.conf.ParticlesConf.Color; + +@Config(modid = ToroHUD.MODID, name = ToroHUD.MODID + "/healthBarGui") +@Config.LangKey("healthBarGui.config.title") +public class HealthBarGuiConf { + + public enum GuiAnchor {TOP_LEFT, TOP_CENTER, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT} + + 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"); + + @Name("Disable GUI") + public static boolean disableGui = false; + + @Name("X Offset") + public static int xOffset = 0; + + @Name("Y Offset") + public static int yOffset = 0; + + @Name("GUI Position") + public static GuiAnchor guiPosition = GuiAnchor.TOP_LEFT; + + @Name("Hide Delay") + @Comment("Delays hiding the dialog for the given number of milliseconds") + @RangeInt(min = 50, max = 5000) + public static int hideDelay = 300; + + @Name("Background Skin Selection") + public static Skin skin = Skin.BASIC; + + @Name("Entity Black List") + public static String[] entityBlacklist = {}; + +} diff --git a/src/main/java/net/torocraft/torohud/conf/HealthBarsConf.java b/src/main/java/net/torocraft/torohud/conf/HealthBarsConf.java new file mode 100644 index 0000000..3be418f --- /dev/null +++ b/src/main/java/net/torocraft/torohud/conf/HealthBarsConf.java @@ -0,0 +1,28 @@ +package net.torocraft.torohud.conf; + +import net.minecraftforge.common.config.Config; +import net.minecraftforge.common.config.Config.Comment; +import net.minecraftforge.common.config.Config.Name; +import net.minecraftforge.common.config.Config.RangeInt; +import net.torocraft.torohud.ToroHUD; +import net.torocraft.torohud.conf.ParticlesConf.Color; + +@Config(modid = ToroHUD.MODID, name = ToroHUD.MODID + "/healthBars") +@Config.LangKey("healthBars.config.title") +public class HealthBarsConf { + + public enum Mode {NONE, WHEN_HOLDING_WEAPON, ALWAYS, WHEN_HURT, WHEN_HURT_TEMP} + + public enum NumberType {NONE, LAST, CUMULATIVE} + + @Name("Show Bars Above Entities") + public static Mode showBarsAboveEntities = Mode.WHEN_HOLDING_WEAPON; + + @Name("Damage Number Type") + public static NumberType numberType = NumberType.LAST; + + @Name("Additional Weapons") + @Comment("When using WHEN_HOLDING_WEAPON to show entity bars, more items can be added here to be treated as weapons.") + public static String[] additionalWeaponItems = {}; + +} diff --git a/src/main/java/net/torocraft/torohud/conf/ParticlesConf.java b/src/main/java/net/torocraft/torohud/conf/ParticlesConf.java new file mode 100644 index 0000000..1356b08 --- /dev/null +++ b/src/main/java/net/torocraft/torohud/conf/ParticlesConf.java @@ -0,0 +1,25 @@ +package net.torocraft.torohud.conf; + +import net.minecraftforge.common.config.Config; +import net.minecraftforge.common.config.Config.Name; +import net.torocraft.torohud.ToroHUD; + +@Config(modid = ToroHUD.MODID, name = ToroHUD.MODID + "/particles") +@Config.LangKey("particles.config.title") +public class ParticlesConf { + + public enum Color {RED, GREEN, BLUE, YELLOW, ORANGE, BLACK, PURPLE} + + @Name("Show Damage Particles") + public static boolean showDamageParticles = true; + + @Name("Heal Color") + public static Color healColor = Color.GREEN; + + @Name("Damage Color") + public static Color damageColor = Color.RED; + + @Name("Visible Throw Walls") + public static boolean visibleThroughWalls = false; + +} diff --git a/src/main/java/net/torocraft/torohud/display/EntityDisplay.java b/src/main/java/net/torocraft/torohud/display/EntityDisplay.java index 1de5e3a..cb3bfcf 100644 --- a/src/main/java/net/torocraft/torohud/display/EntityDisplay.java +++ b/src/main/java/net/torocraft/torohud/display/EntityDisplay.java @@ -14,7 +14,6 @@ import net.minecraftforge.common.config.Config.Name; import net.torocraft.torohud.ToroHUD; -@Config(modid = ToroHUD.MODID, name = "Entity Display Settings") public class EntityDisplay implements IDisplay { private static final int RENDER_HEIGHT = 30; @@ -37,9 +36,6 @@ public class EntityDisplay implements IDisplay { private float prevPrevYahHead; private int scale = 1; - @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"); - public EntityDisplay(Minecraft mc) { } diff --git a/src/main/java/net/torocraft/torohud/gui/GuiEntityStatus.java b/src/main/java/net/torocraft/torohud/gui/GuiEntityStatus.java index 7b6c075..1a2e4db 100644 --- a/src/main/java/net/torocraft/torohud/gui/GuiEntityStatus.java +++ b/src/main/java/net/torocraft/torohud/gui/GuiEntityStatus.java @@ -1,7 +1,5 @@ package net.torocraft.torohud.gui; -import java.util.ArrayList; -import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; @@ -10,12 +8,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; -import net.minecraftforge.common.config.Config; -import net.minecraftforge.common.config.Config.Comment; -import net.minecraftforge.common.config.Config.Name; -import net.minecraftforge.common.config.Config.RangeInt; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.torocraft.torohud.ToroHUD; +import net.torocraft.torohud.conf.HealthBarGuiConf; import net.torocraft.torohud.display.BarDisplay; import net.torocraft.torohud.display.EntityDisplay; import net.torocraft.torohud.display.IDisplay; @@ -24,36 +19,6 @@ public class GuiEntityStatus extends Gui { - @Config(modid = ToroHUD.MODID, name = "GUI Settings") - public static class Conf { - public enum GuiAnchor {TOP_LEFT, TOP_CENTER, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT} - public enum Skin {NONE, BASIC} - - @Name("Disable GUI") - public static boolean disableGui = false; - - @Name("X Offset") - public static int xOffset = 0; - - @Name("Y Offset") - public static int yOffset = 0; - - @Name("GUI Position") - public static GuiAnchor guiPosition = GuiAnchor.TOP_LEFT; - - @Name("Hide Delay") - @Comment("Delays hiding the dialog for the given number of milliseconds") - @RangeInt(min = 50, max = 5000) - public static int hideDelay = 300; - - @Name("Background Skin Selection") - public static Skin skin = Skin.BASIC; - - @Name("Entity Black List") - public static String[] entityBlacklist = {}; - - } - private static final int PADDING_FROM_EDGE = 3; private static final ResourceLocation SKIN_BASIC = new ResourceLocation(ToroHUD.MODID, "textures/gui/default_skin_basic.png"); private static final ResourceLocation SKIN_HEAVY = new ResourceLocation(ToroHUD.MODID, "textures/gui/default_skin_heavy.png"); @@ -88,7 +53,7 @@ public GuiEntityStatus(Minecraft mc) { @SubscribeEvent public void drawHealthBar(RenderGameOverlayEvent.Pre event) { - if (Conf.disableGui || !showHealthBar || event.getType() != ElementType.CHAT) { + if (HealthBarGuiConf.disableGui || !showHealthBar || event.getType() != ElementType.CHAT) { return; } updateGuiAge(); @@ -98,7 +63,7 @@ public void drawHealthBar(RenderGameOverlayEvent.Pre event) { } private void drawSkin() { - if (Conf.skin.equals(Conf.Skin.NONE) || !EntityDisplay.showEntityModel) { + if (HealthBarGuiConf.skin.equals(HealthBarGuiConf.Skin.NONE) || !HealthBarGuiConf.showEntityModel) { return; } mc.getTextureManager().bindTexture(SKIN_BASIC); @@ -108,7 +73,7 @@ private void drawSkin() { private void updateGuiAge() { age = age + 15; - if (age > Conf.hideDelay) { + if (age > HealthBarGuiConf.hideDelay) { hideHealthBar(); } } @@ -119,12 +84,13 @@ private void updatePositions() { x = screenX; y = screenY; - if (EntityDisplay.showEntityModel) { + if (HealthBarGuiConf.showEntityModel) { entityDisplay.setPosition(x, y); x += 40; } - if (Conf.guiPosition.equals(Conf.GuiAnchor.BOTTOM_LEFT) || Conf.guiPosition.equals(Conf.GuiAnchor.BOTTOM_RIGHT)) { + if (HealthBarGuiConf.guiPosition.equals(HealthBarGuiConf.GuiAnchor.BOTTOM_LEFT) || HealthBarGuiConf.guiPosition + .equals(HealthBarGuiConf.GuiAnchor.BOTTOM_RIGHT)) { y += 6; } @@ -133,7 +99,7 @@ private void updatePositions() { } private void draw() { - if (EntityDisplay.showEntityModel) { + if (HealthBarGuiConf.showEntityModel) { entityDisplay.draw(); } barDisplay.draw(); @@ -142,7 +108,7 @@ private void draw() { private void adjustForDisplayPositionSetting() { - if (EntityDisplay.showEntityModel) { + if (HealthBarGuiConf.showEntityModel) { displayHeight = 40; displayWidth = 140; } else { @@ -151,7 +117,7 @@ private void adjustForDisplayPositionSetting() { } ScaledResolution viewport = new ScaledResolution(mc); - String displayPosition = Conf.guiPosition.toString(); + String displayPosition = HealthBarGuiConf.guiPosition.toString(); int sh = viewport.getScaledHeight(); int sw = viewport.getScaledWidth(); @@ -176,8 +142,8 @@ private void adjustForDisplayPositionSetting() { screenX = (sw - displayWidth) / 2; } - screenX += Conf.xOffset; - screenY += Conf.yOffset; + screenX += HealthBarGuiConf.xOffset; + screenY += HealthBarGuiConf.yOffset; } private void showHealthBar() { diff --git a/src/main/java/net/torocraft/torohud/gui/HealthBars.java b/src/main/java/net/torocraft/torohud/gui/HealthBars.java index f4c5736..0430916 100644 --- a/src/main/java/net/torocraft/torohud/gui/HealthBars.java +++ b/src/main/java/net/torocraft/torohud/gui/HealthBars.java @@ -26,17 +26,13 @@ import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.common.config.Config; -import net.minecraftforge.common.config.Config.Comment; -import net.minecraftforge.common.config.Config.Name; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; import net.minecraftforge.fml.relauncher.Side; import net.torocraft.torohud.ToroHUD; +import net.torocraft.torohud.conf.HealthBarsConf; import net.torocraft.torohud.display.AbstractEntityDisplay; -import net.torocraft.torohud.gui.HealthBars.Conf.Mode; -import net.torocraft.torohud.gui.HealthBars.Conf.NumberType; import net.torocraft.torohud.util.EntityUtil; import org.apache.commons.lang3.ArrayUtils; import org.lwjgl.opengl.GL11; @@ -71,25 +67,6 @@ public class HealthBars { private static boolean holdingWeapon = false; private static long tickCount = 0; - @Config(modid = ToroHUD.MODID, name = "Health Bar Settings") - public static class Conf { - - public enum Mode {NONE, WHEN_HOLDING_WEAPON, ALWAYS, WHEN_HURT, WHEN_HURT_TEMP} - - public enum NumberType {NONE, LAST, CUMULATIVE} - - @Name("Show Bars Above Entities") - public static Mode showBarsAboveEntities = Mode.WHEN_HOLDING_WEAPON; - - @Name("Damage Number Type") - public static NumberType numberType = NumberType.LAST; - - @Name("Additional Weapons") - @Comment("When using WHEN_HOLDING_WEAPON to show entity bars, more items can be added here to be treated as weapons.") - public static String[] additionalWeaponItems = {}; - - } - @SubscribeEvent public static void onRenderWorldLast(RenderWorldLastEvent event) { if (!barsAreCurrentlyDisabled()) { @@ -103,10 +80,10 @@ public static void onRenderWorldLast(RenderWorldLastEvent event) { } public static boolean barsAreCurrentlyDisabled() { - if (Conf.showBarsAboveEntities.equals(Mode.ALWAYS)) { + if (HealthBarsConf.showBarsAboveEntities.equals(HealthBarsConf.Mode.ALWAYS)) { return false; } - if (Conf.showBarsAboveEntities.equals(Mode.WHEN_HOLDING_WEAPON)) { + if (HealthBarsConf.showBarsAboveEntities.equals(HealthBarsConf.Mode.WHEN_HOLDING_WEAPON)) { return !holdingWeapon; } return false; @@ -139,7 +116,7 @@ public static void cleanup(ClientTickEvent event) { states.entrySet().removeIf(e -> stateExpired(world, e.getKey(), e.getValue())); } - if (Conf.showBarsAboveEntities.equals(Mode.WHEN_HOLDING_WEAPON) && tickCount % 10 == 0) { + if (HealthBarsConf.showBarsAboveEntities.equals(HealthBarsConf.Mode.WHEN_HOLDING_WEAPON) && tickCount % 10 == 0) { updateEquipment(); } @@ -166,7 +143,7 @@ private static boolean isWeapon(ItemStack item) { private static boolean isInWeaponWhiteList(ItemStack item) { String itemName = item.getItem().getUnlocalizedName(); - return ArrayUtils.contains(Conf.additionalWeaponItems, itemName); + return ArrayUtils.contains(HealthBarsConf.additionalWeaponItems, itemName); } private static boolean stateExpired(World world, int id, State state) { @@ -201,7 +178,7 @@ public static void drawEntityHealthBarInWorld(EntityLivingBase entity, float par if (!EntityUtil.whiteListedEntity(entity) || entity == Minecraft.getMinecraft().player) { return; } - if (Conf.showBarsAboveEntities.equals(Mode.WHEN_HURT) && entity.getHealth() >= entity.getMaxHealth()) { + if (HealthBarsConf.showBarsAboveEntities.equals(HealthBarsConf.Mode.WHEN_HURT) && entity.getHealth() >= entity.getMaxHealth()) { return; } double x = entity.lastTickPosX + ((entity.posX - entity.lastTickPosX) * partialTicks); @@ -241,7 +218,7 @@ private static void drawEntityHealthBar(EntityLivingBase entity, double x, doubl state.previousHealthDelay = HEALTH_INDICATOR_DELAY; } - if (Conf.showBarsAboveEntities.equals(Mode.WHEN_HURT_TEMP) && gui == null && state.lastDmg == 0) { + if (HealthBarsConf.showBarsAboveEntities.equals(HealthBarsConf.Mode.WHEN_HURT_TEMP) && gui == null && state.lastDmg == 0) { return; } @@ -256,9 +233,9 @@ private static void drawEntityHealthBar(EntityLivingBase entity, double x, doubl drawBar(gui, x, y, z, 1, DARK_GRAY, zOffset++); drawBar(gui, x, y, z, percent2, color2, zOffset++); drawBar(gui, x, y, z, percent, color, zOffset++); - if (Conf.numberType.equals(NumberType.CUMULATIVE)) { + if (HealthBarsConf.numberType.equals(HealthBarsConf.NumberType.CUMULATIVE)) { drawDamageNumber(state.previousHealth - entity.getHealth(), entity, gui, x, y, z, zOffset); - } else if (Conf.numberType.equals(NumberType.LAST)) { + } else if (HealthBarsConf.numberType.equals(HealthBarsConf.NumberType.LAST)) { drawDamageNumber(state.lastDmg, entity, gui, x, y, z, zOffset); } } diff --git a/src/main/java/net/torocraft/torohud/render/DamageParticle.java b/src/main/java/net/torocraft/torohud/render/DamageParticle.java index 60b8fd4..c702557 100644 --- a/src/main/java/net/torocraft/torohud/render/DamageParticle.java +++ b/src/main/java/net/torocraft/torohud/render/DamageParticle.java @@ -8,11 +8,10 @@ import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import net.minecraftforge.common.config.Config; -import net.minecraftforge.common.config.Config.Name; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import net.torocraft.torohud.ToroHUD; +import net.torocraft.torohud.conf.ParticlesConf; +import net.torocraft.torohud.conf.ParticlesConf.Color; import org.lwjgl.opengl.GL11; @@ -29,24 +28,8 @@ public class DamageParticle extends Particle { protected float scale = 1.0F; private int damage; - @Config(modid = ToroHUD.MODID, name = "Damage Particles") - public static class Conf { - - @Name("Show Damage Particles") - public static boolean showDamageParticles = true; - - @Name("Heal Color") - public static Color healColor = Color.GREEN; - - @Name("Damage Color") - public static Color damageColor = Color.RED; - - @Name("Visible Throw Walls") - public static boolean visibleThroughWalls = false; - } - public static void displayParticle(Entity entity, int damage) { - if (!Conf.showDamageParticles) { + if (!ParticlesConf.showDamageParticles) { return; } if (damage == 0) { @@ -88,7 +71,7 @@ public void renderParticle(final BufferBuilder renderer, final Entity entity, fi final float locZ = ((float) (this.prevPosZ + (this.posZ - this.prevPosZ) * z - interpPosZ)); GL11.glPushMatrix(); - if (Conf.visibleThroughWalls) { + if (ParticlesConf.visibleThroughWalls) { GL11.glDepthFunc(519); } else { GL11.glDepthFunc(515); @@ -114,9 +97,9 @@ public void renderParticle(final BufferBuilder renderer, final Entity entity, fi GL11.glEnable(3008); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - Color color = Conf.damageColor; + Color color = ParticlesConf.damageColor; if (damage < 0) { - color = Conf.healColor; + color = ParticlesConf.healColor; } final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; @@ -141,8 +124,6 @@ public int getFXLayer() { return 3; } - public enum Color {RED, GREEN, BLUE, YELLOW, ORANGE, BLACK, PURPLE} - private static int mapColor(Color color) { switch (color) { case RED: diff --git a/src/main/java/net/torocraft/torohud/util/EntityUtil.java b/src/main/java/net/torocraft/torohud/util/EntityUtil.java index 60005f9..33f32a6 100644 --- a/src/main/java/net/torocraft/torohud/util/EntityUtil.java +++ b/src/main/java/net/torocraft/torohud/util/EntityUtil.java @@ -2,19 +2,19 @@ import net.minecraft.entity.Entity; import net.minecraftforge.fml.common.registry.EntityRegistry; -import net.torocraft.torohud.gui.GuiEntityStatus.Conf; +import net.torocraft.torohud.conf.HealthBarGuiConf; import org.apache.commons.lang3.ArrayUtils; public class EntityUtil { public static boolean whiteListedEntity(Entity entity) { - return !ArrayUtils.contains(Conf.entityBlacklist, getEntityStringId(entity)); + return !ArrayUtils.contains(HealthBarGuiConf.entityBlacklist, getEntityStringId(entity)); } - public static String getEntityStringId (Entity entity) { + public static String getEntityStringId(Entity entity) { try { return EntityRegistry.getEntry(entity.getClass()).getRegistryName().toString(); - }catch (Exception e){ + } catch (Exception e) { return "unknown:unknown"; } } diff --git a/src/main/resources/assets/torohud/lang/en_US.lang b/src/main/resources/assets/torohud/lang/en_US.lang index e69de29..bf06861 100644 --- a/src/main/resources/assets/torohud/lang/en_US.lang +++ b/src/main/resources/assets/torohud/lang/en_US.lang @@ -0,0 +1,3 @@ +healthBarGui.config.title=Health Bar GUI +healthBars.config.title=Entity Heath Bars +particles.config.title=Particles \ No newline at end of file