diff options
| author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2023-01-11 22:03:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-11 22:03:47 +0100 |
| commit | 49c9345807ed4d13d035e27a0665e2f7c63b0c9e (patch) | |
| tree | 203bb0c8645fff55439da6ec953100d3f63de8a0 | |
| parent | 378c22c7cd98fba1f1bf1c2dd53f560deca29619 (diff) | |
| download | NotEnoughUpdates-49c9345807ed4d13d035e27a0665e2f7c63b0c9e.tar.gz NotEnoughUpdates-49c9345807ed4d13d035e27a0665e2f7c63b0c9e.tar.bz2 NotEnoughUpdates-49c9345807ed4d13d035e27a0665e2f7c63b0c9e.zip | |
Optional Oneconfig support (#401)
28 files changed, 768 insertions, 134 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 04207cf2..e9e769a8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -75,6 +75,7 @@ repositories { maven("https://repo.spongepowered.org/maven/") maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") maven("https://jitpack.io") + maven("https://repo.polyfrost.cc/releases") } lombok { @@ -86,8 +87,12 @@ val shadowImplementation by configurations.creating { configurations.implementation.get().extendsFrom(this) } +val shadowOnly by configurations.creating { + +} + val shadowApi by configurations.creating { - configurations.implementation.get().extendsFrom(this) + configurations.api.get().extendsFrom(this) } val devEnv by configurations.creating { @@ -101,6 +106,14 @@ val kotlinDependencies by configurations.creating { configurations.implementation.get().extendsFrom(this) } +val oneconfigQuarantineSourceSet = sourceSets.create("oneconfig") { + java { + srcDir(layout.projectDirectory.dir("src/main/oneconfig")) + } + kotlin { + } +} + dependencies { implementation("org.projectlombok:lombok:1.18.22") minecraft("com.mojang:minecraft:1.8.9") @@ -108,6 +121,16 @@ dependencies { forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") + if (project.findProperty("neu.buildflags.oneconfig") == "true") { + shadowOnly("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-alpha+") // Should be included in jar + runtimeOnly("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-alpha+") // Should be included in jar + } + + "oneconfigImplementation"(sourceSets.main.get().output) + "oneconfigImplementation"(sourceSets.main.get().compileClasspath) + "oneconfigCompileOnly"(project(":oneconfigquarantine", configuration = "namedElements")) + "runtimeOnly"(oneconfigQuarantineSourceSet.output) + // Please keep this version in sync with KotlinLoadingTweaker implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:1.7.21")) kotlinDependencies(kotlin("stdlib")) @@ -141,6 +164,10 @@ tasks.named<Test>("test") { useJUnitPlatform() } +tasks.named("jar", Jar::class) { + from(oneconfigQuarantineSourceSet.output) +} + tasks.withType(Jar::class) { archiveBaseName.set("NotEnoughUpdates") manifest.attributes.run { @@ -174,8 +201,8 @@ val kotlinDependencyCollectionJar by tasks.creating(Zip::class) { tasks.shadowJar { archiveClassifier.set("dep-dev") + configurations = listOf(shadowImplementation, shadowApi, shadowOnly) archiveBaseName.set("NotEnoughUpdates") - configurations = listOf(shadowImplementation, shadowApi) exclude("**/module-info.class", "LICENSE.txt") dependencies { exclude { @@ -183,6 +210,7 @@ tasks.shadowJar { listOf("logback-classic", "commons-logging", "commons-codec", "logback-core") } } + from(oneconfigQuarantineSourceSet.output) from(kotlinDependencyCollectionJar) dependsOn(kotlinDependencyCollectionJar) fun relocate(name: String) = relocate(name, "io.github.moulberry.notenoughupdates.deps.$name") diff --git a/gradle.properties b/gradle.properties index f596b2d7..0009739e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,3 +4,5 @@ loom.platform=forge # See BuildFlags.java for usages of these values. # Build with Pronouns in PV by default # neu.buildflags.pronouns=true +# Build with Oneconfig support +# neu.buildflags.oneconfig=true diff --git a/oneconfigquarantine/build.gradle.kts b/oneconfigquarantine/build.gradle.kts new file mode 100644 index 00000000..32bc3b7c --- /dev/null +++ b/oneconfigquarantine/build.gradle.kts @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +/** + * This subproject is a stub project to hold oneconfig dependencies, to prevent those dependencies bleeding over into + * our the normal NEU codebase. Usually this could be done using just another source set, however due to using legacy + * arch loom (for now!!!!) we cannot depend on remapped dependencies from only in one source set. + * */ +plugins { + java + id("gg.essential.loom") + id("dev.architectury.architectury-pack200") +} + +loom.forge.pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter()) + +repositories { + mavenCentral() + maven("https://repo.polyfrost.cc/releases") +} + +dependencies { + minecraft("com.mojang:minecraft:1.8.9") + mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") + forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") + + modApi("cc.polyfrost:oneconfig-1.8.9-forge:0.1.0-alpha+") // Don't you just love 0.1.0-alpha+ +} + diff --git a/settings.gradle.kts b/settings.gradle.kts index 408d0f75..a910edd3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,4 +39,5 @@ pluginManagement { } } +include("oneconfigquarantine") rootProject.name = "NotEnoughUpdates" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java b/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java index d997d980..2091496d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java @@ -50,6 +50,7 @@ public class BuildFlags { } public static final boolean ENABLE_PRONOUNS_IN_PV_BY_DEFAULT = getBuildFlag("pronouns"); + public static final boolean ENABLE_ONECONFIG_COMPAT_LAYER = getBuildFlag("oneconfig"); private static class Holder { static Map<String, Boolean> ALL_FLAGS = new HashMap<>(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index f10db528..d6ae6219 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -79,6 +79,7 @@ import io.github.moulberry.notenoughupdates.miscgui.SignCalculator; import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; import io.github.moulberry.notenoughupdates.mixins.AccessorMinecraft; +import io.github.moulberry.notenoughupdates.oneconfig.IOneConfigCompat; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.EquipmentOverlay; import io.github.moulberry.notenoughupdates.overlays.FuelBar; @@ -294,6 +295,8 @@ public class NotEnoughUpdates { if (config.mining.powderGrindingTrackerResetMode == 2) OverlayManager.powderGrindingOverlay.load(); + IOneConfigCompat.getInstance().ifPresent(it -> it.initConfig(config, this::saveConfig)); + MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new NEUEventListener(this)); MinecraftForge.EVENT_BUS.register(new RecipeGenerator(this)); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java index 05a9a65e..fb7b2abe 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java @@ -38,7 +38,8 @@ public class ChromaColour { return sb.toString(); } - private static int[] decompose(String csv) { + @Deprecated + public static int[] decompose(String csv) { String[] split = csv.split(":"); int[] arr = new int[split.length]; @@ -68,6 +69,10 @@ public class ChromaColour { return (255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS; } + public static int getSpeedForSeconds(float seconds) { + return (int) (255 - (seconds - MIN_CHROMA_SECS) * 254f / (MAX_CHROMA_SECS - MIN_CHROMA_SECS)); + } + private static final int MIN_CHROMA_SECS = 1; private static final int MAX_CHROMA_SECS = 60; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java index 11547aaa..ab176933 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java @@ -28,11 +28,12 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Mouse; import java.util.function.Consumer; +import java.util.function.Supplier; public class GuiElementBoolean extends GuiElement { public int x; public int y; - private boolean value; + private Supplier<Boolean> value; private final int clickRadius; private final Consumer<Boolean> toggleCallback; @@ -43,20 +44,20 @@ public class GuiElementBoolean extends GuiElement { private static final int xSize = 48; private static final int ySize = 14; - public GuiElementBoolean(int x, int y, boolean value, Consumer<Boolean> toggleCallback) { + public GuiElementBoolean(int x, int y, Supplier<Boolean> value, Consumer<Boolean> toggleCallback) { this(x, y, value, 0, toggleCallback); } - public GuiElementBoolean(int x, int y, boolean value, int clickRadius, Consumer<Boolean> toggleCallback) { + public GuiElementBoolean(int x, int y, Supplier<Boolean> value, int clickRadius, Consumer<Boolean> toggleCallback) { this.x = x; this.y = y; this.value = value; - this.previewValue = value; + this.previewValue = value.get(); this.clickRadius = clickRadius; this.toggleCallback = toggleCallback; this.lastMillis = System.currentTimeMillis(); - if (value) animation = 36; + if (previewValue) animation = 36; } @Override @@ -70,7 +71,7 @@ public class GuiElementBoolean extends GuiElement { long deltaMillis = currentMillis - lastMillis; lastMillis = currentMillis; boolean passedLimit = false; - if (previewValue != value) { + if (previewValue != value.get()) { if ((previewValue && animation > 12) || (!previewValue && animation < 24)) { passedLimit = true; @@ -83,7 +84,7 @@ public class GuiElementBoolean extends GuiElement { } lastMillis -= deltaMillis % 10; - if (previewValue == value) { + if (previewValue == value.get()) { animation = Math.max(0, Math.min(36, animation)); } else if (!passedLimit) { if (previewValue) { @@ -120,14 +121,13 @@ public class GuiElementBoolean extends GuiElement { mouseY > y - clickRadius && mouseY < y + ySize + clickRadius) { if (Mouse.getEventButton() == 0) { if (Mouse.getEventButtonState()) { - previewValue = !value; - } else if (previewValue == !value) { - value = !value; - toggleCallback.accept(value); + previewValue = !value.get(); + } else if (previewValue == !value.get()) { + toggleCallback.accept(!value.get()); } } } else { - previewValue = value; + previewValue = value.get(); } return false; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java index 1f655aaf..1802a1a4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java @@ -35,6 +35,7 @@ import org.lwjgl.opengl.GL11; import java.awt.*; import java.awt.image.BufferedImage; import java.util.function.Consumer; +import java.util.function.Supplier; public class GuiElementColour extends GuiElement { public static final ResourceLocation colour_selector_dot = new ResourceLocation( @@ -68,20 +69,20 @@ public class GuiElementColour extends GuiElement { private final Consumer<String> colourChangedCallback; private final Runnable closeCallback; - private String colour; + private Supplier<String> colour; private final boolean opacitySlider; private final boolean valueSlider; public GuiElementColour( - int x, int y, String initialColour, Consumer<String> colourChangedCallback, + int x, int y, Supplier<String> colour, Consumer<String> colourChangedCallback, Runnable closeCallback ) { - this(x, y, initialColour, colourChangedCallback, closeCallback, true, true); + this(x, y, colour, colourChangedCallback, closeCallback, true, true); } public GuiElementColour( - int x, int y, String initialColour, Consumer<String> colourChangedCallback, + int x, int y, Supplier<String> colour, Consumer<String> colourChangedCallback, Runnable closeCallback, boolean opacitySlider, boolean valueSlider ) { final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); @@ -89,12 +90,12 @@ public class GuiElementColour extends GuiElement { this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight() - ySize - 10, y)); this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth() - xSize - 10, x)); - this.colour = initialColour; + this.colour = colour; this.colourChangedCallback = colourChangedCallback; this.closeCallback = closeCallback; - int colour = ChromaColour.specialToSimpleRGB(initialColour); - Color c = new Color(colour); + int icolour = ChromaColour.specialToSimpleRGB(colour.get()); + Color c = new Color(icolour); float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); updateAngleAndRadius(hsv); @@ -113,7 +114,7 @@ public class GuiElementColour extends GuiElement { public void render() { RenderUtils.drawFloatingRectDark(x, y, xSize, ySize); - int currentColour = ChromaColour.specialToSimpleRGB(colour); + int currentColour = ChromaColour.specialToSimpleRGB(colour.get()); Color c = new Color(currentColour, true); float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); @@ -200,8 +201,8 @@ public class GuiElementColour extends GuiElement { RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + valueOffset, y + 5, 10, 64, GL11.GL_NEAREST); } - int chromaSpeed = ChromaColour.getSpeed(colour); - int currentColourChroma = ChromaColour.specialToChromaRGB(colour); + int chromaSpeed = ChromaColour.getSpeed(colour.get()); + int currentColourChroma = ChromaColour.specialToChromaRGB(colour.get()); Color cChroma = new Color(currentColourChroma, true); float[] hsvChroma = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null); @@ -343,7 +344,7 @@ public class GuiElementColour extends GuiElement { } } - int chromaSpeed = ChromaColour.getSpeed(colour); + int chromaSpeed = ChromaColour.getSpeed(colour.get()); int xChroma = mouseX - (x + 5 + 64 + valueOffset + opacityOffset + 5); if (xChroma > 0 && xChroma < 10) { if (chromaSpeed > 0) { @@ -351,10 +352,9 @@ public class GuiElementColour extends GuiElement { clickedComponent = 3; } } else if (mouseY > this.y + 5 + 27 && mouseY < this.y + 5 + 37) { - int currentColour = ChromaColour.specialToSimpleRGB(colour); + int currentColour = ChromaColour.specialToSimpleRGB(colour.get()); Color c = new Color(currentColour, true); - colour = ChromaColour.special(200, c.getAlpha(), currentColour); - colourChangedCallback.accept(colour); + colourChangedCallback.accept(ChromaColour.special(200, c.getAlpha(), currentColour)); } } } else { @@ -364,7 +364,7 @@ public class GuiElementColour extends GuiElement { } } if (Mouse.isButtonDown(0) && clickedComponent >= 0) { - int currentColour = ChromaColour.specialToSimpleRGB(colour); + int currentColour = ChromaColour.specialToSimpleRGB(colour.get()); Color c = new Color(currentColour, true); float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); @@ -381,8 +381,7 @@ public class GuiElementColour extends GuiElement { this.wheelAngle = angle; this.wheelRadius = (float) Math.pow(Math.min(1, radius), 1.5f); int rgb = Color.getHSBColor(angle / 360f, wheelRadius, hsv[2]).getRGB(); - colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb); - colourChangedCallback.accept(colour); + colourChangedCallback.accept(ChromaColour.special(ChromaColour.getSpeed(colour.get()), c.getAlpha(), rgb)); return true; } @@ -392,22 +391,19 @@ public class GuiElementColour extends GuiElement { if (clickedComponent == 1) { int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, 1 - y / 64f).getRGB(); - colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb); - colourChangedCallback.accept(colour); + colourChangedCallback.accept(ChromaColour.special(ChromaColour.getSpeed(colour.get()), c.getAlpha(), rgb)); return true; } if (clickedComponent == 2) { - colour = ChromaColour.special(ChromaColour.getSpeed(colour), + colourChangedCallback.accept(ChromaColour.special(ChromaColour.getSpeed(colour.get()), 255 - Math.round(y / 64f * 255), currentColour - ); - colourChangedCallback.accept(colour); + )); return true; } if (clickedComponent == 3) { - colour = ChromaColour.special(255 - Math.round(y / 64f * 255), c.getAlpha(), currentColour); - colourChangedCallback.accept(colour); + colourChangedCallback.accept(ChromaColour.special(255 - Math.round(y / 64f * 255), c.getAlpha(), currentColour)); } return true; } @@ -431,9 +427,8 @@ public class GuiElementColour extends GuiElement { String text = hexField.getText().toLowerCase(); int rgb = Integer.parseInt(text, 16); - int alpha = (ChromaColour.specialToSimpleRGB(colour) >> 24) & 0xFF; - colour = ChromaColour.special(ChromaColour.getSpeed(colour), alpha, rgb); - colourChangedCallback.accept(colour); + int alpha = (ChromaColour.specialToSimpleRGB(colour.get()) >> 24) & 0xFF; + colourChangedCallback.accept(ChromaColour.special(ChromaColour.getSpeed(colour.get()), alpha, rgb)); Color c = new Color(rgb); float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java index dc1173ef..91515259 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java @@ -32,11 +32,9 @@ import org.lwjgl.opengl.GL11; public class GuiOptionEditorAccordion extends GuiOptionEditor { private final int accordionId; - private boolean accordionToggled; public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) { super(option); - this.accordionToggled = (boolean) option.get(); this.accordionId = accordionId; } @@ -50,7 +48,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor { } public boolean getToggled() { - return accordionToggled; + return (boolean) option.get(); } @Override @@ -65,7 +63,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor { GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(1, 1, 1, 1); worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION); - if (accordionToggled) { + if (getToggled()) { worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); worldrenderer.pos((double) x + 9.75f, (double) y + 13.5f, 0.0D).endVertex(); worldrenderer.pos((double) x + 13.5f, (double) y + 6, 0.0D).endVertex(); @@ -87,7 +85,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor { public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { if (Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + getHeight()) { - accordionToggled = !accordionToggled; + option.set(!getToggled()); return true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java index d12ec8e7..00907e9e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java @@ -37,7 +37,7 @@ public class GuiOptionEditorBoolean extends GuiOptionEditor { super(option); this.config = config; this.runnableId = runnableId; - bool = new GuiElementBoolean(0, 0, (boolean) option.get(), 10, (value) -> onUpdate(option, value)); + bool = new GuiElementBoolean(0, 0, () -> (boolean) option.get(), 10, (value) -> onUpdate(option, value)); } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java index ca4087b5..359a3e27 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java @@ -30,13 +30,14 @@ import org.lwjgl.input.Mouse; import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_white; public class GuiOptionEditorColour extends GuiOptionEditor { - private String chromaColour; private GuiElementColour colourElement = null; public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) { super(option); + } - this.chromaColour = (String) option.get(); + public String getChromaString() { + return (String) option.get(); } @Override @@ -44,7 +45,7 @@ public class GuiOptionEditorColour extends GuiOptionEditor { super.render(x, y, width); int height = getHeight(); - int argb = ChromaColour.specialToChromaRGB(chromaColour); + int argb = ChromaColour.specialToChromaRGB(getChromaString()); int r = (argb >> 16) & 0xFF; int g = (argb >> 8) & 0xFF; int b = argb & 0xFF; @@ -72,10 +73,8 @@ public class GuiOptionEditorColour extends GuiOptionEditor { if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0 && mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) { - colourElement = new GuiElementColour(mouseX, mouseY, (String) option.get(), (val) -> { - option.set(val); - chromaColour = val; - }, () -> colourElement = null); + colourElement = new GuiElementColour(mouseX, mouseY, () -> (String) option.get(), + option::set, () -> colourElement = null); } return false; |
