aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-05-16 17:04:51 +0100
committerisXander <xandersmith2008@gmail.com>2023-05-16 17:04:51 +0100
commit4f1bba3f51de1f544b239e7eac740eab5832dc5b (patch)
tree72357adf401c2f0c2962eba59d2a793ba238a182
parent5b368af9efcc1c587c608d014e9dc79bcc3c691c (diff)
downloadYetAnotherConfigLib-4f1bba3f51de1f544b239e7eac740eab5832dc5b.tar.gz
YetAnotherConfigLib-4f1bba3f51de1f544b239e7eac740eab5832dc5b.tar.bz2
YetAnotherConfigLib-4f1bba3f51de1f544b239e7eac740eab5832dc5b.zip
1.20
-rw-r--r--common/build.gradle.kts7
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java19
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java15
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java20
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java7
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java39
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java7
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java14
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java5
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java36
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java4
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java11
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java44
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java27
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java19
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java16
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java30
-rw-r--r--common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java20
-rw-r--r--fabric/build.gradle.kts4
-rw-r--r--fabric/src/main/resources/fabric.mod.json2
-rw-r--r--forge/build.gradle.kts5
-rw-r--r--gradle.properties2
-rw-r--r--gradle/libs.versions.toml10
-rw-r--r--settings.gradle.kts16
-rw-r--r--test-common/build.gradle.kts7
-rw-r--r--test-fabric/build.gradle.kts4
-rw-r--r--test-forge/build.gradle.kts6
27 files changed, 204 insertions, 192 deletions
diff --git a/common/build.gradle.kts b/common/build.gradle.kts
index fb79bd1..f725a17 100644
--- a/common/build.gradle.kts
+++ b/common/build.gradle.kts
@@ -7,7 +7,8 @@ base {
}
architectury {
- common("fabric", "forge")
+ val enabledLoaders = rootProject.properties["loaders"].toString().split(",").map { it.trim() }
+ common(enabledLoaders)
}
loom {
@@ -19,7 +20,9 @@ loom {
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
- mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
+ val qm = libs.versions.quilt.mappings.get()
+ if (qm != "0")
+ mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
officialMojangMappings()
})
modImplementation(libs.fabric.loader)
diff --git a/common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java b/common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java
index ae3c83b..a34b3fa 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java
@@ -1,16 +1,13 @@
package dev.isxander.yacl.gui;
-import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.PoseStack;
import dev.isxander.yacl.api.utils.Dimension;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
-import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.narration.NarrationElementOutput;
-import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.sounds.SoundEvents;
@@ -27,7 +24,7 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na
this.dim = dim;
}
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
}
@@ -67,7 +64,7 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na
}
- protected void drawButtonRect(PoseStack matrices, int x1, int y1, int x2, int y2, boolean hovered, boolean enabled) {
+ protected void drawButtonRect(GuiGraphics graphics, int x1, int y1, int x2, int y2, boolean hovered, boolean enabled) {
if (x1 > x2) {
int xx1 = x1;
x1 = x2;
@@ -81,15 +78,9 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na
int width = x2 - x1;
int height = y2 - y1;
- RenderSystem.setShader(GameRenderer::getPositionTexShader);
- RenderSystem.setShaderTexture(0, net.minecraft.client.gui.components.AbstractWidget.WIDGETS_LOCATION);
- RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
int i = !enabled ? 0 : hovered ? 2 : 1;
- RenderSystem.enableBlend();
- RenderSystem.defaultBlendFunc();
- RenderSystem.enableDepthTest();
- GuiComponent.blit(matrices, x1, y1, 0, 0, 46 + i * 20, width / 2, height, 256, 256);
- GuiComponent.blit(matrices, x1 + width / 2, y1, 0, 200 - width / 2f, 46 + i * 20, width / 2, height, 256, 256);
+ graphics.blit(net.minecraft.client.gui.components.AbstractWidget.WIDGETS_LOCATION, x1, y1, 0, 0, 46 + i * 20, width / 2, height, 256, 256);
+ graphics.blit(net.minecraft.client.gui.components.AbstractWidget.WIDGETS_LOCATION, x1 + width / 2, y1, 0, 200 - width / 2f, 46 + i * 20, width / 2, height, 256, 256);
}
protected int multiplyColor(int hex, float amount) {
diff --git a/common/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java b/common/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java
index 41286ff..6668584 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java
@@ -6,6 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import dev.isxander.yacl.api.ConfigCategory;
import dev.isxander.yacl.gui.utils.GuiUtils;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
@@ -26,9 +27,9 @@ public class CategoryListWidget extends ElementListWidgetExt<CategoryListWidget.
}
@Override
- public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
GuiUtils.enableScissor(0, 0, width, height);
- super.render(matrices, mouseX, mouseY, delta);
+ super.render(graphics, mouseX, mouseY, delta);
RenderSystem.disableScissor();
}
@@ -48,7 +49,7 @@ public class CategoryListWidget extends ElementListWidgetExt<CategoryListWidget.
}
@Override
- protected void renderBackground(PoseStack matrices) {
+ protected void renderBackground(GuiGraphics graphics) {
}
@@ -68,17 +69,17 @@ public class CategoryListWidget extends ElementListWidgetExt<CategoryListWidget.
}
@Override
- public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
+ public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
if (mouseY > y1) {
mouseY = -20;
}
categoryButton.setY(y);
- categoryButton.render(matrices, mouseX, mouseY, tickDelta);
+ categoryButton.render(graphics, mouseX, mouseY, tickDelta);
}
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float tickDelta) {
- categoryButton.renderHoveredTooltip(matrices);
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float tickDelta) {
+ categoryButton.renderHoveredTooltip(graphics);
}
@Override
diff --git a/common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java b/common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java
index b177236..cb9fc87 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/ElementListWidgetExt.java
@@ -1,8 +1,8 @@
package dev.isxander.yacl.gui;
import com.mojang.blaze3d.platform.InputConstants;
-import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.util.Mth;
@@ -31,11 +31,11 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
}
@Override
- protected void renderBackground(PoseStack matrices) {
+ protected void renderBackground(GuiGraphics graphics) {
// render transparent background if in-game.
setRenderBackground(minecraft.level == null);
if (minecraft.level != null)
- fill(matrices, x0, y0, x1, y1, 0x6B000000);
+ graphics.fill(x0, y0, x1, y1, 0x6B000000);
}
@Override
@@ -45,10 +45,10 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
}
@Override
- public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
smoothScrollAmount = Mth.lerp(Minecraft.getInstance().getDeltaFrameTime() * 0.5, smoothScrollAmount, getScrollAmount());
returnSmoothAmount = true;
- super.render(matrices, mouseX, mouseY, delta);
+ super.render(graphics, mouseX, mouseY, delta);
returnSmoothAmount = false;
}
@@ -68,9 +68,9 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
this.smoothScrollAmount = getScrollAmount();
}
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
for (E entry : children()) {
- entry.postRender(matrices, mouseX, mouseY, delta);
+ entry.postRender(graphics, mouseX, mouseY, delta);
}
}
@@ -123,7 +123,7 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
}
@Override
- protected void renderList(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void renderList(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
int left = this.getRowLeft();
int right = this.getRowWidth();
int count = this.getItemCount();
@@ -134,7 +134,7 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
int bottom = top + entry.getItemHeight();
int entryHeight = entry.getItemHeight() - 4;
if (bottom >= this.y0 && top <= this.y1) {
- this.renderItem(matrices, mouseX, mouseY, delta, i, left, top, right, entryHeight);
+ this.renderItem(graphics, mouseX, mouseY, delta, i, left, top, right, entryHeight);
}
}
}
@@ -166,7 +166,7 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
return false;
}
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java b/common/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java
index e8bf59f..f002e82 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java
@@ -2,6 +2,7 @@ package dev.isxander.yacl.gui;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.network.chat.Component;
@@ -17,12 +18,12 @@ public class LowProfileButtonWidget extends Button {
}
@Override
- public void renderWidget(PoseStack matrices, int mouseX, int mouseY, float deltaTicks) {
+ public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float deltaTicks) {
if (!isHoveredOrFocused() || !active) {
int j = this.active ? 0xFFFFFF : 0xA0A0A0;
- this.renderString(matrices, Minecraft.getInstance().font, j);
+ this.renderString(graphics, Minecraft.getInstance().font, j);
} else {
- super.renderWidget(matrices, mouseX, mouseY, deltaTicks);
+ super.renderWidget(graphics, mouseX, mouseY, deltaTicks);
}
}
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java b/common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
index d2d1b71..fc7c317 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java
@@ -8,6 +8,7 @@ import dev.isxander.yacl.impl.utils.YACLConstants;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
@@ -284,20 +285,20 @@ public class OptionListWidget extends ElementListWidgetExt<OptionListWidget.Entr
}
@Override
- public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
+ public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
widget.setDimension(widget.getDimension().withY(y));
- widget.render(matrices, mouseX, mouseY, tickDelta);
+ widget.render(graphics, mouseX, mouseY, tickDelta);
if (resetButton != null) {
resetButton.setY(y);
- resetButton.render(matrices, mouseX, mouseY, tickDelta);
+ resetButton.render(graphics, mouseX, mouseY, tickDelta);
}
}
@Override
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
- widget.postRender(matrices, mouseX, mouseY, delta);
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
+ widget.postRender(graphics, mouseX, mouseY, delta);
}
@Override
@@ -379,22 +380,22 @@ public class OptionListWidget extends ElementListWidgetExt<OptionListWidget.Entr
}
@Override
- public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
+ public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
this.y = y;
int buttonY = y + entryHeight / 2 - expandMinimizeButton.getHeight() / 2 + 1;
expandMinimizeButton.setY(buttonY);
expandMinimizeButton.setX(x);
- expandMinimizeButton.render(matrices, mouseX, mouseY, tickDelta);
+ expandMinimizeButton.render(graphics, mouseX, mouseY, tickDelta);
- wrappedName.renderCentered(matrices, x + entryWidth / 2, y + getYPadding());
+ wrappedName.renderCentered(graphics, x + entryWidth / 2, y + getYPadding());
}
@Override
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
if ((isHovered() && !expandMinimizeButton.isMouseOver(mouseX, mouseY)) || expandMinimizeButton.isFocused()) {
- YACLScreen.renderMultilineTooltip(matrices, font, wrappedTooltip, getRowLeft() + getRowWidth() / 2, y - 3, y + getItemHeight() + 3, screen.width, screen.height);
+ YACLScreen.renderMultilineTooltip(graphics, font, wrappedTooltip, getRowLeft() + getRowWidth() / 2, y - 3, y + getItemHeight() + 3, screen.width, screen.height);
}
}
@@ -485,27 +486,27 @@ public class OptionListWidget extends ElementListWidgetExt<OptionListWidget.Entr
}
@Override
- public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
+ public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
updateExpandMinimizeText(); // update every render because option could become available/unavailable at any time
- super.render(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
+ super.render(graphics, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
int buttonY = expandMinimizeButton.getY();
resetListButton.setY(buttonY);
addListButton.setY(buttonY);
- resetListButton.render(matrices, mouseX, mouseY, tickDelta);
- addListButton.render(matrices, mouseX, mouseY, tickDelta);
+ resetListButton.render(graphics, mouseX, mouseY, tickDelta);
+ addListButton.render(graphics, mouseX, mouseY, tickDelta);
}
@Override
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
minimizeIfUnavailable(); // cannot run in render because it *should* cause a ConcurrentModificationException (but doesn't)
- super.postRender(matrices, mouseX, mouseY, delta);
+ super.postRender(graphics, mouseX, mouseY, delta);
- addListButton.renderHoveredTooltip(matrices);
+ addListButton.renderHoveredTooltip(graphics);
}
private void minimizeIfUnavailable() {
@@ -540,8 +541,8 @@ public class OptionListWidget extends ElementListWidgetExt<OptionListWidget.Entr
}
@Override
- public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
- drawCenteredString(matrices, Minecraft.getInstance().font, Component.translatable("yacl.list.empty").withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC), x + entryWidth / 2, y, -1);
+ public void render(GuiGraphics graphics, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
+ graphics.drawCenteredString(Minecraft.getInstance().font, Component.translatable("yacl.list.empty").withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC), x + entryWidth / 2, y, -1);
}
@Override
diff --git a/common/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java b/common/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java
index 5cf38e0..fb098a9 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java
@@ -2,6 +2,7 @@ package dev.isxander.yacl.gui;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
@@ -22,10 +23,10 @@ public class SearchFieldWidget extends EditBox {
}
@Override
- public void renderWidget(PoseStack matrices, int mouseX, int mouseY, float delta) {
- super.renderWidget(matrices, mouseX, mouseY, delta);
+ public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
+ super.renderWidget(graphics, mouseX, mouseY, delta);
if (isVisible() && isEmpty()) {
- font.drawShadow(matrices, emptyText, getX() + 4, this.getY() + (this.height - 8) / 2f, 0x707070);
+ graphics.drawString(font, emptyText, getX() + 4, this.getY() + (this.height - 8) / 2, 0x707070, true);
}
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java b/common/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
index ac58db6..277e5f9 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java
@@ -3,6 +3,7 @@ package dev.isxander.yacl.gui;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
@@ -20,13 +21,14 @@ public class TextScaledButtonWidget extends TooltipButtonWidget {
}
@Override
- public void renderString(PoseStack matrices, Font textRenderer, int color) {
+ public void renderString(GuiGraphics graphics, Font textRenderer, int color) {
Font font = Minecraft.getInstance().font;
+ PoseStack pose = graphics.pose();
- matrices.pushPose();
- matrices.translate(((this.getX() + this.width / 2f) - font.width(getMessage()) * textScale / 2), (float)this.getY() + (this.height - 8 * textScale) / 2f / textScale, 0);
- matrices.scale(textScale, textScale, 1);
- font.drawShadow(matrices, getMessage(), 0, 0, color | Mth.ceil(this.alpha * 255.0F) << 24);
- matrices.popPose();
+ pose.pushPose();
+ pose.translate(((this.getX() + this.width / 2f) - font.width(getMessage()) * textScale / 2), (float)this.getY() + (this.height - 8 * textScale) / 2f / textScale, 0);
+ pose.scale(textScale, textScale, 1);
+ graphics.drawString(font, getMessage(), 0, 0, color | Mth.ceil(this.alpha * 255.0F) << 24, true);
+ pose.popPose();
}
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java b/common/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java
index c8f3cf2..824ff86 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java
@@ -2,6 +2,7 @@ package dev.isxander.yacl.gui;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.screens.Screen;
@@ -19,9 +20,9 @@ public class TooltipButtonWidget extends Button {
setTooltip(tooltip);
}
- public void renderHoveredTooltip(PoseStack matrices) {
+ public void renderHoveredTooltip(GuiGraphics graphics) {
if (isHoveredOrFocused() && wrappedDescription != null) {
- YACLScreen.renderMultilineTooltip(matrices, Minecraft.getInstance().font, wrappedDescription, getX() + width / 2, getY() - 4, getY() + height + 4, screen.width, screen.height);
+ YACLScreen.renderMultilineTooltip(graphics, Minecraft.getInstance().font, wrappedDescription, getX() + width / 2, getY() - 4, getY() + height + 4, screen.width, screen.height);
}
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
index 3600e61..b3e614f 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
@@ -13,7 +13,7 @@ import dev.isxander.yacl.gui.utils.GuiUtils;
import dev.isxander.yacl.impl.utils.YACLConstants;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.Font;
-import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
@@ -21,7 +21,6 @@ import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
-import org.joml.Matrix4f;
import java.util.HashSet;
import java.util.Set;
@@ -116,20 +115,20 @@ public class YACLScreen extends Screen {
}
@Override
- public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
- renderBackground(matrices);
+ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
+ renderBackground(graphics);
- super.render(matrices, mouseX, mouseY, delta);
- categoryList.render(matrices, mouseX, mouseY, delta);
- searchFieldWidget.render(matrices, mouseX, mouseY, delta);
- optionList.render(matrices, mouseX, mouseY, delta);
+ super.render(graphics, mouseX, mouseY, delta);
+ categoryList.render(graphics, mouseX, mouseY, delta);
+ searchFieldWidget.render(graphics, mouseX, mouseY, delta);
+ optionList.render(graphics, mouseX, mouseY, delta);
- categoryList.postRender(matrices, mouseX, mouseY, delta);
- optionList.postRender(matrices, mouseX, mouseY, delta);
+ categoryList.postRender(graphics, mouseX, mouseY, delta);
+ optionList.postRender(graphics, mouseX, mouseY, delta);
for (GuiEventListener child : children()) {
if (child instanceof TooltipButtonWidget tooltipButtonWidget) {
- tooltipButtonWidget.renderHoveredTooltip(matrices);
+ tooltipButtonWidget.renderHoveredTooltip(graphics);
}
}
}
@@ -269,7 +268,7 @@ public class YACLScreen extends Screen {
minecraft.setScreen(parent);
}
- public static void renderMultilineTooltip(PoseStack matrices, Font font, MultiLineLabel text, int centerX, int yAbove, int yBelow, int screenWidth, int screenHeight) {
+ public static void renderMultilineTooltip(GuiGraphics graphics, Font font, MultiLineLabel text, int centerX, int yAbove, int yBelow, int screenWidth, int screenHeight) {
if (text.getLineCount() > 0) {
int maxWidth = text.getWidth();
int lineHeight = font.lineHeight + 1;
@@ -288,16 +287,13 @@ public class YACLScreen extends Screen {
int drawX = x + 12;
int drawY = y - 12;
- matrices.pushPose();
+ graphics.pose().pushPose();
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferBuilder = tesselator.getBuilder();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
- Matrix4f matrix4f = matrices.last().pose();
TooltipRenderUtil.renderTooltipBackground(
- GuiComponent::fillGradient,
- matrix4f,
- bufferBuilder,
+ graphics,
drawX,
drawY,
maxWidth,
@@ -309,11 +305,11 @@ public class YACLScreen extends Screen {
RenderSystem.defaultBlendFunc();
BufferUploader.drawWithShader(bufferBuilder.end());
RenderSystem.disableBlend();
- matrices.translate(0.0, 0.0, 400.0);
+ graphics.pose().translate(0.0, 0.0, 400.0);
- text.renderLeftAligned(matrices, drawX, drawY, lineHeight, -1);
+ text.renderLeftAligned(graphics, drawX, drawY, lineHeight, -1);
- matrices.popPose();
+ graphics.pose().popPose();
}
}
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java
index d7d17d5..1c395d6 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/BooleanController.java
@@ -1,13 +1,13 @@
package dev.isxander.yacl.gui.controllers;
import com.mojang.blaze3d.platform.InputConstants;
-import com.mojang.blaze3d.vertex.PoseStack;
import dev.isxander.yacl.api.Controller;
import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.AbstractWidget;
import dev.isxander.yacl.gui.YACLScreen;
import net.minecraft.ChatFormatting;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
@@ -108,7 +108,7 @@ public class BooleanController implements Controller<Boolean> {
}
@Override
- protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java
index 3cbce40..4f71248 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/ColorController.java
@@ -1,7 +1,6 @@
package dev.isxander.yacl.gui.controllers;
import com.google.common.collect.ImmutableList;
-import com.mojang.blaze3d.vertex.PoseStack;
import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.api.utils.MutableDimension;
@@ -10,7 +9,7 @@ import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.gui.controllers.string.IStringController;
import dev.isxander.yacl.gui.controllers.string.StringControllerElement;
import net.minecraft.ChatFormatting;
-import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
@@ -114,14 +113,14 @@ public class ColorController implements IStringController<Color> {
}
@Override
- protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
if (isHovered()) {
colorPreviewDim.move(-inputFieldBounds.width() - 5, 0);
- super.drawValueText(matrices, mouseX, mouseY, delta);
+ super.drawValueText(graphics, mouseX, mouseY, delta);
}
- GuiComponent.fill(matrices, colorPreviewDim.x(), colorPreviewDim.y(), colorPreviewDim.xLimit(), colorPreviewDim.yLimit(), colorController.option().pendingValue().getRGB());
- drawOutline(matrices, colorPreviewDim.x(), colorPreviewDim.y(), colorPreviewDim.xLimit(), colorPreviewDim.yLimit(), 1, 0xFF000000);
+ graphics.fill(colorPreviewDim.x(), colorPreviewDim.y(), colorPreviewDim.xLimit(), colorPreviewDim.yLimit(), colorController.option().pendingValue().getRGB());
+ drawOutline(graphics, colorPreviewDim.x(), colorPreviewDim.y(), colorPreviewDim.xLimit(), colorPreviewDim.yLimit(), 1, 0xFF000000);
}
@Override
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java
index 22c469d..232dddb 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/ControllerWidget.java
@@ -1,6 +1,5 @@
package dev.isxander.yacl.gui.controllers;
-import com.mojang.blaze3d.vertex.PoseStack;
import dev.isxander.yacl.api.Controller;
import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.AbstractWidget;
@@ -8,7 +7,7 @@ import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.gui.utils.GuiUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.ComponentPath;
-import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.narration.NarratedElementType;
import net.minecraft.client.gui.narration.NarrationElementOutput;
@@ -38,41 +37,36 @@ public abstract class ControllerWidget<T extends Controller<?>> extends Abstract
}
@Override
- public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
hovered = isMouseOver(mouseX, mouseY);
Component name = control.option().changed() ? modifiedOptionName : control.option().name();
Component shortenedName = Component.literal(GuiUtils.shortenString(name.getString(), textRenderer, getDimension().width() - getControlWidth() - getXPadding() - 7, "...")).setStyle(name.getStyle());
- drawButtonRect(matrices, getDimension().x(), getDimension().y(), getDimension().xLimit(), getDimension().yLimit(), isHovered(), isAvailable());
- matrices.pushPose();
- matrices.translate(getDimension().x() + getXPadding(), getTextY(), 0);
- textRenderer.drawShadow(matrices, shortenedName, 0, 0, getValueColor());
- matrices.popPose();
+ drawButtonRect(graphics, getDimension().x(), getDimension().y(), getDimension().xLimit(), getDimension().yLimit(), isHovered(), isAvailable());
+ graphics.drawString(textRenderer, shortenedName, getDimension().x() + getXPadding(), getTextY(), getValueColor(), true);
- drawValueText(matrices, mouseX, mouseY, delta);
+
+ drawValueText(graphics, mouseX, mouseY, delta);
if (isHovered()) {
- drawHoveredControl(matrices, mouseX, mouseY, delta);
+ drawHoveredControl(graphics, mouseX, mouseY, delta);
}
}
@Override
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
if (hovered || focused) {
- YACLScreen.renderMultilineTooltip(matrices, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height);
+ YACLScreen.renderMultilineTooltip(graphics, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height);
}
}
- protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
}
- protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
Component valueText = getValueText();
- matrices.pushPose();
- matrices.translate(getDimension().xLimit() - textRenderer.width(valueText) - getXPadding(), getTextY(), 0);
- textRenderer.drawShadow(matrices, valueText, 0, 0, getValueColor());
- matrices.popPose();
+ graphics.drawString(textRenderer, valueText, getDimension().xLimit() - textRenderer.width(valueText) - getXPadding(), getTextY(), getValueColor(), true);
}
private void updateTooltip() {
@@ -118,15 +112,15 @@ public abstract class ControllerWidget<T extends Controller<?>> extends Abstract
return true;
}
- protected void drawOutline(PoseStack matrices, int x1, int y1, int x2, int y2, int width, int color) {
- GuiComponent.fill(matrices, x1, y1, x2, y1 + width, color);
- GuiComponent.fill(matrices, x2, y1, x2 - width, y2, color);
- GuiComponent.fill(matrices, x1, y2, x2, y2 - width, color);
- GuiComponent.fill(matrices, x1, y1, x1 + width, y2, color);
+ protected void drawOutline(GuiGraphics graphics, int x1, int y1, int x2, int y2, int width, int color) {
+ graphics.fill(x1, y1, x2, y1 + width, color);
+ graphics.fill(x2, y1, x2 - width, y2, color);
+ graphics.fill(x1, y2, x2, y2 - width, color);
+ graphics.fill(x1, y1, x1 + width, y2, color);
}
- protected float getTextY() {
- return getDimension().y() + getDimension().height() / 2f - textRenderer.lineHeight / 2f;
+ protected int getTextY() {
+ return (int)(getDimension().y() + getDimension().height() / 2f - textRenderer.lineHeight / 2f);
}
@Nullable
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java
index 1dfae0b..a55a255 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/LabelController.java
@@ -7,11 +7,12 @@ import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.AbstractWidget;
import dev.isxander.yacl.gui.YACLScreen;
import net.minecraft.client.gui.ComponentPath;
-import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.narration.NarratedElementType;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
+import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.Style;
@@ -69,27 +70,27 @@ public class LabelController implements Controller<Component> {
}
@Override
- public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
updateText();
- float y = getDimension().y();
+ int y = getDimension().y();
for (FormattedCharSequence text : wrappedText) {
- textRenderer.drawShadow(matrices, text, getDimension().x() + getXPadding(), y + getYPadding(), option().available() ? -1 : 0xFFA0A0A0);
+ graphics.drawString(textRenderer, text, getDimension().x() + getXPadding(), y + getYPadding(), option().available() ? -1 : 0xFFA0A0A0, true);
y += textRenderer.lineHeight;
}
if (isFocused()) {
- GuiComponent.fill(matrices, getDimension().x() - 1, getDimension().y() - 1, getDimension().xLimit() + 1, getDimension().y(), -1);
- GuiComponent.fill(matrices, getDimension().x() - 1, getDimension().y() - 1, getDimension().x(), getDimension().yLimit() + 1, -1);
- GuiComponent.fill(matrices, getDimension().x() - 1, getDimension().yLimit(), getDimension().xLimit() + 1, getDimension().yLimit() + 1, -1);
- GuiComponent.fill(matrices, getDimension().xLimit(), getDimension().y() - 1, getDimension().xLimit() + 1, getDimension().yLimit() + 1, -1);
+ graphics.fill(getDimension().x() - 1, getDimension().y() - 1, getDimension().xLimit() + 1, getDimension().y(), -1);
+ graphics.fill(getDimension().x() - 1, getDimension().y() - 1, getDimension().x(), getDimension().yLimit() + 1, -1);
+ graphics.fill(getDimension().x() - 1, getDimension().yLimit(), getDimension().xLimit() + 1, getDimension().yLimit() + 1, -1);
+ graphics.fill(getDimension().xLimit(), getDimension().y() - 1, getDimension().xLimit() + 1, getDimension().yLimit() + 1, -1);
}
}
@Override
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
if (isMouseOver(mouseX, mouseY)) {
- YACLScreen.renderMultilineTooltip(matrices, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height);
+ YACLScreen.renderMultilineTooltip(graphics, textRenderer, wrappedTooltip, getDimension().centerX(), getDimension().y() - 5, getDimension().yLimit() + 5, screen.width, screen.height);
Style style = getStyle(mouseX, mouseY);
if (style != null && style.getHoverEvent() != null) {
@@ -97,18 +98,18 @@ public class LabelController implements Controller<Component> {
HoverEvent.ItemStackInfo itemStackContent = hoverEvent.getValue(HoverEvent.Action.SHOW_ITEM);
if (itemStackContent != null) {
ItemStack stack = itemStackContent.getItemStack();
- screen.renderTooltip(matrices, screen.getTooltipFromItem(stack), stack.getTooltipImage(), mouseX, mouseY);
+ graphics.renderTooltip(textRenderer, Screen.getTooltipFromItem(client, stack), stack.getTooltipImage(), mouseX, mouseY);
} else {
HoverEvent.EntityTooltipInfo entityContent = hoverEvent.getValue(HoverEvent.Action.SHOW_ENTITY);
if (entityContent != null) {
if (this.client.options.advancedItemTooltips) {
- screen.renderComponentTooltip(matrices, entityContent.getTooltipLines(), mouseX, mouseY);
+ graphics.renderComponentTooltip(textRenderer, entityContent.getTooltipLines(), mouseX, mouseY);
}
} else {
Component text = hoverEvent.getValue(HoverEvent.Action.SHOW_TEXT);
if (text != null) {
MultiLineLabel multilineText = MultiLineLabel.create(textRenderer, text, getDimension().width());
- YACLScreen.renderMultilineTooltip(matrices, textRenderer, multilineText, getDimension().centerX(), getDimension().y(), getDimension().yLimit(), screen.width, screen.height);
+ YACLScreen.renderMultilineTooltip(graphics, textRenderer, multilineText, getDimension().centerX(), getDimension().y(), getDimension().yLimit(), screen.width, screen.height);
}
}
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java
index c3f674d..2156dcc 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/ListEntryWidget.java
@@ -8,6 +8,7 @@ import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.AbstractWidget;
import dev.isxander.yacl.gui.TooltipButtonWidget;
import dev.isxander.yacl.gui.YACLScreen;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.events.ContainerEventHandler;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarrationElementOutput;
@@ -65,7 +66,7 @@ public class ListEntryWidget extends AbstractWidget implements ContainerEventHan
}
@Override
- public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
updateButtonStates(); // update every render in case option becomes available/unavailable
removeButton.setY(getDimension().y());
@@ -73,17 +74,17 @@ public class ListEntryWidget extends AbstractWidget implements ContainerEventHan
moveDownButton.setY(getDimension().y());
entryWidget.setDimension(entryWidget.getDimension().withY(getDimension().y()));
- removeButton.render(matrices, mouseX, mouseY, delta);
- moveUpButton.render(matrices, mouseX, mouseY, delta);
- moveDownButton.render(matrices, mouseX, mouseY, delta);
- entryWidget.render(matrices, mouseX, mouseY, delta);
+ removeButton.render(graphics, mouseX, mouseY, delta);
+ moveUpButton.render(graphics, mouseX, mouseY, delta);
+ moveDownButton.render(graphics, mouseX, mouseY, delta);
+ entryWidget.render(graphics, mouseX, mouseY, delta);
}
@Override
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
- removeButton.renderHoveredTooltip(matrices);
- moveUpButton.renderHoveredTooltip(matrices);
- moveDownButton.renderHoveredTooltip(matrices);
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
+ removeButton.renderHoveredTooltip(graphics);
+ moveUpButton.renderHoveredTooltip(graphics);
+ moveDownButton.renderHoveredTooltip(graphics);
}
protected void updateButtonStates() {
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java
index 3f615db..31200b6 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/TickBoxController.java
@@ -7,7 +7,7 @@ import dev.isxander.yacl.api.Option;
import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.AbstractWidget;
import dev.isxander.yacl.gui.YACLScreen;
-import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
/**
@@ -55,7 +55,7 @@ public class TickBoxController implements Controller<Boolean> {
}
@Override
- protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
int outlineSize = 10;
int outlineX1 = getDimension().xLimit() - getXPadding() - outlineSize;
int outlineY1 = getDimension().centerY() - outlineSize / 2;
@@ -65,18 +65,18 @@ public class TickBoxController implements Controller<Boolean> {
int color = getValueColor();
int shadowColor = multiplyColor(color, 0.25f);
- drawOutline(matrices, outlineX1 + 1, outlineY1 + 1, outlineX2 + 1, outlineY2 + 1, 1, shadowColor);
- drawOutline(matrices, outlineX1, outlineY1, outlineX2, outlineY2, 1, color);
+ drawOutline(graphics, outlineX1 + 1, outlineY1 + 1, outlineX2 + 1, outlineY2 + 1, 1, shadowColor);
+ drawOutline(graphics, outlineX1, outlineY1, outlineX2, outlineY2, 1, color);
if (control.option().pendingValue()) {
- GuiComponent.fill(matrices, outlineX1 + 3, outlineY1 + 3, outlineX2 - 1, outlineY2 - 1, shadowColor);
- GuiComponent.fill(matrices, outlineX1 + 2, outlineY1 + 2, outlineX2 - 2, outlineY2 - 2, color);
+ graphics.fill(outlineX1 + 3, outlineY1 + 3, outlineX2 - 1, outlineY2 - 1, shadowColor);
+ graphics.fill(outlineX1 + 2, outlineY1 + 2, outlineX2 - 2, outlineY2 - 2, color);
}
}
@Override
- protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
if (!isHovered())
- drawHoveredControl(matrices, mouseX, mouseY, delta);
+ drawHoveredControl(graphics, mouseX, mouseY, delta);
}
@Override
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java
index d00f3d7..b60de07 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/slider/SliderControllerElement.java
@@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.gui.controllers.ControllerWidget;
-import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.util.Mth;
@@ -27,32 +27,32 @@ public class SliderControllerElement extends ControllerWidget<ISliderController<
}
@Override
- public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
- super.render(matrices, mouseX, mouseY, delta);
+ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
+ super.render(graphics, mouseX, mouseY, delta);
calculateInterpolation();
}
@Override
- protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
// track
- GuiComponent.fill(matrices, sliderBounds.x(), sliderBounds.centerY() - 1, sliderBounds.xLimit(), sliderBounds.centerY(), -1);
+ graphics.fill(sliderBounds.x(), sliderBounds.centerY() - 1, sliderBounds.xLimit(), sliderBounds.centerY(), -1);
// track shadow
- GuiComponent.fill(matrices, sliderBounds.x() + 1, sliderBounds.centerY(), sliderBounds.xLimit() + 1, sliderBounds.centerY() + 1, 0xFF404040);
+ graphics.fill(sliderBounds.x() + 1, sliderBounds.centerY(), sliderBounds.xLimit() + 1, sliderBounds.centerY() + 1, 0xFF404040);
// thumb shadow
- GuiComponent.fill(matrices, getThumbX() - getThumbWidth() / 2 + 1, sliderBounds.y() + 1, getThumbX() + getThumbWidth() / 2 + 1, sliderBounds.yLimit() + 1, 0xFF404040);
+ graphics.fill(getThumbX() - getThumbWidth() / 2 + 1, sliderBounds.y() + 1, getThumbX() + getThumbWidth() / 2 + 1, sliderBounds.yLimit() + 1, 0xFF404040);
// thumb
- GuiComponent.fill(matrices, getThumbX() - getThumbWidth() / 2, sliderBounds.y(), getThumbX() + getThumbWidth() / 2, sliderBounds.yLimit(), -1);
+ graphics.fill(getThumbX() - getThumbWidth() / 2, sliderBounds.y(), getThumbX() + getThumbWidth() / 2, sliderBounds.yLimit(), -1);
}
@Override
- protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) {
- matrices.pushPose();
+ protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
+ graphics.pose().pushPose();
if (isHovered())
- matrices.translate(-(sliderBounds.width() + 6 + getThumbWidth() / 2f), 0, 0);
- super.drawValueText(matrices, mouseX, mouseY, delta);
- matrices.popPose();
+ graphics.pose().translate(-(sliderBounds.width() + 6 + getThumbWidth() / 2f), 0, 0);
+ super.drawValueText(graphics, mouseX, mouseY, delta);
+ graphics.pose().popPose();
}
@Override
@@ -157,8 +157,8 @@ public class SliderControllerElement extends ControllerWidget<ISliderController<
}
@Override
- public void postRender(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ public void postRender(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
if (super.isMouseOver(mouseX, mouseY) || focused)
- super.postRender(matrices, mouseX, mouseY, delta);
+ super.postRender(graphics, mouseX, mouseY, delta);
}
}
diff --git a/common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java b/common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java
index cb2ad4e..08c3275 100644
--- a/common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java
+++ b/common/src/main/java/dev/isxander/yacl/gui/controllers/string/StringControllerElement.java
@@ -2,13 +2,12 @@ package dev.isxander.yacl.gui.controllers.string;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.PoseStack;
import dev.isxander.yacl.api.utils.Dimension;
import dev.isxander.yacl.gui.YACLScreen;
import dev.isxander.yacl.gui.controllers.ControllerWidget;
import dev.isxander.yacl.gui.utils.GuiUtils;
import net.minecraft.ChatFormatting;
-import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
@@ -42,29 +41,26 @@ public class StringControllerElement extends ControllerWidget<IStringController<
}
@Override
- protected void drawHoveredControl(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawHoveredControl(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
}
@Override
- protected void drawValueText(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ protected void drawValueText(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
Component valueText = getValueText();
if (!isHovered()) valueText = Component.literal(GuiUtils.shortenString(valueText.getString(), textRenderer, getMaxUnwrapLength(), "...")).setStyle(valueText.getStyle());
- matrices.pushPose();
int textX = getDimension().xLimit() - textRenderer.width(valueText) + renderOffset - getXPadding();
- matrices.translate(textX, getTextY(), 0);
GuiUtils.enableScissor(inputFieldBounds.x(), inputFieldBounds.y() - 2, inputFieldBounds.width() + 1, inputFieldBounds.height() + 4);
- textRenderer.drawShadow(matrices, valueText, 0, 0, getValueColor());
- matrices.popPose();
+ graphics.drawString(textRenderer, valueText, textX, getTextY(), getValueColor(), true);
if (isHovered()) {
ticks += delta;
String text = getValueText().getString();
- GuiComponent.fill(matrices, inputFieldBounds.x(), inputFieldBounds.yLimit(), inputFieldBounds.xLimit(), inputFieldBounds.yLimit() + 1, -1);
- GuiComponent.fill(matrices, inputFieldBounds.x() + 1, inputFieldBounds.yLimit() + 1, inputFieldBounds.xLimit() + 1, inputFieldBounds.yLimit() + 2, 0xFF404040);
+ graphics.fill(inputFieldBounds.x(), inputFieldBounds.yLimit(), inputFieldBounds.xLimit(), inputFieldBounds.yLimit() + 1, -1);
+ graphics.fill(inputFieldBounds.x() + 1, inputFieldBounds.yLimit() + 1, inputFieldBounds.xLimit() + 1, inputFieldBounds.yLimit() + 2, 0xFF404040);
if (inputFieldFocused || focused) {
if (caretPos > text.length())
@@ -75,12 +71,12 @@ public class StringControllerElement extends ControllerWidget<IStringController<
caretX = inputFieldBounds.x() + inputFieldBounds.width() / 2;
if (ticks % 20 <= 10) {
- GuiComponent.fill(matrices, caretX, inputFieldBounds.y(), caretX + 1, inputFieldBounds.yLimit(), -1);
+ graphics.fill(caretX, inputFieldBounds.y(), caretX + 1, inputFieldBounds.yLimit(), -1);
}
if (selectionLength != 0) {
int selectionX = textX + textRenderer.width(text.substring(0, caretPos + selectionLength));
- GuiComponent.fill(matrices, caretX, inputFieldBounds.y() - 1, selectionX, inputFieldBounds.yLimit(), 0x803030FF);
+ graphics.fill(caretX, inputFieldBounds.y() - 1, selectionX, inputFieldBounds.yLimit(), 0x803030FF);
}
}
}
diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts
index a2327ae..784f263 100644
--- a/fabric/build.gradle.kts
+++ b/fabric/build.gradle.kts
@@ -28,7 +28,9 @@ val minecraftVersion = libs.versions.minecraft.get()
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
- mappings("org.quiltmc:quilt-mappings:$minecraftVersion+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
+ val qm = libs.versions.quilt.mappings.get()
+ if (qm != "0")
+ mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
officialMojangMappings()
})
modImplementation(libs.fabric.loader)
diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json
index 6b6f6e4..508eeed 100644
--- a/fabric/src/main/resources/fabric.mod.json
+++ b/fabric/src/main/resources/fabric.mod.json
@@ -20,7 +20,7 @@
"environment": "*",
"depends": {
"fabricloader": ">=0.14.0",
- "minecraft": "~1.19.4",
+ "minecraft": ">1.20-",
"java": ">=17",
"fabric-resource-loader-v0": "*"
},
diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts
index 7a851cd..f1f2721 100644
--- a/forge/build.gradle.kts
+++ b/forge/build.gradle.kts
@@ -1,4 +1,5 @@
import org.gradle.jvm.tasks.Jar
+import org.gradle.kotlin.dsl.libs
plugins {
alias(libs.plugins.architectury.loom)
@@ -35,7 +36,9 @@ val minecraftVersion: String = libs.versions.minecraft.get()
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
- mappings("org.quiltmc:quilt-mappings:$minecraftVersion+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
+ val qm = libs.versions.quilt.mappings.get()
+ if (qm != "0")
+ mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
officialMojangMappings()
})
forge(libs.forge)
diff --git a/gradle.properties b/gradle.properties
index 86d6900..b5e8729 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,3 +7,5 @@ modDescription=YetAnotherConfigLib (yacl) is just that. A builder-based configur
modrinthId=yacl
curseforgeId=667299
githubProject=isXander/YetAnotherConfigLib
+
+loaders=fabric
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index e7cbd5f..8cbe798 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -10,16 +10,16 @@ github_release = "2.+"
machete = "2.+"
grgit = "5.0.+"
-minecraft = "1.19.4"
-quilt_mappings = "10"
+minecraft = "1.20-pre2"
+quilt_mappings = "0"
fabric_loader = "0.14.19"
# Common Dependencies
-mixin_extras = "0.2.0-beta.6"
+mixin_extras = "0.2.0-beta.7"
# Fabric-like Dependencies
-fabric_api = "0.79.0+1.19.4"
-mod_menu = "6.2.1"
+fabric_api = "0.81.2+1.20"
+mod_menu = "7.0.0-beta.2"
# Forge Dependencies
forge = "1.19.4-45.0.47"
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 51b9105..bdda698 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -17,9 +17,17 @@ dependencyResolutionManagement {
rootProject.name = "YetAnotherConfigLib"
+val enabledLoaders = settings.extra.properties["loaders"].toString().split(",").map { it.trim() }
+
include("common")
-include("fabric")
-include("forge")
include("test-common")
-include("test-fabric")
-include("test-forge")
+
+if ("fabric" in enabledLoaders) {
+ include("fabric")
+ include("test-fabric")
+}
+
+if ("forge" in enabledLoaders) {
+ include("forge")
+ include("test-forge")
+}
diff --git a/test-common/build.gradle.kts b/test-common/build.gradle.kts
index 7e14666..6bdfb0a 100644
--- a/test-common/build.gradle.kts
+++ b/test-common/build.gradle.kts
@@ -3,7 +3,8 @@ plugins {
}
architectury {
- common("fabric", "forge")
+ val enabledLoaders = rootProject.properties["loaders"].toString().split(",").map { it.trim() }
+ common(enabledLoaders)
}
loom {
@@ -15,7 +16,9 @@ loom {
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
- mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
+ val qm = libs.versions.quilt.mappings.get()
+ if (qm != "0")
+ mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
officialMojangMappings()
})
modImplementation(libs.fabric.loader)
diff --git a/test-fabric/build.gradle.kts b/test-fabric/build.gradle.kts
index 1d2d5fd..b6ff7e5 100644
--- a/test-fabric/build.gradle.kts
+++ b/test-fabric/build.gradle.kts
@@ -24,7 +24,9 @@ val minecraftVersion = libs.versions.minecraft.get()
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
- mappings("org.quiltmc:quilt-mappings:$minecraftVersion+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
+ val qm = libs.versions.quilt.mappings.get()
+ if (qm != "0")
+ mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
officialMojangMappings()
})
modImplementation(libs.fabric.loader)
diff --git a/test-forge/build.gradle.kts b/test-forge/build.gradle.kts
index 5f98b90..8cd0573 100644
--- a/test-forge/build.gradle.kts
+++ b/test-forge/build.gradle.kts
@@ -1,3 +1,5 @@
+import org.gradle.kotlin.dsl.libs
+
plugins {
alias(libs.plugins.architectury.loom)
alias(libs.plugins.shadow)
@@ -29,7 +31,9 @@ val minecraftVersion: String = libs.versions.minecraft.get()
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
- mappings("org.quiltmc:quilt-mappings:$minecraftVersion+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
+ val qm = libs.versions.quilt.mappings.get()
+ if (qm != "0")
+ mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
officialMojangMappings()
})
forge(libs.forge)