diff options
Diffstat (limited to 'src/main/java')
8 files changed, 48 insertions, 21 deletions
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 f7d807f..bbb878d 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 @@ -9,6 +9,7 @@ import dev.isxander.yacl3.config.v2.impl.FieldBackedBinding; import dev.isxander.yacl3.config.v2.impl.autogen.AutoGenUtils; import dev.isxander.yacl3.config.v2.impl.autogen.EmptyCustomImageFactory; import dev.isxander.yacl3.config.v2.impl.autogen.YACLAutoGenException; +import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.client.Minecraft; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; @@ -90,7 +91,7 @@ public abstract class SimpleOptionFactory<A extends Annotation, T> implements Op builder.customImage(imageFactory.createImage(value, field, storage).thenApply(Optional::of)); } else if (!imageOverride.value().isEmpty()) { String path = imageOverride.value(); - ResourceLocation imageLocation = new ResourceLocation(field.parent().id().getNamespace(), path); + ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), path); String extension = path.substring(path.lastIndexOf('.') + 1); switch (extension) { @@ -105,7 +106,7 @@ public abstract class SimpleOptionFactory<A extends Annotation, T> implements Op } else { String imagePath = "textures/yacl3/" + field.parent().id().getPath() + "/" + field.access().name() + ".webp"; imagePath = imagePath.toLowerCase().replaceAll("[^a-z0-9/._:-]", "_"); - ResourceLocation imageLocation = new ResourceLocation(field.parent().id().getNamespace(), imagePath); + ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), imagePath); if (Minecraft.getInstance().getResourceManager().getResource(imageLocation).isPresent()) { builder.webpImage(imageLocation); } diff --git a/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java b/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java index f78d4ba..022d56e 100644 --- a/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java +++ b/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java @@ -8,6 +8,7 @@ import dev.isxander.yacl3.config.v2.api.autogen.ListGroup; import dev.isxander.yacl3.config.v2.api.autogen.OptionFactory; import dev.isxander.yacl3.config.v2.api.autogen.OptionAccess; import dev.isxander.yacl3.config.v2.impl.FieldBackedBinding; +import dev.isxander.yacl3.platform.YACLPlatform; import net.minecraft.client.Minecraft; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; @@ -56,7 +57,7 @@ public class ListGroupImpl<T> implements OptionFactory<ListGroup, List<T>> { String imagePath = "textures/yacl3/" + field.parent().id().getPath() + "/" + field.access().name() + ".webp"; imagePath = imagePath.toLowerCase().replaceAll("[^a-z0-9/._:-]", "_"); - ResourceLocation imageLocation = new ResourceLocation(field.parent().id().getNamespace(), imagePath); + ResourceLocation imageLocation = YACLPlatform.rl(field.parent().id().getNamespace(), imagePath); if (Minecraft.getInstance().getResourceManager().getResource(imageLocation).isPresent()) { builder.webpImage(imageLocation); } 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"); diff --git a/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java b/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java index bfb0586..e330324 100644 --- a/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java +++ b/src/main/java/dev/isxander/yacl3/platform/YACLPlatform.java @@ -14,8 +14,28 @@ import net.minecraft.resources.ResourceLocation; import java.nio.file.Path; public final class YACLPlatform { + public static ResourceLocation parseRl(String rl) { + /*? if >1.20.6 {*//* + return ResourceLocation.parse(rl); + *//*?} else {*/ + return new ResourceLocation(rl); + /*?}*/ + } + public static ResourceLocation rl(String path) { - return new ResourceLocation("yet_another_config_lib_v3", path); + return rl("yet_another_config_lib_v3", path); + } + + public static ResourceLocation mcRl(String path) { + return rl("minecraft", path); + } + + public static ResourceLocation rl(String namespace, String path) { + /*? if >1.20.6 {*//* + return ResourceLocation.fromNamespaceAndPath(namespace, path); + *//*?} else {*/ + return new ResourceLocation(namespace, path); + /*?}*/ } public static Env getEnvironment() { |