aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander
diff options
context:
space:
mode:
authorisXander <xander@isxander.dev>2024-10-19 19:22:45 +0100
committerisXander <xander@isxander.dev>2024-10-19 19:22:45 +0100
commite73a08e6672fb380cab8db71340158969c5ef56b (patch)
treedd08a311f4eff9a91b465ef1854caa1286fc6f9a /src/main/java/dev/isxander
parent519ac2fc0e23587defcf4a8259979961d35d0ce2 (diff)
downloadYetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.tar.gz
YetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.tar.bz2
YetAnotherConfigLib-e73a08e6672fb380cab8db71340158969c5ef56b.zip
3.6.0
Diffstat (limited to 'src/main/java/dev/isxander')
-rw-r--r--src/main/java/dev/isxander/yacl3/api/LabelOption.java2
-rw-r--r--src/main/java/dev/isxander/yacl3/api/ListOption.java6
-rw-r--r--src/main/java/dev/isxander/yacl3/api/Option.java20
-rw-r--r--src/main/java/dev/isxander/yacl3/api/OptionEventListener.java13
-rw-r--r--src/main/java/dev/isxander/yacl3/api/StateManager.java89
-rw-r--r--src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java2
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java49
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java3
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/YACLScreen.java14
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/controllers/ColorController.java8
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/controllers/ColorPickerWidget.java16
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/controllers/LabelController.java2
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/controllers/dropdown/DropdownWidget.java19
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/controllers/dropdown/ItemControllerElement.java10
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/controllers/string/StringControllerElement.java7
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/image/YACLImageReloadListener.java10
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/image/impl/AnimatedDynamicTextureImage.java17
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/image/impl/DynamicTextureImage.java3
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/image/impl/ResourceTextureImage.java3
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/utils/GuiUtils.java81
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java9
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/utils/MiscUtil.java14
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java2
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/ButtonOptionImpl.java20
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/HiddenNameListOptionEntry.java11
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/ImmutableStateManager.java56
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/InstantStateManager.java68
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/LabelOptionImpl.java160
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/ListOptionEntryImpl.java12
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/ListOptionImpl.java120
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/NotNullBinding.java31
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/OptionImpl.java162
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/ProvidesBindingForDeprecation.java7
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/SafeBinding.java29
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/SelfContainedBinding.java32
-rw-r--r--src/main/java/dev/isxander/yacl3/impl/SimpleStateManager.java65
36 files changed, 868 insertions, 304 deletions
diff --git a/src/main/java/dev/isxander/yacl3/api/LabelOption.java b/src/main/java/dev/isxander/yacl3/api/LabelOption.java
index a5f015e..16372b0 100644
--- a/src/main/java/dev/isxander/yacl3/api/LabelOption.java
+++ b/src/main/java/dev/isxander/yacl3/api/LabelOption.java
@@ -26,6 +26,8 @@ public interface LabelOption extends Option<Component> {
}
interface Builder {
+ Builder state(@NotNull StateManager<Component> stateManager);
+
/**
* Appends a line to the label
*/
diff --git a/src/main/java/dev/isxander/yacl3/api/ListOption.java b/src/main/java/dev/isxander/yacl3/api/ListOption.java
index 1f4adfa..9103254 100644
--- a/src/main/java/dev/isxander/yacl3/api/ListOption.java
+++ b/src/main/java/dev/isxander/yacl3/api/ListOption.java
@@ -93,6 +93,8 @@ public interface ListOption<T> extends OptionGroup, Option<List<T>> {
*/
Builder<T> customController(@NotNull Function<ListOptionEntry<T>, Controller<T>> control);
+ Builder<T> state(@NotNull StateManager<List<T>> stateManager);
+
/**
* Sets the binding for the option.
* Used for default, getter and setter.
@@ -159,6 +161,10 @@ public interface ListOption<T> extends OptionGroup, Option<List<T>> {
*/
Builder<T> collapsed(boolean collapsible);
+ ListOption.Builder<T> addListener(@NotNull OptionEventListener<List<T>> listener);
+
+ ListOption.Builder<T> addListeners(@NotNull Collection<OptionEventListener<List<T>>> listeners);
+
/**
* Adds a listener to the option. Invoked upon changing any of the list's entries.
*
diff --git a/src/main/java/dev/isxander/yacl3/api/Option.java b/src/main/java/dev/isxander/yacl3/api/Option.java
index 38bd8ca..9190168 100644
--- a/src/main/java/dev/isxander/yacl3/api/Option.java
+++ b/src/main/java/dev/isxander/yacl3/api/Option.java
@@ -34,12 +34,15 @@ public interface Option<T> {
*/
@NotNull Controller<T> controller();
+ @NotNull StateManager<T> stateManager();
+
/**
* Binding for the option.
* Controls setting, getting and default value.
*
* @see Binding
*/
+ @Deprecated
@NotNull Binding<T> binding();
/**
@@ -101,9 +104,12 @@ public interface Option<T> {
return true;
}
+ void addEventListener(OptionEventListener<T> listener);
+
/**
* Adds a listener for when the pending value changes
*/
+ @Deprecated
void addListener(BiConsumer<Option<T>, T> changedListener);
static <T> Builder<T> createBuilder() {
@@ -146,6 +152,10 @@ public interface Option<T> {
*/
Builder<T> description(@NotNull Function<T, OptionDescription> descriptionFunction);
+ /**
+ * Supplies a controller for this option. A controller is the GUI control to interact with the option.
+ * @return this builder
+ */
Builder<T> controller(@NotNull Function<Option<T>, ControllerBuilder<T>> controllerBuilder);
/**
@@ -156,9 +166,12 @@ public interface Option<T> {
*/
Builder<T> customController(@NotNull Function<Option<T>, Controller<T>> control);
+ Builder<T> stateManager(@NotNull StateManager<T> stateManager);
+
/**
* Sets the binding for the option.
* Used for default, getter and setter.
+ * Under-the-hood, this creates a state manager that is individual to the option, sharing state with no options.
*
* @see Binding
*/
@@ -196,12 +209,17 @@ public interface Option<T> {
*/
Builder<T> flags(@NotNull Collection<? extends OptionFlag> flags);
+ Builder<T> addListener(@NotNull OptionEventListener<T> listener);
+
+ Builder<T> addListeners(@NotNull Collection<OptionEventListener<T>> listeners);
+
/**
* Instantly invokes the binder's setter when modified in the GUI.
* Prevents the user from undoing the change
* <p>
* Does not support {@link Option#flags()}!
*/
+ @Deprecated
Builder<T> instant(boolean instant);
/**
@@ -209,6 +227,7 @@ public interface Option<T> {
*
* @see Option#addListener(BiConsumer)
*/
+ @Deprecated
Builder<T> listener(@NotNull BiConsumer<Option<T>, T> listener);
/**
@@ -216,6 +235,7 @@ public interface Option<T> {
*
* @see Option#addListener(BiConsumer)
*/
+ @Deprecated
Builder<T> listeners(@NotNull Collection<BiConsumer<Option<T>, T>> listeners);
Option<T> build();
diff --git a/src/main/java/dev/isxander/yacl3/api/OptionEventListener.java b/src/main/java/dev/isxander/yacl3/api/OptionEventListener.java
new file mode 100644
index 0000000..c805948
--- /dev/null
+++ b/src/main/java/dev/isxander/yacl3/api/OptionEventListener.java
@@ -0,0 +1,13 @@
+package dev.isxander.yacl3.api;
+
+@FunctionalInterface
+public interface OptionEventListener<T> {
+ void onEvent(Option<T> option, Event event);
+
+ enum Event {
+ INITIAL,
+ STATE_CHANGE,
+ AVAILABILITY_CHANGE,
+ OTHER,
+ }
+}
diff --git a/src/main/java/dev/isxander/yacl3/api/StateManager.java b/src/main/java/dev/isxander/yacl3/api/StateManager.java
new file mode 100644
index 0000000..07d263e
--- /dev/null
+++ b/src/main/java/dev/isxander/yacl3/api/StateManager.java
@@ -0,0 +1,89 @@
+package dev.isxander.yacl3.api;
+
+import dev.isxander.yacl3.impl.ImmutableStateManager;
+import dev.isxander.yacl3.impl.InstantStateManager;
+import dev.isxander.yacl3.impl.SimpleStateManager;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+public interface StateManager<T> {
+ static <T> StateManager<T> createSimple(Binding<T> binding) {
+ return new SimpleStateManager<>(binding);
+ }
+
+ static <T> StateManager<T> createSimple(@NotNull T def, @NotNull Supplier<@NotNull T> getter, @NotNull Consumer<@NotNull T> setter) {
+ return new SimpleStateManager<>(Binding.generic(def, getter, setter));
+ }
+
+ static <T> StateManager<T> createInstant(Binding<T> binding) {
+ return new InstantStateManager<>(binding);
+ }
+
+ static <T> StateManager<T> createInstant(@NotNull T def, @NotNull Supplier<@NotNull T> getter, @NotNull Consumer<@NotNull T> setter) {
+ return new InstantStateManager<>(Binding.generic(def, getter, setter));
+ }
+
+ static <T> StateManager<T> createImmutable(@NotNull T value) {
+ return new ImmutableStateManager<>(value);
+ }
+
+ /**
+ * Sets the pending value.
+ */
+ void set(T value);
+
+ /**
+ * @return the pending value.
+ */
+ T get();
+
+ /**
+ * Applies the pending value to the backed binding.
+ */
+ void apply();
+
+ void resetToDefault(ResetAction action);
+
+ /**
+ * Essentially "forgets" the pending value and reassigns state as backed by the binding.
+ */
+ void sync();
+
+ /**
+ * @return true if the pending value is the same as the backed binding value.
+ */
+ boolean isSynced();
+
+ /**
+ * @return true if this state manage will always be synced with the backing binding.
+ */
+ default boolean isAlwaysSynced() {
+ return false;
+ }
+
+ boolean isDefault();
+
+ void addListener(StateListener<T> stateListener);
+
+ enum ResetAction {
+ BY_OPTION,
+ BY_GLOBAL,
+ }
+
+ interface StateListener<T> {
+ static <T> StateListener<T> noop() {
+ return (oldValue, newValue) -> {};
+ }
+
+ void onStateChange(T oldValue, T newValue);
+
+ default StateListener<T> andThen(StateListener<T> after) {
+ return (oldValue, newValue) -> {
+ this.onStateChange(oldValue, newValue);
+ after.onStateChange(oldValue, newValue);
+ };
+ }
+ }
+}
diff --git a/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java b/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java
index bbb878d..9adc64f 100644
--- a/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java
+++ b/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java
@@ -37,7 +37,7 @@ public abstract class SimpleOptionFactory<A extends Annotation, T> implements Op
})
.available(this.available(annotation, field, optionAccess))
.flags(this.flags(annotation, field, optionAccess))
- .listener((opt, v) -> this.listener(annotation, field, optionAccess, opt, v))
+ .addListener((opt, event) -> this.listener(annotation, field, optionAccess, opt, opt.pendingValue()))
.build();
postInit(annotation, field, optionAccess, option);
diff --git a/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java b/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
index 48f2cc3..111ccdb 100644
--- a/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
+++ b/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
@@ -2,6 +2,7 @@ package dev.isxander.yacl3.gui;
import com.mojang.blaze3d.vertex.VertexConsumer;
import dev.isxander.yacl3.api.utils.Dimension;
+import dev.isxander.yacl3.gui.utils.GuiUtils;
import dev.isxander.yacl3.gui.utils.YACLRenderHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
@@ -88,23 +89,22 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na
graphics.fill(x1, y1, x1 + width, y2, color);
}
- protected void fillSidewaysGradient(GuiGraphics graphics, int x1, int y1, int x2, int y2, int startColor, int endColor) {
+ protected void fillSidewaysGradient(GuiGraphics graphics, int x1, int y1, int x2, int y2, int startColor, int endColor, VertexConsumer consumer) {
//Fills a gradient, left to right
//Uses practically the same method as the GuiGraphics class, but with the x/y moved
//Has a custom "z" value in case needed for later
- VertexConsumer vertex = graphics.bufferSource().getBuffer(RenderType.gui());
Matrix4f matrix4f = graphics.pose().last().pose();
/*? if >1.20.6 {*/
- vertex.addVertex(matrix4f, x1, y1, 0).setColor(startColor);
- vertex.addVertex(matrix4f, x1, y2, 0).setColor(startColor);
- vertex.addVertex(matrix4f, x2, y2, 0).setColor(endColor);
- vertex.addVertex(matrix4f, x2, y1, 0).setColor(endColor);
+ consumer.addVertex(matrix4f, x1, y1, 0).setColor(startColor);
+ consumer.addVertex(matrix4f, x1, y2, 0).setColor(startColor);
+ consumer.addVertex(matrix4f, x2, y2, 0).setColor(endColor);
+ consumer.addVertex(matrix4f, x2, y1, 0).setColor(endColor);
/*?} else {*/
- /*vertex.vertex(matrix4f, x1, y1, 0).color(startColor).endVertex();
- vertex.vertex(matrix4f, x1, y2, 0).color(startColor).endVertex();
- vertex.vertex(matrix4f, x2, y2, 0).color(endColor).endVertex();
- vertex.vertex(matrix4f, x2, y1, 0).color(endColor).endVertex();
+ /*consumer.vertex(matrix4f, x1, y1, 0).color(startColor).endVertex();
+ consumer.vertex(matrix4f, x1, y2, 0).color(startColor).endVertex();
+ consumer.vertex(matrix4f, x2, y2, 0).color(endColor).endVertex();
+ consumer.vertex(matrix4f, x2, y1, 0).color(endColor).endVertex();
*//*?}*/
}
@@ -115,16 +115,25 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na
Color.cyan.getRGB(), Color.blue.getRGB(), Color.magenta.getRGB(), Color.red.getRGB()}; //all the colors in the gradient
int width = x2 - x1;
int maxColors = colors.length - 1;
- for (int color = 0; color < maxColors; color++) {
- //First checks if the final color is being rendered, if true -> uses x2 int instead of x1
- //if false -> it adds the width divided by the max colors multiplied by the current color plus one to the x1 int
- //the x2 int for the fillSidewaysGradient is the same formula, excluding the additional plus one.
- //The gradient colors is determined by the color int and the color int plus one, which is why red is in the colors array twice
- fillSidewaysGradient(graphics,
- x1 + (width / maxColors * color), y1,
- color == maxColors - 1 ? x2 : x1 + (width / maxColors * (color + 1)), y2,
- colors[color], colors[color + 1]);
- }
+
+ GuiUtils.drawSpecial(graphics, bufferSource -> {
+ VertexConsumer consumer = bufferSource.getBuffer(RenderType.gui());
+
+ for (int color = 0; color < maxColors; color++) {
+ //First checks if the final color is being rendered, if true -> uses x2 int instead of x1
+ //if false -> it adds the width divided by the max colors multiplied by the current color plus one to the x1 int
+ //the x2 int for the fillSidewaysGradient is the same formula, excluding the additional plus one.
+ //The gradient colors is determined by the color int and the color int plus one, which is why red is in the colors array twice
+ fillSidewaysGradient(
+ graphics,
+ x1 + (width / maxColors * color), y1,
+ color == maxColors - 1 ? x2 : x1 + (width / maxColors * (color + 1)), y2,
+ colors[color], colors[color + 1],
+ consumer
+ );
+ }
+ });
+
}
protected int multiplyColor(int hex, float amount) {
diff --git a/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java b/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java
index 8412cc8..cbd15fe 100644
--- a/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java
+++ b/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java
@@ -173,7 +173,8 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
}
@Override
- protected int getRowTop(int index) {
+ /*? if >=1.21.2 {*/ public /*?} else {*/ /*protected *//*?}*/
+ int getRowTop(int index) {
int integer = getY() + 4 - (int) this.getScrollAmount() + headerHeight;
for (int i = 0; i < children().size() && i < index; i++)
integer += children().get(i).getItemHeight();
diff --git a/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java
index 90bc75f..812a0a1 100644
--- a/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java
+++ b/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java
@@ -2,7 +2,6 @@ package dev.isxander.yacl3.gui;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Axis;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.utils.Dimension;
@@ -25,12 +24,10 @@ import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.components.tabs.TabManager;
-import net.minecraft.client.gui.components.tabs.TabNavigationBar;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil;
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
-import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
@@ -285,7 +282,8 @@ public class YACLScreen extends Screen {
drawY,
maxWidth,
height,
- 400
+ 400/*? if >=1.21.2 {*/,
+ null/*?}*/
);
graphics.pose().translate(0.0, 0.0, 400.0);
@@ -394,19 +392,19 @@ public class YACLScreen extends Screen {
public void renderBackground(GuiGraphics graphics) {
RenderSystem.enableBlend();
// right pane darker db
- graphics.blit(DARKER_BG, rightPaneDim.left(), rightPaneDim.top(), rightPaneDim.right() + 2, rightPaneDim.bottom() + 2, rightPaneDim.width() + 2, rightPaneDim.height() + 2, 32, 32);
-
+ GuiUtils.blitGuiTex(graphics, DARKER_BG, rightPaneDim.left(), rightPaneDim.top(), rightPaneDim.right() + 2, rightPaneDim.bottom() + 2, rightPaneDim.width() + 2, rightPaneDim.height() + 2, 32, 32);
+
// top separator for right pane
graphics.pose().pushPose();
graphics.pose().translate(0, 0, 10);
- graphics.blit(CreateWorldScreen.HEADER_SEPARATOR, rightPaneDim.left() - 1, rightPaneDim.top() - 2, 0.0F, 0.0F, rightPaneDim.width() + 1, 2, 32, 2);
+ GuiUtils.blitGuiTex(graphics, CreateWorldScreen.HEADER_SEPARATOR, rightPaneDim.left() - 1, rightPaneDim.top() - 2, 0.0F, 0.0F, rightPaneDim.width() + 1, 2, 32, 2);
graphics.pose().popPose();
// left separator for right pane
graphics.pose().pushPose();
graphics.pose().translate(rightPaneDim.left(), rightPaneDim.top() - 1, 0);
graphics.pose().rotateAround(Axis.ZP.rotationDegrees(90), 0, 0, 1);
- graphics.blit(CreateWorldScreen.FOOTER_SEPARATOR, 0, 0, 0f, 0f, rightPaneDim.height() + 1, 2, 32, 2);
+ GuiUtils.blitGuiTex(graphics, CreateWorldScreen.FOOTER_SEPARATOR, 0, 0, 0f, 0f, rightPaneDim.height() + 1, 2, 32, 2);
graphics.pose().popPose();
RenderSystem.disableBlend();
diff --git a/src/main/java/dev/isxander/yacl3/gui/controllers/ColorController.java b/src/main/java/dev/isxander/yacl3/gui/controllers/ColorController.java
index 3c0a5fc..a48bdde 100644
--- a/src/main/java/dev/isxander/yacl3/gui/controllers/ColorController.java
+++ b/src/main/java/dev/isxander/yacl3/gui/controllers/ColorController.java
@@ -260,7 +260,7 @@ public class ColorController implements IStringController<Color> {
@Override
public void unfocus() {
- if(colorPickerVisible) {
+ if (colorPickerVisible) {
removeColorPicker();
}
previewOutlineFadeTicks = 0;
@@ -271,7 +271,7 @@ public class ColorController implements IStringController<Color> {
Color outlineColor = new Color(0xFF000000);
Color highlightedColor = getHighlightedOutlineColor();
- if(!hovered && !colorPreviewHovered) {
+ if (!hovered && !colorPreviewHovered) {
previewOutlineFadeTicks = 0;
return outlineColor;
}
@@ -279,11 +279,11 @@ public class ColorController implements IStringController<Color> {
int fadeInTicks = 80;
int fadeOutTicks = fadeInTicks + 120;
- if(colorPreviewHovered) {
+ if (colorPreviewHovered) {
//white/light grey if the color preview is being hovered
previewOutlineFadeTicks = 0;
return highlightedColor;
- } else if(YACLConfig.HANDLER.instance().showColorPickerIndicator) {
+ } else if (YACLConfig.HANDLER.instance().showColorPickerIndicator) {
if(previewOutlineFadeTicks <= fadeInTicks) {
//fade to white
return getFadedColor(outlineColor, highlightedColor, previewOutlineFadeTicks, fadeInTicks);
diff --git a/src/main/java/dev/isxander/yacl3/gui/controllers/ColorPickerWidget.java b/src/main/java/dev/isxander/yacl3/gui/controllers/ColorPickerWidget.java
index efa1aec..a1828f5 100644
--- a/src/main/java/dev/isxander/yacl3/gui/controllers/ColorPickerWidget.java
+++ b/src/main/java/dev/isxander/yacl3/gui/controllers/ColorPickerWidget.java
@@ -3,9 +3,11 @@ package dev.isxander.yacl3.gui.controllers;
import dev.isxander.yacl3.api.utils.Dimension;
import dev.isxander.yacl3.api.utils.MutableDimension;
import dev.isxander.yacl3.gui.YACLScreen;
+import dev.isxander.yacl3.gui.utils.GuiUtils;
import dev.isxander.yacl3.gui.utils.YACLRenderHelper;
import dev.isxander.yacl3.platform.YACLPlatform;
import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
@@ -89,7 +91,7 @@ public class ColorPickerWidget extends ControllerPopupWidget<ColorController> {
//Background
/*? if >1.20.3 {*/
- graphics.blitSprite(COLOR_PICKER_LOCATION, colorPickerDim.x() - 5, colorPickerDim.y() - 5, colorPickerDim.width() + 10, colorPickerDim.height() + 10);
+ GuiUtils.blitSprite(graphics, COLOR_PICKER_LOCATION, colorPickerDim.x() - 5, colorPickerDim.y() - 5, colorPickerDim.width() + 10, colorPickerDim.height() + 10);
/*?} else {*/
/*graphics.blitNineSliced(COLOR_PICKER_ATLAS, colorPickerDim.x() - 5, colorPickerDim.y() - 5, colorPickerDim.width() + 10, colorPickerDim.height() + 10, 3, 236, 34, 0, 0);
*//*?}*/
@@ -100,7 +102,7 @@ public class ColorPickerWidget extends ControllerPopupWidget<ColorController> {
//transparent texture - must be rendered BEFORE the main color preview
if(controller.allowAlpha()) {
/*? if >1.20.3 {*/
- graphics.blitSprite(TRANSPARENT_TEXTURE_LOCATION, previewColorDim.x(), previewColorDim.y(), previewColorDim.width(), previewColorDim.height());
+ GuiUtils.blitSprite(graphics, TRANSPARENT_TEXTURE_LOCATION, previewColorDim.x(), previewColorDim.y(), previewColorDim.width(), previewColorDim.height());
/*?} else {*/
/*graphics.blitRepeating(COLOR_PICKER_ATLAS, previewColorDim.x(), previewColorDim.y(), previewColorDim.width(), previewColorDim.height(), 236, 0, 8, 8);
*//*?}*/
@@ -112,7 +114,9 @@ public class ColorPickerWidget extends ControllerPopupWidget<ColorController> {
//outline
graphics.fill(saturationLightDim.x() - outline, saturationLightDim.y() - outline, saturationLightDim.xLimit() + outline, saturationLightDim.yLimit() + outline, Color.black.getRGB());
//White to pending color's RGB from hue, left to right
- fillSidewaysGradient(graphics, saturationLightDim.x(), saturationLightDim.y(), saturationLightDim.xLimit(), saturationLightDim.yLimit(), 0xFFFFFFFF, (int) getRgbFromHueX());
+ GuiUtils.drawSpecial(graphics, bufferSource -> {
+ fillSidewaysGradient(graphics, saturationLightDim.x(), saturationLightDim.y(), saturationLightDim.xLimit(), saturationLightDim.yLimit(), 0xFFFFFFFF, (int) getRgbFromHueX(), bufferSource.getBuffer(RenderType.gui()));
+ });
//Transparent to black, top to bottom
graphics.fillGradient(saturationLightDim.x(), saturationLightDim.y(), saturationLightDim.xLimit(), saturationLightDim.yLimit(), 0x00000000, 0xFF000000);
//Sat/light thumb shadow
@@ -135,12 +139,14 @@ public class ColorPickerWidget extends ControllerPopupWidget<ColorController> {
graphics.fill(alphaGradientDim.x() - outline, alphaGradientDim.y() - outline, alphaGradientDim.xLimit() + outline, alphaGradientDim.yLimit() + outline, Color.black.getRGB());
//Transparent texture
/*? if >1.20.3 {*/
- graphics.blitSprite(TRANSPARENT_TEXTURE_LOCATION, alphaGradientDim.x(), alphaGradientDim.y(), alphaGradientDim.width(), sliderHeight);
+ GuiUtils.blitSprite(graphics, TRANSPARENT_TEXTURE_LOCATION, alphaGradientDim.x(), alphaGradientDim.y(), alphaGradientDim.width(), sliderHeight);
/*?} else {*/
/*graphics.blitRepeating(COLOR_PICKER_ATLAS, alphaGradientDim.x(), alphaGradientDim.y(), alphaGradientDim.width(), sliderHeight, 236, 0, 8, 8);
*//*?}*/
//Pending color to transparent
- fillSidewaysGradient(graphics, alphaGradientDim.x(), alphaGradientDim.y(), alphaGradientDim.xLimit(), alphaGradientDim.yLimit(), getRgbWithoutAlpha(), 0x00000000);
+ GuiUtils.drawSpecial(graphics, bufferSource -> {
+ fillSidewaysGradient(graphics, alphaGradientDim.x(), alphaGradientDim.y(), alphaGradientDim.xLimit(), alphaGradientDim.yLimit(), getRgbWithoutAlpha(), 0x00000000, bufferSource.getBuffer(RenderType.gui()));
+ });
//Alpha slider thumb shadow
graphics.fill(alphaThumbX - thumbWidth / 2 - 1, alphaGradientDim.y() - outline - 1, alphaThumbX + thumbWidth / 2 + 1, alphaGradientDim.yLimit() + outline + 1, 0xFF404040);
//Alpha slider thumb
diff --git a/src/main/java/dev/isxander/yacl3/gui/controllers/LabelController.java b/src/main/java/dev/isxander/yacl3/gui/controllers/LabelController.java
index fee6c19..9f38d3b 100644
--- a/