aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/gui
diff options
context:
space:
mode:
authorisXander <xander@isxander.dev>2024-05-29 22:42:46 +0100
committerisXander <xander@isxander.dev>2024-05-29 22:42:46 +0100
commit646c7bac69dba476b3f9171568091eb23a86edaa (patch)
tree83727744315b956120fb573f9ecd883837b63099 /src/main/java/dev/isxander/yacl3/gui
parent41253828df7c2066b5df29a32aa8e512f34ad85a (diff)
downloadYetAnotherConfigLib-646c7bac69dba476b3f9171568091eb23a86edaa.tar.gz
YetAnotherConfigLib-646c7bac69dba476b3f9171568091eb23a86edaa.tar.bz2
YetAnotherConfigLib-646c7bac69dba476b3f9171568091eb23a86edaa.zip
1.21 compat
Diffstat (limited to 'src/main/java/dev/isxander/yacl3/gui')
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java8
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java6
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/YACLScreen.java12
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java5
-rw-r--r--src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java8
5 files changed, 22 insertions, 17 deletions
diff --git a/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java b/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
index 1f7c29b..e6ab3f1 100644
--- a/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
+++ b/src/main/java/dev/isxander/yacl3/gui/AbstractWidget.java
@@ -94,10 +94,18 @@ public abstract class AbstractWidget implements GuiEventListener, Renderable, Na
//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);
+ *//*? } 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();
+ /*? } */
}
diff --git a/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java b/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java
index 85b86bb..be95caa 100644
--- a/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java
+++ b/src/main/java/dev/isxander/yacl3/gui/ElementListWidgetExt.java
@@ -63,7 +63,11 @@ public class ElementListWidgetExt<E extends ElementListWidgetExt.Entry<E>> exten
resetSmoothScrolling();
}
- smoothScrollAmount = Mth.lerp(Minecraft.getInstance().getDeltaFrameTime() * 0.5, smoothScrollAmount, getScrollAmount());
+ smoothScrollAmount = Mth.lerp(
+ delta * 0.5,
+ smoothScrollAmount,
+ getScrollAmount()
+ );
returnSmoothAmount = true;
diff --git a/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java
index 8152d18..4cf1cca 100644
--- a/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java
+++ b/src/main/java/dev/isxander/yacl3/gui/YACLScreen.java
@@ -15,6 +15,7 @@ import dev.isxander.yacl3.gui.tab.ScrollableNavigationBar;
import dev.isxander.yacl3.gui.tab.TabExt;
import dev.isxander.yacl3.gui.utils.GuiUtils;
import dev.isxander.yacl3.impl.utils.YACLConstants;
+import dev.isxander.yacl3.platform.YACLPlatform;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
@@ -278,10 +279,6 @@ public class YACLScreen extends Screen {
int drawY = y - 12;
graphics.pose().pushPose();
- Tesselator tesselator = Tesselator.getInstance();
- BufferBuilder bufferBuilder = tesselator.getBuilder();
- RenderSystem.setShader(GameRenderer::getPositionColorShader);
- bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
TooltipRenderUtil.renderTooltipBackground(
graphics,
drawX,
@@ -290,11 +287,6 @@ public class YACLScreen extends Screen {
height,
400
);
- RenderSystem.enableDepthTest();
- RenderSystem.enableBlend();
- RenderSystem.defaultBlendFunc();
- BufferUploader.drawWithShader(bufferBuilder.end());
- RenderSystem.disableBlend();
graphics.pose().translate(0.0, 0.0, 400.0);
text.renderLeftAligned(graphics, drawX, drawY, lineHeight, -1);
@@ -305,7 +297,7 @@ public class YACLScreen extends Screen {
public static class CategoryTab implements TabExt {
/*? if >1.20.4 {*/
- private static final ResourceLocation DARKER_BG = new ResourceLocation("textures/gui/menu_list_background.png");
+ private static final ResourceLocation DARKER_BG = YACLPlatform.mcRl("textures/gui/menu_list_background.png");
/*?}*/
private final YACLScreen screen;
diff --git a/src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java b/src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java
index 3c4f03a..bb6c664 100644
--- a/src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java
+++ b/src/main/java/dev/isxander/yacl3/gui/utils/ItemRegistryHelper.java
@@ -1,6 +1,7 @@
package dev.isxander.yacl3.gui.utils;
+import dev.isxander.yacl3.platform.YACLPlatform;
import net.minecraft.ResourceLocationException;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
@@ -26,7 +27,7 @@ public final class ItemRegistryHelper {
*/
public static boolean isRegisteredItem(String identifier) {
try {
- ResourceLocation itemIdentifier = new ResourceLocation(identifier.toLowerCase());
+ ResourceLocation itemIdentifier = YACLPlatform.parseRl(identifier.toLowerCase());
return BuiltInRegistries.ITEM.containsKey(itemIdentifier);
} catch (ResourceLocationException e) {
return false;
@@ -43,7 +44,7 @@ public final class ItemRegistryHelper {
*/
public static Item getItemFromName(String identifier, Item defaultItem) {
try {
- ResourceLocation itemIdentifier = new ResourceLocation(identifier.toLowerCase());
+ ResourceLocation itemIdentifier = YACLPlatform.parseRl(identifier.toLowerCase());
if (BuiltInRegistries.ITEM.containsKey(itemIdentifier)) {
return BuiltInRegistries.ITEM.get(itemIdentifier);
}
diff --git a/src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java b/src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java
index b49557b..b8293fb 100644
--- a/src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java
+++ b/src/main/java/dev/isxander/yacl3/gui/utils/YACLRenderHelper.java
@@ -8,10 +8,10 @@ import net.minecraft.resources.ResourceLocation;
public class YACLRenderHelper {
/*? if >1.20.1 {*/
private static final net.minecraft.client.gui.components.WidgetSprites SPRITES = new net.minecraft.client.gui.components.WidgetSprites(
- new ResourceLocation("widget/button"), // normal
- new ResourceLocation("widget/button_disabled"), // disabled & !focused
- new ResourceLocation("widget/button_highlighted"), // !disabled & focused
- new ResourceLocation("widget/slider_highlighted") // disabled & focused
+ YACLPlatform.mcRl("widget/button"), // normal
+ YACLPlatform.mcRl("widget/button_disabled"), // disabled & !focused
+ YACLPlatform.mcRl("widget/button_highlighted"), // !disabled & focused
+ YACLPlatform.mcRl("widget/slider_highlighted") // disabled & focused
);
/*?} else {*//*
private static final ResourceLocation SLIDER_LOCATION = new ResourceLocation("textures/gui/slider.png");