From 13ad58ef5a26a61d1d07f546153c7020ee7527b5 Mon Sep 17 00:00:00 2001 From: Mixces Date: Sun, 2 Jun 2024 02:02:17 -0500 Subject: [PATCH] Take the wheel imToggle :cold_face: --- .../RenderItemMixin_GlintCustomizer.java | 111 +++++++++++ .../glintcolorizer/GlintColorizer.kt | 3 - .../glintcolorizer/config/GlintConfig.kt | 184 ++++++++++++------ 3 files changed, 231 insertions(+), 67 deletions(-) diff --git a/src/main/java/org/polyfrost/glintcolorizer/mixin/RenderItemMixin_GlintCustomizer.java b/src/main/java/org/polyfrost/glintcolorizer/mixin/RenderItemMixin_GlintCustomizer.java index b15796f..0cf52f4 100644 --- a/src/main/java/org/polyfrost/glintcolorizer/mixin/RenderItemMixin_GlintCustomizer.java +++ b/src/main/java/org/polyfrost/glintcolorizer/mixin/RenderItemMixin_GlintCustomizer.java @@ -38,6 +38,47 @@ public class RenderItemMixin_GlintCustomizer { } } + @ModifyArg( + method = "renderEffect", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V" + ), + index = 0 + ) + private float glintColorizer$modifySpeed(float speed) { + if (!GlintConfig.INSTANCE.enabled) { return speed; } + return glintColorizer$getModifiedSpeed(speed); //todo: adw + } + + @ModifyArg( + method = "renderEffect", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/GlStateManager;rotate(FFFF)V", + ordinal = 0 + ), + index = 0 + ) + private float glintColorizer$modifyRotation(float angle) { + if (!GlintConfig.INSTANCE.enabled) { return angle; } + return glintColorizer$getModifiedRotation(angle, true); //todo: adw + } + + @ModifyArg( + method = "renderEffect", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/GlStateManager;rotate(FFFF)V", + ordinal = 1 + ), + index = 0 + ) + private float glintColorizer$modifyRotation2(float angle) { + if (!GlintConfig.INSTANCE.enabled) { return angle; } + return glintColorizer$getModifiedRotation(angle, false); //todo: adw + } + @ModifyArg( method = "renderEffect", at = @At( @@ -103,6 +144,76 @@ public class RenderItemMixin_GlintCustomizer { return color; } + @Unique + private float glintColorizer$getModifiedRotation(float color, boolean isFirstStroke) { + if (RenderItemHook.INSTANCE.isRenderingHeld()) { + return isFirstStroke ? GlintConfig.INSTANCE.getHeldStrokeRotOne() : GlintConfig.INSTANCE.getHeldStrokeRotTwo(); + } + +// if (RenderItemHook.INSTANCE.isRenderingInGUI()) { +// if (GlintConfig.INSTANCE.getPotionBasedColor() && RenderItemHook.INSTANCE.isPotionItem()) { +// return glintColorizer$getPotionColor(RenderItemHook.INSTANCE.getItemStack()); +// } +// if (GlintConfig.INSTANCE.getPotionGlintBackground() && RenderItemHook.INSTANCE.isPotionItem()) { +// return GlintConfig.INSTANCE.getShinyIndividualStrokes() ? +// (isFirstStroke ? GlintConfig.INSTANCE.getShinyStrokeOne().getRGB() : GlintConfig.INSTANCE.getShinyStrokeTwo().getRGB()) : +// GlintConfig.INSTANCE.getShinyColor().getRGB(); +// } +// return GlintConfig.INSTANCE.getGuiIndividualStrokes() ? +// (isFirstStroke ? GlintConfig.INSTANCE.getGuiStrokeOne().getRGB() : GlintConfig.INSTANCE.getGuiStrokeTwo().getRGB()) : +// GlintConfig.INSTANCE.getGuiColor().getRGB(); +// } +// +// if (RenderItemHook.INSTANCE.isRenderingDropped()) { +// return GlintConfig.INSTANCE.getDroppedIndividualStrokes() ? +// (isFirstStroke ? GlintConfig.INSTANCE.getDroppedStrokeOne().getRGB() : GlintConfig.INSTANCE.getDroppedStrokeTwo().getRGB()) : +// GlintConfig.INSTANCE.getDroppedColor().getRGB(); +// } +// +// if (RenderItemHook.INSTANCE.isRenderingFramed()) { +// return GlintConfig.INSTANCE.getFramedIndividualStrokes() ? +// (isFirstStroke ? GlintConfig.INSTANCE.getFramedStrokeOne().getRGB() : GlintConfig.INSTANCE.getFramedStrokeTwo().getRGB()) : +// GlintConfig.INSTANCE.getFramedColor().getRGB(); +// } + + return color; + } + + @Unique + private float glintColorizer$getModifiedSpeed(float speed) { + if (RenderItemHook.INSTANCE.isRenderingHeld()) { + return GlintConfig.INSTANCE.getHeldSpeed() * speed; + } + +// if (RenderItemHook.INSTANCE.isRenderingInGUI()) { +// if (GlintConfig.INSTANCE.getPotionBasedColor() && RenderItemHook.INSTANCE.isPotionItem()) { +// return glintColorizer$getPotionColor(RenderItemHook.INSTANCE.getItemStack()); +// } +// if (GlintConfig.INSTANCE.getPotionGlintBackground() && RenderItemHook.INSTANCE.isPotionItem()) { +// return GlintConfig.INSTANCE.getShinyIndividualStrokes() ? +// (isFirstStroke ? GlintConfig.INSTANCE.getShinyStrokeOne().getRGB() : GlintConfig.INSTANCE.getShinyStrokeTwo().getRGB()) : +// GlintConfig.INSTANCE.getShinyColor().getRGB(); +// } +// return GlintConfig.INSTANCE.getGuiIndividualStrokes() ? +// (isFirstStroke ? GlintConfig.INSTANCE.getGuiStrokeOne().getRGB() : GlintConfig.INSTANCE.getGuiStrokeTwo().getRGB()) : +// GlintConfig.INSTANCE.getGuiColor().getRGB(); +// } +// +// if (RenderItemHook.INSTANCE.isRenderingDropped()) { +// return GlintConfig.INSTANCE.getDroppedIndividualStrokes() ? +// (isFirstStroke ? GlintConfig.INSTANCE.getDroppedStrokeOne().getRGB() : GlintConfig.INSTANCE.getDroppedStrokeTwo().getRGB()) : +// GlintConfig.INSTANCE.getDroppedColor().getRGB(); +// } +// +// if (RenderItemHook.INSTANCE.isRenderingFramed()) { +// return GlintConfig.INSTANCE.getFramedIndividualStrokes() ? +// (isFirstStroke ? GlintConfig.INSTANCE.getFramedStrokeOne().getRGB() : GlintConfig.INSTANCE.getFramedStrokeTwo().getRGB()) : +// GlintConfig.INSTANCE.getFramedColor().getRGB(); +// } + + return speed; + } + @Unique private boolean glintColorizer$shouldApplyMatrix() { return GlintConfig.INSTANCE.getPotionGlintSize() && diff --git a/src/main/kotlin/org/polyfrost/glintcolorizer/GlintColorizer.kt b/src/main/kotlin/org/polyfrost/glintcolorizer/GlintColorizer.kt index ce167d4..bb3709b 100644 --- a/src/main/kotlin/org/polyfrost/glintcolorizer/GlintColorizer.kt +++ b/src/main/kotlin/org/polyfrost/glintcolorizer/GlintColorizer.kt @@ -1,6 +1,5 @@ package org.polyfrost.glintcolorizer -import cc.polyfrost.oneconfig.config.core.ConfigUtils import cc.polyfrost.oneconfig.utils.commands.CommandManager import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.event.FMLInitializationEvent @@ -20,8 +19,6 @@ object GlintColorizer { const val VER: String = "@VER@" const val ID: String = "@ID@" - val path = "${ConfigUtils.getProfileDir().absolutePath}/${ID}/caches/" - @Mod.EventHandler fun onInit(event: FMLInitializationEvent?) { GlintConfig diff --git a/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintConfig.kt b/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintConfig.kt index 5f01806..129845d 100644 --- a/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintConfig.kt +++ b/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintConfig.kt @@ -6,7 +6,6 @@ import cc.polyfrost.oneconfig.config.core.OneColor import cc.polyfrost.oneconfig.config.data.Mod import cc.polyfrost.oneconfig.config.data.ModType import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator -import net.minecraft.client.Minecraft import org.polyfrost.glintcolorizer.GlintColorizer import java.io.File @@ -23,12 +22,10 @@ object GlintConfig : Config( @Button( name = "Reset ALL Colors Settings", category = "Global", - subcategory = "Color Configuration", text = "Reset", description = "Resets ALL custom glint colors settings and defaults them back to the vanilla color." ) var resetColors: Runnable = (Runnable { - Minecraft.getMinecraft().displayGuiScreen(null) /* Singular Colors */ heldColor = OneColor(defaultColor) guiColor = OneColor(defaultColor) @@ -52,143 +49,205 @@ object GlintConfig : Config( guiIndividualStrokes = false droppedIndividualStrokes = false framedIndividualStrokes = false - - GlintConfig.save() - openGui() }) @Button( name = "Reset ALL Shiny Pots Settings", category = "Global", - subcategory = "Color Configuration", text = "Reset", description = "Resets ALL custom shiny pots settings." ) var resetShinyPots: Runnable = (Runnable { - Minecraft.getMinecraft().displayGuiScreen(null) potionGlint = false potionGlintSize = false potionGlintBackground = false potionBasedColor = false potionGlintForeground = false - GlintConfig.save() - openGui() + }) + + @Color( + name = "Global Glint Color", + category = "Global", + subcategory = "Configuration", + description = "Modifies the color of the enchantment glint." + ) + var globalColor: OneColor = OneColor(defaultColor) + + @Button( + name = "Apply Global Glint Color", + category = "Global", + subcategory = "Configuration", + text = "Apply", + description = "Applies your global glint color. Resets ALL custom colors." + ) + var applyColors: Runnable = (Runnable { + /* Singular Colors */ + heldColor = OneColor(globalColor.rgb) + guiColor = OneColor(globalColor.rgb) + droppedColor = OneColor(globalColor.rgb) + framedColor = OneColor(globalColor.rgb) + shinyColor = OneColor(globalColor.rgb) + armorColor = OneColor(globalColor.rgb) + /* Stroke */ + heldIndividualStrokes = false + guiIndividualStrokes = false + droppedIndividualStrokes = false + framedIndividualStrokes = false }) // @Button( // name = "Sync Armor Glint With Item Glint", // category = "Global", -// subcategory = "Color Configuration", +// subcategory = "Configuration", // text = "Sync", // description = "Syncs the armor glint color with the item glint color." // ) // var syncAtoI: Runnable = (Runnable { -// Minecraft.getMinecraft().displayGuiScreen(null) // guiStrokeOne = OneColor(defaultColor) // guiStrokeTwo = OneColor(defaultColor) -// save() -// openGui() // }) // // @Button( // name = "Sync Item Glint With Armor Glint", // category = "Global", -// subcategory = "Color Configuration", +// subcategory = "Configuration", // text = "Sync", // description = "Syncs the item glint color with the armor glint color ." // ) // var syncItoA: Runnable = (Runnable { -// Minecraft.getMinecraft().displayGuiScreen(null) // guiStrokeOne = OneColor(defaultColor) // guiStrokeTwo = OneColor(defaultColor) -// save() -// openGui() // }) /* Held Items */ @Button( name = "Reset Held Glint Colors", - category = "Held Item Glint Color", - subcategory = "Color Configuration", + category = "Held Item", + subcategory = "Configuration", text = "Reset", description = "Resets ALL custom glint colors." ) var resetHeld: Runnable = (Runnable { - Minecraft.getMinecraft().displayGuiScreen(null) heldColor = OneColor(defaultColor) heldStrokeOne = OneColor(defaultColor) heldStrokeTwo = OneColor(defaultColor) - GlintConfig.save() - openGui() + }) + + @Button( + name = "Reset Held Glint Transformations", + category = "Held Item", + subcategory = "Configuration", + text = "Reset", + description = "Resets ALL custom glint transformations." + ) + var resetHeld2: Runnable = (Runnable { + heldSpeed = 1.0F + heldStrokeRotOne = -50.0F + heldStrokeRotTwo = 10.0F }) @Switch( name = "Modify Strokes Individually", - category = "Held Item Glint Color", + category = "Held Item", + subcategory = "Color" ) var heldIndividualStrokes: Boolean = false @Color( name = "Held Item Glint Color", - category = "Held Item Glint Color", + category = "Held Item", + subcategory = "Color", description = "Modifies the color of the enchantment glint." ) var heldColor: OneColor = OneColor(defaultColor) @Color( name = "Stroke 1 Color", - category = "Held Item Glint Color", + category = "Held Item", + subcategory = "Color", description = "Modifies the first stroke of the enchantment glint effect." ) var heldStrokeOne: OneColor = OneColor(defaultColor) @Color( name = "Stroke 2 Color", - category = "Held Item Glint Color", + category = "Held Item", + subcategory = "Color", description = "Modifies the second stroke of the enchantment glint effect." ) var heldStrokeTwo: OneColor = OneColor(defaultColor) + @Slider( + name = "Speed", + category = "Held Item", + subcategory = "Speed", + min = 0.1F, + max = 10.0F, + instant = true + ) + var heldSpeed = 1.0F + + @Slider( + name = "Stroke 1 Rotation", + category = "Held Item", + subcategory = "Rotation", + min = -180.0F, + max = 180.0F, + instant = true + ) + var heldStrokeRotOne = -50.0F + + @Slider( + name = "Stroke 2 Rotation", + category = "Held Item", + subcategory = "Rotation", + min = -180.0F, + max = 180.0F, + instant = true + ) + var heldStrokeRotTwo = 10.0F + /* Gui Items */ @Button( name = "Reset GUI Item Glint Colors", - category = "GUI Item Glint Color", - subcategory = "Color Configuration", + category = "GUI Item", + subcategory = "Configuration", text = "Reset", description = "Resets ALL custom glint colors." ) var resetGui: Runnable = (Runnable { - Minecraft.getMinecraft().displayGuiScreen(null) guiColor = OneColor(defaultColor) guiStrokeOne = OneColor(defaultColor) guiStrokeTwo = OneColor(defaultColor) - GlintConfig.save() - openGui() }) @Switch( name = "Modify Strokes Individually", - category = "GUI Item Glint Color", + category = "GUI Item ", + subcategory = "Color" ) var guiIndividualStrokes: Boolean = false @Color( name = "GUI Item Glint Color", - category = "GUI Item Glint Color", + category = "GUI Item", + subcategory = "Color", description = "Modifies the color of the enchantment glint." ) var guiColor: OneColor = OneColor(defaultColor) @Color( name = "Stroke 1 Color", - category = "GUI Item Glint Color", + category = "GUI Item", + subcategory = "Color", description = "Modifies the first stroke of the enchantment glint effect." ) var guiStrokeOne: OneColor = OneColor(defaultColor) @Color( name = "Stroke 2 Color", - category = "GUI Item Glint Color", + category = "GUI Item", + subcategory = "Color", description = "Modifies the second stroke of the enchantment glint effect." ) var guiStrokeTwo: OneColor = OneColor(defaultColor) @@ -196,43 +255,44 @@ object GlintConfig : Config( /* Dropped Items */ @Button( name = "Reset Dropped Item Glint Colors", - category = "Dropped Item Glint Color", - subcategory = "Color Configuration", + category = "Dropped Item", + subcategory = "Configuration", text = "Reset", description = "Resets ALL custom glint colors." ) var resetDropped: Runnable = (Runnable { - Minecraft.getMinecraft().displayGuiScreen(null) droppedColor = OneColor(defaultColor) droppedStrokeOne = OneColor(defaultColor) droppedStrokeTwo = OneColor(defaultColor) - GlintConfig.save() - openGui() }) @Switch( name = "Modify Strokes Individually", - category = "Dropped Item Glint Color", + category = "Dropped Item", + subcategory = "Color" ) var droppedIndividualStrokes: Boolean = false @Color( name = "Dropped Item Glint Color", - category = "Dropped Item Glint Color", + category = "Dropped Item", + subcategory = "Color", description = "Modifies the color of the enchantment glint." ) var droppedColor: OneColor = OneColor(defaultColor) @Color( name = "Stroke 1 Color", - category = "Dropped Item Glint Color", + category = "Dropped Item", + subcategory = "Color", description = "Modifies the first stroke of the enchantment glint effect." ) var droppedStrokeOne: OneColor = OneColor(defaultColor) @Color( name = "Stroke 2 Color", - category = "Dropped Item Glint Color", + category = "Dropped Item", + subcategory = "Color", description = "Modifies the second stroke of the enchantment glint effect." ) var droppedStrokeTwo: OneColor = OneColor(defaultColor) @@ -240,43 +300,44 @@ object GlintConfig : Config( /* Framed Items */ @Button( name = "Reset Framed Item Glint Colors", - category = "Framed Item Glint Color", - subcategory = "Color Configuration", + category = "Framed Item", + subcategory = "Configuration", text = "Reset", description = "Resets ALL custom glint colors." ) var resetFramed: Runnable = (Runnable { - Minecraft.getMinecraft().displayGuiScreen(null) droppedColor = OneColor(defaultColor) droppedStrokeOne = OneColor(defaultColor) droppedStrokeTwo = OneColor(defaultColor) - GlintConfig.save() - openGui() }) @Switch( name = "Modify Strokes Individually", - category = "Framed Item Glint Color", + category = "Framed Item", + subcategory = "Color" ) var framedIndividualStrokes: Boolean = false @Color( name = "Framed Item Glint Color", - category = "Framed Item Glint Color", + category = "Framed Item", + subcategory = "Color", description = "Modifies the color of the enchantment glint." ) var framedColor: OneColor = OneColor(defaultColor) @Color( name = "Stroke 1 Color", - category = "Framed Item Glint Color", + category = "Framed Item", + subcategory = "Color", description = "Modifies the first stroke of the enchantment glint effect." ) var framedStrokeOne: OneColor = OneColor(defaultColor) @Color( name = "Stroke 2 Color", - category = "Framed Item Glint Color", + category = "Framed Item", + subcategory = "Color", description = "Modifies the second stroke of the enchantment glint effect." ) var framedStrokeTwo: OneColor = OneColor(defaultColor) @@ -284,21 +345,19 @@ object GlintConfig : Config( /* Armor */ @Button( name = "Reset Armor Glint", - category = "Armor Glint Color", - subcategory = "Color Configuration", + category = "Armor", + subcategory = "Configuration", text = "Reset", description = "Resets ALL custom glint colors." ) var resetArmor: Runnable = (Runnable { - Minecraft.getMinecraft().displayGuiScreen(null) armorColor = OneColor(defaultColor) - GlintConfig.save() - openGui() }) @Color( name = "Armor Glint Color", - category = "Armor Glint Color", + category = "Armor", + subcategory = "Color", description = "Modifies the color of the enchantment glint." ) var armorColor: OneColor = OneColor(defaultColor) @@ -307,20 +366,17 @@ object GlintConfig : Config( @Button( name = "Reset Shiny Pots Glint Colors", category = "Shiny Pots", - subcategory = "Color Configuration", + subcategory = "Configuration", text = "Reset", description = "Resets ALL custom glint colors." ) var resetShiny: Runnable = (Runnable { - Minecraft.getMinecraft().displayGuiScreen(null) shinyColor = OneColor(defaultColor) shinyStrokeOne = OneColor(defaultColor) shinyStrokeTwo = OneColor(defaultColor) potionBasedColor = false potionGlintBackground = false potionGlintForeground = false - GlintConfig.save() - openGui() }) @Switch(