From d5b4a817e2b9e7e5c88eb0c8212b9a6e678bd92f Mon Sep 17 00:00:00 2001 From: Walker Selby Date: Mon, 11 Dec 2023 13:59:52 -0800 Subject: Internal: Migrate Deprecated Config Values to Enums (#790) Migrate Deprecated Config Values to Enums. #790 --- .../skyhanni/features/chroma/ChromaShader.kt | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/chroma') diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt index 8afd758a7..dfa187c0d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt @@ -1,17 +1,22 @@ package at.hannibal2.skyhanni.features.chroma import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.features.chroma.ChromaConfig.Direction import at.hannibal2.skyhanni.data.MinecraftData import at.hannibal2.skyhanni.mixins.transformers.AccessorMinecraft +import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.shader.Shader import at.hannibal2.skyhanni.utils.shader.Uniform import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent /** * Modified from SkyblockAddons * * Credit: [ChromaShader.java](https://github.com/BiscuitDevelopment/SkyblockAddons/blob/main/src/main/java/codes/biscuit/skyblockaddons/shader/chroma/ChromaShader.java) */ + object ChromaShader : Shader("chroma", "chroma") { val config get() = SkyHanniMod.feature.chroma val INSTANCE: ChromaShader @@ -26,8 +31,8 @@ object ChromaShader : Shader("chroma", "chroma") { (MinecraftData.totalTicks / 2) + (Minecraft.getMinecraft() as AccessorMinecraft).timer.renderPartialTicks ticks = when (config.chromaDirection) { - 0, 2 -> ticks - 1, 3 -> -ticks + Direction.FORWARD_RIGHT, Direction.BACKWARD_RIGHT -> ticks + Direction.FORWARD_LEFT, Direction.BACKWARD_LEFT -> -ticks else -> ticks } @@ -39,10 +44,17 @@ object ChromaShader : Shader("chroma", "chroma") { } registerUniform(Uniform.UniformType.BOOL, "forwardDirection") { when (config.chromaDirection) { - 0, 1 -> true - 2, 3 -> false + Direction.FORWARD_RIGHT, Direction.FORWARD_LEFT -> true + Direction.BACKWARD_RIGHT, Direction.BACKWARD_LEFT -> false else -> true } } } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.transform(14, "config.chromaDirection") { element -> + ConfigUtils.migrateIntToEnum(element, Direction::class.java) + } + } } -- cgit