aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-05-16 19:19:38 +1000
committerGitHub <noreply@github.com>2024-05-16 11:19:38 +0200
commit4140b88a2a0b045169f90f392292528aca626d8a (patch)
treebd3bcdb3ab8ab7813cfe17c806e90bdcedf4efb0 /src/main/java
parentd4f7a7753d7ba772add76b43bcf2f692d10f25ad (diff)
downloadskyhanni-4140b88a2a0b045169f90f392292528aca626d8a.tar.gz
skyhanni-4140b88a2a0b045169f90f392292528aca626d8a.tar.bz2
skyhanni-4140b88a2a0b045169f90f392292528aca626d8a.zip
Fix white enchantments (#1798)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/EnchantParsingConfig.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/FontRendererHook.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/MixinPatcherFontRendererHookHook.kt2
6 files changed, 37 insertions, 22 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java
index d3a97bac7..83a45c584 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/chroma/ChromaConfig.java
@@ -10,6 +10,7 @@ import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+import io.github.notenoughupdates.moulconfig.observer.Property;
public class ChromaConfig {
@@ -22,7 +23,7 @@ public class ChromaConfig {
@ConfigOption(name = "Enabled", desc = "Toggle for SkyHanni's chroma. (Disables Patcher's Optimized Font Renderer while enabled)")
@ConfigEditorBoolean
@FeatureToggle
- public boolean enabled = false;
+ public Property<Boolean> enabled = Property.of(false);
@Expose
@ConfigOption(name = "Chroma Size", desc = "Change the size of each color in the chroma.")
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/EnchantParsingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/EnchantParsingConfig.java
index a7571291a..132121c45 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/EnchantParsingConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/EnchantParsingConfig.java
@@ -39,7 +39,8 @@ public class EnchantParsingConfig {
}
@Expose
- @ConfigOption(name = "Perfect Enchantment Color", desc = "The color an enchantment will be at max level.")
+ @ConfigOption(name = "Perfect Enchantment Color", desc = "The color an enchantment will be at max level. " +
+ "§eIf SkyHanni chroma is disabled this will default to §6Gold.")
@ConfigEditorDropdown
public Property<LorenzColor> perfectEnchantColor = Property.of(LorenzColor.CHROMA);
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt
index a44be9824..d010198dd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/Enchant.kt
@@ -1,6 +1,8 @@
package at.hannibal2.skyhanni.features.misc.items.enchants
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.features.chroma.ChromaManager
+import at.hannibal2.skyhanni.utils.LorenzColor
import com.google.gson.annotations.Expose
import java.util.TreeSet
@@ -25,11 +27,18 @@ open class Enchant : Comparable<Enchant> {
open fun getFormat(level: Int): String {
val config = SkyHanniMod.feature.inventory.enchantParsing
+
// TODO change color to string (support for bold)
- if (level >= maxLevel) return config.perfectEnchantColor.get().getChatColor()
- if (level > goodLevel) return config.greatEnchantColor.get().getChatColor()
- if (level == goodLevel) return config.goodEnchantColor.get().getChatColor()
- return config.poorEnchantColor.get().getChatColor()
+ val colour = when {
+ level >= maxLevel -> config.perfectEnchantColor
+ level > goodLevel -> config.greatEnchantColor
+ level == goodLevel -> config.goodEnchantColor
+ else -> config.poorEnchantColor
+ }
+
+ // TODO when chroma is disabled maybe use the neu chroma style instead of gold
+ if (colour.get() == LorenzColor.CHROMA && !(ChromaManager.config.enabled.get() || EnchantParser.isSbaLoaded)) return "§6§l"
+ return colour.get().getChatColor()
}
override fun toString() = "$nbtName $goodLevel $maxLevel\n"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt
index 593e844d4..5c8f9b893 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/enchants/EnchantParser.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.ChatHoverEvent
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.features.chroma.ChromaManager
import at.hannibal2.skyhanni.mixins.hooks.GuiChatHook
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ConditionalUtils
@@ -22,6 +23,7 @@ import net.minecraft.event.HoverEvent
import net.minecraft.item.ItemStack
import net.minecraft.util.ChatComponentText
import net.minecraft.util.IChatComponent
+import net.minecraftforge.fml.common.Loader
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.TreeSet
@@ -58,6 +60,8 @@ object EnchantParser {
private val loreCache: Cache = Cache()
+ val isSbaLoaded by lazy { Loader.isModLoaded("skyblockaddons") }
+
// Maps for all enchants
private var enchants: EnchantsJson = EnchantsJson()
@@ -79,6 +83,7 @@ object EnchantParser {
config.commaFormat,
config.hideVanillaEnchants,
config.hideEnchantDescriptions,
+ ChromaManager.config.enabled,
) {
markCacheDirty()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/FontRendererHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/FontRendererHook.kt
index ccdb69cdb..ad6232646 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/FontRendererHook.kt
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/FontRendererHook.kt
@@ -15,6 +15,8 @@ import net.minecraft.client.renderer.GlStateManager
*/
object FontRendererHook {
+ private val config get() = ChromaManager.config
+
private const val CHROMA_FORMAT_INDEX = 22
private const val WHITE_FORMAT_INDEX = 15
@@ -63,9 +65,8 @@ object FontRendererHook {
@JvmStatic
fun beginChromaRendering(text: String, shadow: Boolean) {
- if (!LorenzUtils.inSkyBlock) return
- if (!ChromaManager.config.enabled) return
- if (ChromaManager.config.allChroma && ChromaManager.config.ignoreChat && cameFromChat) {
+ if (!isEnabled()) return
+ if (config.allChroma && config.ignoreChat && cameFromChat) {
endChromaFont()
return
}
@@ -78,7 +79,7 @@ object FontRendererHook {
currentDrawState = if (shadow) DRAW_CHROMA_SHADOW else DRAW_CHROMA
// Best feature ngl
- if (ChromaManager.config.allChroma) {
+ if (config.allChroma) {
// Handles setting the base color of text when they don't use color codes i.e. MoulConfig
if (shadow) {
GlStateManager.color(0.33f, 0.33f, 0.33f, RenderUtils.getAlpha())
@@ -100,9 +101,7 @@ object FontRendererHook {
@JvmStatic
fun forceWhiteColorCode(formatIndex: Int): Int {
- if (!LorenzUtils.inSkyBlock) return formatIndex
-
- if (!ChromaManager.config.enabled) return formatIndex
+ if (!isEnabled()) return formatIndex
val drawState = currentDrawState ?: return formatIndex
if (drawState.getChromaState() && formatIndex <= WHITE_FORMAT_INDEX) { // If it's a color code
@@ -114,40 +113,40 @@ object FontRendererHook {
@JvmStatic
fun restoreChromaState() {
- if (!LorenzUtils.inSkyBlock) return
- if (!ChromaManager.config.enabled) return
+ if (!isEnabled()) return
currentDrawState?.restoreChromaEnv()
}
@JvmStatic
fun endChromaRendering() {
- if (!LorenzUtils.inSkyBlock) return
- if (!ChromaManager.config.enabled) return
+ if (!isEnabled()) return
if (previewChroma) {
previewChroma = false
endChromaFont()
}
- if (ChromaManager.config.allChroma) endChromaFont()
+ if (config.allChroma) endChromaFont()
currentDrawState?.endChromaEnv()
}
@JvmStatic
fun insertZColorCode(constant: String): String {
- return if (LorenzUtils.inSkyBlock && !ChromaManager.config.enabled) constant else "0123456789abcdefklmnorz"
+ return if (LorenzUtils.inSkyBlock && !isChromaEnabled()) constant else "0123456789abcdefklmnorz"
}
@JvmStatic
fun toggleChromaAndResetStyle(formatIndex: Int): Boolean {
- if (!LorenzUtils.inSkyBlock) return false
- if (!ChromaManager.config.enabled) return false
+ if (!isEnabled()) return false
if (formatIndex == CHROMA_FORMAT_INDEX) {
toggleChromaOn()
return true
}
return false
}
+
+ private fun isChromaEnabled() = config.enabled.get()
+ private fun isEnabled() = LorenzUtils.inSkyBlock && isChromaEnabled()
}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/MixinPatcherFontRendererHookHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/MixinPatcherFontRendererHookHook.kt
index 92e545a44..25d415889 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/MixinPatcherFontRendererHookHook.kt
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/MixinPatcherFontRendererHookHook.kt
@@ -11,7 +11,7 @@ class MixinPatcherFontRendererHookHook {
fun overridePatcherFontRenderer(string: String, shadow: Boolean, cir: CallbackInfoReturnable<Boolean>) {
if (!LorenzUtils.onHypixel) return
- if (ChromaManager.config.enabled) {
+ if (ChromaManager.config.enabled.get()) {
cir.cancel()
cir.returnValue = false
}