diff --git a/dependencies.gradle b/dependencies.gradle index f08c618..7c9167c 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -71,4 +71,5 @@ dependencies { compileOnly(rfg.deobf("curse.maven:reliquary-reincarnations-241319:2323453")) compileOnly(deobf("https://github.com/Roadhog360/Et-Futurum-Requiem/releases/download/2.5.1/Et_Futurum_Requiem-2.5.1+nomixin.jar", "Et Futurum Requiem")) compileOnly(deobf("https://dl.dropboxusercontent.com/s/c35c42xm0y6pq83/%5B1.7.10%5DDQRmod%20ver0.9.4.8a_%239-i.jar", "DQRespect")) + shadowImplementation("com.github.GTNewHorizons:GTNHLib:0.11.5") } diff --git a/gradle.properties b/gradle.properties index ca6b1ce..62b3f36 100644 --- a/gradle.properties +++ b/gradle.properties @@ -139,7 +139,7 @@ forceEnableMixins = false # If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your # responsibility to check the license and request permission for distribution if required. -usesShadowedDependencies = false +usesShadowedDependencies = true # If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access # their own classes, making the minimization unreliable. diff --git a/src/main/java/com/kuba6000/mobsinfo/nei/ColorUtils.java b/src/main/java/com/kuba6000/mobsinfo/nei/ColorUtils.java new file mode 100644 index 0000000..11417c9 --- /dev/null +++ b/src/main/java/com/kuba6000/mobsinfo/nei/ColorUtils.java @@ -0,0 +1,18 @@ +package com.kuba6000.mobsinfo.nei; + +import com.gtnewhorizon.gtnhlib.color.ColorResource; + +public class ColorUtils { + + private static final ColorResource.Factory color = new ColorResource.Factory("mobsinfo"); + + public static final ColorResource + // spotless:off + + textDefault = color.argb("textDefault", "0xFF555555"), + textDanger = color.argb("textDanger", "0xFFFF0000"), + textBoss = color.argb("textBoss", "0xFFD68F00"), + textPositive = color.argb("textPositive", "0xFF005500"), + slotHighlight = color.argb("slotHighlight", "0x80FFFFFF"); + // spotless:on +} diff --git a/src/main/java/com/kuba6000/mobsinfo/nei/EnumColors.java b/src/main/java/com/kuba6000/mobsinfo/nei/EnumColors.java deleted file mode 100644 index b6bb505..0000000 --- a/src/main/java/com/kuba6000/mobsinfo/nei/EnumColors.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.kuba6000.mobsinfo.nei; - -import java.util.Locale; - -import net.minecraft.util.StatCollector; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -/** - * Enum for UI colors that supports optional resource-pack overrides. - */ -public enum EnumColors { - - TEXT_DEFAULT(0xFF555555), - TEXT_DANGER(0xFFFF0000), - TEXT_BOSS(0xFFD68F00), - TEXT_POSITIVE(0xFF005500), - SLOT_HIGHLIGHT(0x80FFFFFF), - - ; - - private static final Logger LOG = LogManager.getLogger("mobsinfo[EnumColors]"); - private static final String PREFIX = "mobsinfo.color.override."; - private final int defaultColor; - - private String unlocalizedName; - private int cachedColor; - private boolean hasCachedColor = false; - - EnumColors(int defaultColor) { - this.defaultColor = defaultColor; - } - - public int getColor() { - if (!hasCachedColor) { - updateCachedColor(); - } - return cachedColor; - } - - public void updateCachedColor() { - String key = getUnlocalized(); - if (!StatCollector.canTranslate(key)) { - cachedColor = defaultColor; - } else { - cachedColor = parseColor(StatCollector.translateToLocal(key), defaultColor); - } - hasCachedColor = true; - } - - public String getUnlocalized() { - if (unlocalizedName == null) { - unlocalizedName = PREFIX + name().toLowerCase(Locale.ROOT); - } - return unlocalizedName; - } - - private static int parseColor(String raw, int fallback) { - if (raw == null) { - return fallback; - } - - String value = raw.trim(); - if (value.isEmpty()) { - return fallback; - } - - if (value.startsWith("#")) { - value = value.substring(1); - } else if (value.startsWith("0x") || value.startsWith("0X")) { - value = value.substring(2); - } - - try { - return Integer.parseUnsignedInt(value, 16); - } catch (NumberFormatException e) { - LOG.warn("Invalid color override value '{}'", raw); - return fallback; - } - } -} diff --git a/src/main/java/com/kuba6000/mobsinfo/nei/MobHandler.java b/src/main/java/com/kuba6000/mobsinfo/nei/MobHandler.java index 4a0b8aa..e177530 100644 --- a/src/main/java/com/kuba6000/mobsinfo/nei/MobHandler.java +++ b/src/main/java/com/kuba6000/mobsinfo/nei/MobHandler.java @@ -279,7 +279,7 @@ public void drawBackground(int recipe) { GL11.glTranslatef(20.f, 20.f, 0.f); GL11.glScalef(4.f, 4.f, 0.f); - GuiDraw.drawString("?", 0, 0, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString("?", 0, 0, ColorUtils.textDefault.getColor(), false); GL11.glPopMatrix(); return; @@ -446,30 +446,26 @@ public void drawForeground(int recipe) { y, yshift, 168 - x, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false) - yshift; if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips && NEIClientUtils.shiftKey()) - GuiDraw.drawString(currentrecipe.mobname, x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString(currentrecipe.mobname, x, y += yshift, ColorUtils.textDefault.getColor(), false); GuiDraw.drawString( Translations.MOD.get() + currentrecipe.mod, x, y += yshift, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); if (!currentrecipe.isUnlocked()) { x = 6; y = 83; - GuiDraw.drawStringC( - Translations.LOCKED.get(), - 168 / 2, - y += yshift, - EnumColors.TEXT_DEFAULT.getColor(), - false); + GuiDraw + .drawStringC(Translations.LOCKED.get(), 168 / 2, y += yshift, ColorUtils.textDefault.getColor(), false); GuiDraw.drawStringC( Translations.LOCKED_1.get(), 168 / 2, y += yshift, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); return; } @@ -477,7 +473,7 @@ public void drawForeground(int recipe) { Translations.MAX_HEALTH.get() + currentrecipe.maxHealth, x, y += yshift, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); switch (currentrecipe.infernaltype) { case -1: @@ -487,7 +483,7 @@ public void drawForeground(int recipe) { Translations.INFERNAL_CANNOT.get(), x, y += yshift, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); break; case 1: @@ -495,7 +491,7 @@ public void drawForeground(int recipe) { Translations.INFERNAL_CAN.get(), x, y += yshift, - EnumColors.TEXT_DANGER.getColor(), + ColorUtils.textDanger.getColor(), false); break; case 2: @@ -503,7 +499,7 @@ public void drawForeground(int recipe) { Translations.INFERNAL_ALWAYS.get(), x, y += yshift, - EnumColors.TEXT_DANGER.getColor(), + ColorUtils.textDanger.getColor(), false); break; } @@ -512,31 +508,27 @@ public void drawForeground(int recipe) { EnumChatFormatting.BOLD + "" + BOSS.get(), x, y += yshift, - EnumColors.TEXT_BOSS.getColor(), + ColorUtils.textBoss.getColor(), false); - if (currentrecipe.isPeacefulAllowed) GuiDraw.drawString( - Translations.PEACEFUL_ALLOWED.get(), - x, - y += yshift, - EnumColors.TEXT_POSITIVE.getColor(), - false); + if (currentrecipe.isPeacefulAllowed) GuiDraw + .drawString(Translations.PEACEFUL_ALLOWED.get(), x, y += yshift, ColorUtils.textPositive.getColor(), false); if (!currentrecipe.isUsableInVial) GuiDraw - .drawString(Translations.CANNOT_USE_VIAL.get(), x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); + .drawString(Translations.CANNOT_USE_VIAL.get(), x, y += yshift, ColorUtils.textDefault.getColor(), false); if (currentrecipe.spawnList != null && !currentrecipe.spawnList.isEmpty()) { int possiblePlaces = SpawnInfo.getAllKnownInfos() .size(); if (currentrecipe.spawnList.size() >= possiblePlaces && !NEIClientUtils.shiftKey()) { - GuiDraw.drawString(SPAWNS_EVERYWHERE.get(), x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString(SPAWNS_EVERYWHERE.get(), x, y += yshift, ColorUtils.textDefault.getColor(), false); setBiomeSpawnTooltip(false, 0, 0, 0, 0, false, null); } else if (currentrecipe.spawnList.size() < possiblePlaces / 2 || NEIClientUtils.shiftKey()) { GuiDraw.drawString( EnumChatFormatting.UNDERLINE + SPAWNS_IN.get(currentrecipe.spawnList.size()), x, y += yshift, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); setBiomeSpawnTooltip( true, @@ -553,18 +545,18 @@ public void drawForeground(int recipe) { y + yshift, yshift, 168 - x, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); setBiomeSpawnTooltip(true, x, y - yshift, 168 - x, 18, true, currentrecipe.spawnList); } } else { - // GuiDraw.drawString("Doesn't spawn naturally", x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); + // GuiDraw.drawString("Doesn't spawn naturally", x, y += yshift, ColorUtils.textDefault.getColor(), false); setBiomeSpawnTooltip(false, 0, 0, 0, 0, false, null); } if (!currentrecipe.additionalInformation.isEmpty()) { for (String s : currentrecipe.additionalInformation) { - GuiDraw.drawString(s, x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString(s, x, y += yshift, ColorUtils.textDefault.getColor(), false); } } @@ -580,20 +572,19 @@ public void drawForeground(int recipe) { y = itemsYStart; yshift = nextRowYShift; if (currentrecipe.normalOutputsCount > 0) { - GuiDraw.drawString(Translations.NORMAL_DROPS.get(), x, y, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString(Translations.NORMAL_DROPS.get(), x, y, ColorUtils.textDefault.getColor(), false); y += yshift + ((currentrecipe.normalOutputsCount - 1) / itemsPerRow) * 18; } if (currentrecipe.rareOutputsCount > 0) { - GuiDraw.drawString(Translations.RARE_DROPS.get(), x, y, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString(Translations.RARE_DROPS.get(), x, y, ColorUtils.textDefault.getColor(), false); y += yshift + ((currentrecipe.rareOutputsCount - 1) / itemsPerRow) * 18; } if (currentrecipe.additionalOutputsCount > 0) { - GuiDraw - .drawString(Translations.ADDITIONAL_DROPS.get(), x, y, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString(Translations.ADDITIONAL_DROPS.get(), x, y, ColorUtils.textDefault.getColor(), false); y += yshift + ((currentrecipe.additionalOutputsCount - 1) / itemsPerRow) * 18; } if (currentrecipe.infernalOutputsCount > 0) { - GuiDraw.drawString(Translations.INFERNAL_DROPS.get(), x, y, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString(Translations.INFERNAL_DROPS.get(), x, y, ColorUtils.textDefault.getColor(), false); y += yshift + ((currentrecipe.additionalOutputsCount - 1) / itemsPerRow) * 18; } yshift = 10; diff --git a/src/main/java/com/kuba6000/mobsinfo/nei/MobHandlerInfernal.java b/src/main/java/com/kuba6000/mobsinfo/nei/MobHandlerInfernal.java index efe30aa..07639e8 100644 --- a/src/main/java/com/kuba6000/mobsinfo/nei/MobHandlerInfernal.java +++ b/src/main/java/com/kuba6000/mobsinfo/nei/MobHandlerInfernal.java @@ -207,12 +207,12 @@ public void drawBackground(int recipeID) { public void drawForeground(int recipeID) { int y = 0, yshift = 10, x = 7; - GuiDraw.drawString(Translations.TITLE.get(), x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); - GuiDraw.drawString(Translations.FORMAT.get(), x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); - GuiDraw.drawString(Translations.FORMAT_1.get(), x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); - GuiDraw.drawString(Translations.FORMAT_2.get(), x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); - GuiDraw.drawString(Translations.FORMAT_3.get(), x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); - GuiDraw.drawString(Translations.FORMAT_4.get(), x + 20, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); + GuiDraw.drawString(Translations.TITLE.get(), x, y += yshift, ColorUtils.textDefault.getColor(), false); + GuiDraw.drawString(Translations.FORMAT.get(), x, y += yshift, ColorUtils.textDefault.getColor(), false); + GuiDraw.drawString(Translations.FORMAT_1.get(), x, y += yshift, ColorUtils.textDefault.getColor(), false); + GuiDraw.drawString(Translations.FORMAT_2.get(), x, y += yshift, ColorUtils.textDefault.getColor(), false); + GuiDraw.drawString(Translations.FORMAT_3.get(), x, y += yshift, ColorUtils.textDefault.getColor(), false); + GuiDraw.drawString(Translations.FORMAT_4.get(), x + 20, y += yshift, ColorUtils.textDefault.getColor(), false); { x = 6; @@ -223,7 +223,7 @@ public void drawForeground(int recipeID) { Translations.ELITE.get(recipe.eliteChance * 100d, 100d), x, y, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); y += yshift + ((recipe.eliteCount - 1) / itemsPerRow) * 18; } @@ -232,7 +232,7 @@ public void drawForeground(int recipeID) { Translations.ULTRA.get(recipe.ultraChance * recipe.eliteChance * 100d, recipe.ultraChance * 100d), x, y, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); y += yshift + ((recipe.ultraCount - 1) / itemsPerRow) * 18; } @@ -243,7 +243,7 @@ public void drawForeground(int recipeID) { recipe.infernoChance * recipe.ultraChance * 100d), x, y, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); } } diff --git a/src/main/java/com/kuba6000/mobsinfo/nei/VillagerTradesHandler.java b/src/main/java/com/kuba6000/mobsinfo/nei/VillagerTradesHandler.java index 74f6ff8..7fcdc60 100644 --- a/src/main/java/com/kuba6000/mobsinfo/nei/VillagerTradesHandler.java +++ b/src/main/java/com/kuba6000/mobsinfo/nei/VillagerTradesHandler.java @@ -302,11 +302,11 @@ public void drawForeground(int recipe) { NAME.get() + currentRecipe.profession, x, y += yshift, - EnumColors.TEXT_DEFAULT.getColor(), + ColorUtils.textDefault.getColor(), false); if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips && NEIClientUtils.shiftKey()) GuiDraw - .drawString("ID: " + currentRecipe.professionID, x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); - GuiDraw.drawString(MOD.get() + currentRecipe.mod, x, y += yshift, EnumColors.TEXT_DEFAULT.getColor(), false); + .drawString("ID: " + currentRecipe.professionID, x, y += yshift, ColorUtils.textDefault.getColor(), false); + GuiDraw.drawString(MOD.get() + currentRecipe.mod, x, y += yshift, ColorUtils.textDefault.getColor(), false); }