From f361c5e75298956cc98607c33ca729dc73479fea Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Thu, 13 Jun 2024 19:32:47 +0200 Subject: [PATCH] Port to 1.21 (#260) * Port to 1.21 * Remove AW/AT required, mark as v15 * Update to 1.20.1 --------- Co-authored-by: shedaniel --- .github/workflows/publish.yml | 1 + .../autoconfig/gui/ConfigScreenProvider.java | 4 +- .../clothconfig2/ClothConfigDemo.java | 4 +- .../gui/AbstractConfigScreen.java | 14 +++-- .../clothconfig2/gui/ClothConfigScreen.java | 30 +++++------ .../gui/GlobalizedClothConfigScreen.java | 51 +++++++++---------- .../gui/entries/BaseListEntry.java | 2 +- .../gui/entries/DropdownBoxEntry.java | 20 ++++---- .../gui/entries/MultiElementListEntry.java | 2 +- .../gui/entries/SubCategoryListEntry.java | 2 +- .../gui/widget/DynamicEntryListWidget.java | 31 +++++------ .../clothconfig2/impl/ConfigBuilderImpl.java | 2 +- .../impl/builders/DropdownMenuBuilder.java | 10 ++-- fabric/build.gradle | 2 +- fabric/src/main/resources/fabric.mod.json | 4 +- gradle.properties | 14 ++--- neoforge/build.gradle | 4 +- .../clothconfig/ClothConfigForge.java | 7 +-- .../resources/META-INF/neoforge.mods.toml | 2 +- 19 files changed, 98 insertions(+), 108 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ed08cee5..0d15aed3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,6 +21,7 @@ on: - v13 - v14 - v14-24w14potato + - v15 jobs: build: diff --git a/common/src/main/java/me/shedaniel/autoconfig/gui/ConfigScreenProvider.java b/common/src/main/java/me/shedaniel/autoconfig/gui/ConfigScreenProvider.java index 399688a9..f7da1693 100644 --- a/common/src/main/java/me/shedaniel/autoconfig/gui/ConfigScreenProvider.java +++ b/common/src/main/java/me/shedaniel/autoconfig/gui/ConfigScreenProvider.java @@ -45,7 +45,7 @@ @Environment(EnvType.CLIENT) public class ConfigScreenProvider implements Supplier { - private static final ResourceLocation TRANSPARENT_BACKGROUND = new ResourceLocation(Config.Gui.Background.TRANSPARENT); + private static final ResourceLocation TRANSPARENT_BACKGROUND = ResourceLocation.parse(Config.Gui.Background.TRANSPARENT); private final ConfigManager manager; private final GuiRegistryAccess registry; @@ -110,7 +110,7 @@ public Screen get() { .collect( toMap( Config.Gui.CategoryBackground::category, - ann -> new ResourceLocation(ann.background()) + ann -> ResourceLocation.parse(ann.background()) ) ); diff --git a/common/src/main/java/me/shedaniel/clothconfig2/ClothConfigDemo.java b/common/src/main/java/me/shedaniel/clothconfig2/ClothConfigDemo.java index a9b51590..8e79a5ea 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/ClothConfigDemo.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/ClothConfigDemo.java @@ -30,6 +30,8 @@ import net.minecraft.Util; import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; @@ -206,7 +208,7 @@ enum DependencyDemoEnum { Component.translatable("text.cloth-config.testing.1", Component.literal("ClothConfig").withStyle(s -> s.withBold(true).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new HoverEvent.ItemStackInfo(Util.make(new ItemStack(Items.PINK_WOOL), stack -> { stack.set(DataComponents.CUSTOM_NAME, Component.literal("(\u30FB\u2200\u30FB)")); - stack.enchant(Enchantments.EFFICIENCY, 10); + stack.enchant(VanillaRegistries.createLookup().lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(Enchantments.EFFICIENCY), 10); }))))), Component.translatable("text.cloth-config.testing.2").withStyle(s -> s.withColor(ChatFormatting.BLUE).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("https://shedaniel.gitbook.io/cloth-config/"))).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://shedaniel.gitbook.io/cloth-config/"))), Component.translatable("text.cloth-config.testing.3").withStyle(s -> s.withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, Utils.getConfigFolder().getParent().resolve("options.txt").toString()))) diff --git a/common/src/main/java/me/shedaniel/clothconfig2/gui/AbstractConfigScreen.java b/common/src/main/java/me/shedaniel/clothconfig2/gui/AbstractConfigScreen.java index b3ca8ca1..f87c46d0 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/gui/AbstractConfigScreen.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/gui/AbstractConfigScreen.java @@ -54,7 +54,7 @@ import java.util.function.Consumer; public abstract class AbstractConfigScreen extends Screen implements ConfigScreen { - protected static final ResourceLocation CONFIG_TEX = new ResourceLocation("cloth-config2", "textures/gui/cloth_config.png"); + protected static final ResourceLocation CONFIG_TEX = ResourceLocation.fromNamespaceAndPath("cloth-config2", "textures/gui/cloth_config.png"); private final ResourceLocation backgroundLocation; protected boolean confirmSave; protected final Screen parent; @@ -378,16 +378,14 @@ protected void overlayBackground(Matrix4f matrix, Rectangle rect, int red, int g if (isTransparentBackground()) return; Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); + BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); RenderSystem.setShader(GameRenderer::getPositionTexColorShader); RenderSystem.setShaderTexture(0, getBackgroundLocation()); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - buffer.vertex(matrix, rect.getMinX(), rect.getMaxY(), 0.0F).uv(rect.getMinX() / 32.0F, rect.getMaxY() / 32.0F).color(red, green, blue, endAlpha).endVertex(); - buffer.vertex(matrix, rect.getMaxX(), rect.getMaxY(), 0.0F).uv(rect.getMaxX() / 32.0F, rect.getMaxY() / 32.0F).color(red, green, blue, endAlpha).endVertex(); - buffer.vertex(matrix, rect.getMaxX(), rect.getMinY(), 0.0F).uv(rect.getMaxX() / 32.0F, rect.getMinY() / 32.0F).color(red, green, blue, startAlpha).endVertex(); - buffer.vertex(matrix, rect.getMinX(), rect.getMinY(), 0.0F).uv(rect.getMinX() / 32.0F, rect.getMinY() / 32.0F).color(red, green, blue, startAlpha).endVertex(); - tesselator.end(); + buffer.addVertex(matrix, rect.getMinX(), rect.getMaxY(), 0.0F).setUv(rect.getMinX() / 32.0F, rect.getMaxY() / 32.0F).setColor(red, green, blue, endAlpha); + buffer.addVertex(matrix, rect.getMaxX(), rect.getMaxY(), 0.0F).setUv(rect.getMaxX() / 32.0F, rect.getMaxY() / 32.0F).setColor(red, green, blue, endAlpha); + buffer.addVertex(matrix, rect.getMaxX(), rect.getMinY(), 0.0F).setUv(rect.getMaxX() / 32.0F, rect.getMinY() / 32.0F).setColor(red, green, blue, startAlpha); + buffer.addVertex(matrix, rect.getMinX(), rect.getMinY(), 0.0F).setUv(rect.getMinX() / 32.0F, rect.getMinY() / 32.0F).setColor(red, green, blue, startAlpha); } @Override diff --git a/common/src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigScreen.java b/common/src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigScreen.java index 27422c5d..33f2b2ef 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigScreen.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/gui/ClothConfigScreen.java @@ -313,17 +313,15 @@ private void drawTabsShades(Matrix4f matrix, int lightColor, int darkColor) { RenderSystem.blendFuncSeparate(770, 771, 0, 1); RenderSystem.setShader(GameRenderer::getPositionTexColorShader); Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMinY() + 4, 0.0F).uv(0, 1f).color(0, 0, 0, lightColor).endVertex(); - buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMinY() + 4, 0.0F).uv(1f, 1f).color(0, 0, 0, lightColor).endVertex(); - buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMinY(), 0.0F).uv(1f, 0).color(0, 0, 0, darkColor).endVertex(); - buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMinY(), 0.0F).uv(0, 0).color(0, 0, 0, darkColor).endVertex(); - buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMaxY(), 0.0F).uv(0, 1f).color(0, 0, 0, darkColor).endVertex(); - buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMaxY(), 0.0F).uv(1f, 1f).color(0, 0, 0, darkColor).endVertex(); - buffer.vertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMaxY() - 4, 0.0F).uv(1f, 0).color(0, 0, 0, lightColor).endVertex(); - buffer.vertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMaxY() - 4, 0.0F).uv(0, 0).color(0, 0, 0, lightColor).endVertex(); - tesselator.end(); + BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + buffer.addVertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMinY() + 4, 0.0F).setUv(0, 1f).setColor(0, 0, 0, lightColor); + buffer.addVertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMinY() + 4, 0.0F).setUv(1f, 1f).setColor(0, 0, 0, lightColor); + buffer.addVertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMinY(), 0.0F).setUv(1f, 0).setColor(0, 0, 0, darkColor); + buffer.addVertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMinY(), 0.0F).setUv(0, 0).setColor(0, 0, 0, darkColor); + buffer.addVertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMaxY(), 0.0F).setUv(0, 1f).setColor(0, 0, 0, darkColor); + buffer.addVertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMaxY(), 0.0F).setUv(1f, 1f).setColor(0, 0, 0, darkColor); + buffer.addVertex(matrix, tabsBounds.getMaxX() - 20, tabsBounds.getMaxY() - 4, 0.0F).setUv(1f, 0).setColor(0, 0, 0, lightColor); + buffer.addVertex(matrix, tabsBounds.getMinX() + 20, tabsBounds.getMaxY() - 4, 0.0F).setUv(0, 0).setColor(0, 0, 0, lightColor); RenderSystem.disableBlend(); } @@ -397,10 +395,10 @@ protected static void fillGradient(Matrix4f matrix4f, BufferBuilder bufferBuilde float n = (float) (k >> 16 & 255) / 255.0F; float o = (float) (k >> 8 & 255) / 255.0F; float p = (float) (k & 255) / 255.0F; - bufferBuilder.vertex(matrix4f, (float) xEnd, (float) yStart, (float) i).color(g, h, l, f).endVertex(); - bufferBuilder.vertex(matrix4f, (float) xStart, (float) yStart, (float) i).color(g, h, l, f).endVertex(); - bufferBuilder.vertex(matrix4f, (float) xStart, (float) yEnd, (float) i).color(n, o, p, m).endVertex(); - bufferBuilder.vertex(matrix4f, (float) xEnd, (float) yEnd, (float) i).color(n, o, p, m).endVertex(); + bufferBuilder.addVertex(matrix4f, (float) xEnd, (float) yStart, (float) i).setColor(g, h, l, f); + bufferBuilder.addVertex(matrix4f, (float) xStart, (float) yStart, (float) i).setColor(g, h, l, f); + bufferBuilder.addVertex(matrix4f, (float) xStart, (float) yEnd, (float) i).setColor(n, o, p, m); + bufferBuilder.addVertex(matrix4f, (float) xEnd, (float) yEnd, (float) i).setColor(n, o, p, m); } @Override @@ -431,7 +429,7 @@ protected void renderBackBackground(GuiGraphics graphics, BufferBuilder buffer, super.renderBackBackground(graphics, buffer, tessellator); else { RenderSystem.enableBlend(); - graphics.blit(new ResourceLocation("textures/gui/menu_list_background.png"), this.left, this.top, this.right, this.bottom, this.width, this.bottom - this.top, 32, 32); + graphics.blit(ResourceLocation.withDefaultNamespace("textures/gui/menu_list_background.png"), this.left, this.top, this.right, this.bottom, this.width, this.bottom - this.top, 32, 32); RenderSystem.disableBlend(); } } diff --git a/common/src/main/java/me/shedaniel/clothconfig2/gui/GlobalizedClothConfigScreen.java b/common/src/main/java/me/shedaniel/clothconfig2/gui/GlobalizedClothConfigScreen.java index 9fadc8d2..682d53f9 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/gui/GlobalizedClothConfigScreen.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/gui/GlobalizedClothConfigScreen.java @@ -205,7 +205,6 @@ private void buildReferenceFor(AbstractConfigEntry entry, int layer) { } } - @SuppressWarnings("deprecation") @Override public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { this.lastHoveredReference = null; @@ -243,8 +242,8 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { sideScroller.updatePosition(delta); if (isTransparentBackground()) { RenderSystem.enableBlend(); - graphics.blit(new ResourceLocation("textures/gui/menu_list_background.png"), 0, 0, sliderPosition, height, sliderPosition, height, 32, 32); - graphics.blit(new ResourceLocation("textures/gui/menu_list_background.png"), 0, 0, sliderPosition - 14, height, sliderPosition - 14, height, 32, 32); + graphics.blit(ResourceLocation.withDefaultNamespace("textures/gui/menu_list_background.png"), 0, 0, sliderPosition, height, sliderPosition, height, 32, 32); + graphics.blit(ResourceLocation.withDefaultNamespace("textures/gui/menu_list_background.png"), 0, 0, sliderPosition - 14, height, sliderPosition - 14, height, 32, 32); graphics.blit(DynamicEntryListWidget.VERTICAL_HEADER_SEPARATOR, sliderPosition - 1, 0, 0.0F, 0.0F, 1, this.height, 2, 32); if (sliderPosition - 14 - 1 > 0) { graphics.blit(DynamicEntryListWidget.VERTICAL_HEADER_SEPARATOR, sliderPosition - 14 - 1, 0, 0.0F, 0.0F, 1, this.height, 2, 32); @@ -252,49 +251,45 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { RenderSystem.disableBlend(); } else { Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); + BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); RenderSystem.setShader(GameRenderer::getPositionTexColorShader); RenderSystem.setShaderTexture(0, getBackgroundLocation()); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); float f = 32.0F; - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - buffer.vertex(sliderPosition - 14, height, 0.0D).uv(0, height / 32.0F).color(68, 68, 68, 255).endVertex(); - buffer.vertex(sliderPosition, height, 0.0D).uv(14 / 32.0F, height / 32.0F).color(68, 68, 68, 255).endVertex(); - buffer.vertex(sliderPosition, 0, 0.0D).uv(14 / 32.0F, 0).color(68, 68, 68, 255).endVertex(); - buffer.vertex(sliderPosition - 14, 0, 0.0D).uv(0, 0).color(68, 68, 68, 255).endVertex(); + buffer.addVertex(sliderPosition - 14, height, 0.0F).setUv(0, height / 32.0F).setColor(68, 68, 68, 255); + buffer.addVertex(sliderPosition, height, 0.0F).setUv(14 / 32.0F, height / 32.0F).setColor(68, 68, 68, 255); + buffer.addVertex(sliderPosition, 0, 0.0F).setUv(14 / 32.0F, 0).setColor(68, 68, 68, 255); + buffer.addVertex(sliderPosition - 14, 0, 0.0F).setUv(0, 0).setColor(68, 68, 68, 255); - buffer.vertex(0, height, 0.0D).uv(0, (height + sideScroller.scrollAmountInt()) / 32.0F).color(32, 32, 32, 255).endVertex(); - buffer.vertex(sliderPosition - 14, height, 0.0D).uv((sliderPosition - 14) / 32.0F, (height + sideScroller.scrollAmountInt()) / 32.0F).color(32, 32, 32, 255).endVertex(); - buffer.vertex(sliderPosition - 14, 0, 0.0D).uv((sliderPosition - 14) / 32.0F, sideScroller.scrollAmountInt() / 32.0F).color(32, 32, 32, 255).endVertex(); - buffer.vertex(0, 0, 0.0D).uv(0, sideScroller.scrollAmountInt() / 32.0F).color(32, 32, 32, 255).endVertex(); - tesselator.end(); + buffer.addVertex(0, height, 0.0F).setUv(0, (height + sideScroller.scrollAmountInt()) / 32.0F).setColor(32, 32, 32, 255); + buffer.addVertex(sliderPosition - 14, height, 0.0F).setUv((sliderPosition - 14) / 32.0F, (height + sideScroller.scrollAmountInt()) / 32.0F).setColor(32, 32, 32, 255); + buffer.addVertex(sliderPosition - 14, 0, 0.0F).setUv((sliderPosition - 14) / 32.0F, sideScroller.scrollAmountInt() / 32.0F).setColor(32, 32, 32, 255); + buffer.addVertex(0, 0, 0.0F).setUv(0, sideScroller.scrollAmountInt() / 32.0F).setColor(32, 32, 32, 255); Matrix4f matrix = graphics.pose().last().pose(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.setShader(GameRenderer::getPositionColorShader); int shadeColor = isTransparentBackground() ? 120 : 160; - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - buffer.vertex(matrix, sliderPosition + 4, 0, 100.0F).color(0, 0, 0, 0).endVertex(); - buffer.vertex(matrix, sliderPosition, 0, 100.0F).color(0, 0, 0, shadeColor).endVertex(); - buffer.vertex(matrix, sliderPosition, height, 100.0F).color(0, 0, 0, shadeColor).endVertex(); - buffer.vertex(matrix, sliderPosition + 4, height, 100.0F).color(0, 0, 0, 0).endVertex(); - tesselator.end(); + buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + buffer.addVertex(matrix, sliderPosition + 4, 0, 100.0F).setColor(0, 0, 0, 0); + buffer.addVertex(matrix, sliderPosition, 0, 100.0F).setColor(0, 0, 0, shadeColor); + buffer.addVertex(matrix, sliderPosition, height, 100.0F).setColor(0, 0, 0, shadeColor); + buffer.addVertex(matrix, sliderPosition + 4, height, 100.0F).setColor(0, 0, 0, 0); shadeColor /= 2; - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - buffer.vertex(matrix, sliderPosition - 14, 0, 100.0F).color(0, 0, 0, shadeColor).endVertex(); - buffer.vertex(matrix, sliderPosition - 14 - 4, 0, 100.0F).color(0, 0, 0, 0).endVertex(); - buffer.vertex(matrix, sliderPosition - 14 - 4, height, 100.0F).color(0, 0, 0, 0).endVertex(); - buffer.vertex(matrix, sliderPosition - 14, height, 100.0F).color(0, 0, 0, shadeColor).endVertex(); - tesselator.end(); + buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + buffer.addVertex(matrix, sliderPosition - 14, 0, 100.0F).setColor(0, 0, 0, shadeColor); + buffer.addVertex(matrix, sliderPosition - 14 - 4, 0, 100.0F).setColor(0, 0, 0, 0); + buffer.addVertex(matrix, sliderPosition - 14 - 4, height, 100.0F).setColor(0, 0, 0, 0); + buffer.addVertex(matrix, sliderPosition - 14, height, 100.0F).setColor(0, 0, 0, shadeColor); RenderSystem.disableBlend(); } Rectangle slideArrowBounds = new Rectangle(sliderPosition - 14, 0, 14, height); { - MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); + MultiBufferSource.BufferSource immediate = graphics.bufferSource(); font.renderText(">", sliderPosition - 7 - font.width(">") / 2f, height / 2, (slideArrowBounds.contains(mouseX, mouseY) ? 16777120 : 16777215) | Mth.clamp(Mth.ceil((1 - sideSlider.scrollAmount()) * 255.0F), 0, 255) << 24, false, graphics.pose().last().pose(), immediate, Font.DisplayMode.NORMAL, 0, 15728880); font.renderText("<", sliderPosition - 7 - font.width("<") / 2f, height / 2, (slideArrowBounds.contains(mouseX, mouseY) ? 16777120 : 16777215) | Mth.clamp(Mth.ceil(sideSlider.scrollAmount() * 255.0F), 0, 255) << 24, false, graphics.pose().last().pose(), immediate, Font.DisplayMode.NORMAL, 0, 15728880); - immediate.endBatch(); + graphics.flush(); Rectangle scrollerBounds = sideScroller.getBounds(); if (!scrollerBounds.isEmpty()) { diff --git a/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java b/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java index 85d36f59..8d98d830 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/BaseListEntry.java @@ -58,7 +58,7 @@ @Environment(EnvType.CLIENT) public abstract class BaseListEntry> extends TooltipListEntry> implements Expandable { - protected static final ResourceLocation CONFIG_TEX = new ResourceLocation("cloth-config2", "textures/gui/cloth_config.png"); + protected static final ResourceLocation CONFIG_TEX = ResourceLocation.fromNamespaceAndPath("cloth-config2", "textures/gui/cloth_config.png"); @NotNull protected final List cells; @NotNull protected final List widgets; @NotNull protected final List narratables; diff --git a/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DropdownBoxEntry.java b/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DropdownBoxEntry.java index 85c6f341..1ddfc731 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DropdownBoxEntry.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/DropdownBoxEntry.java @@ -446,21 +446,19 @@ public void lateRender(GuiGraphics graphics, int mouseX, int mouseY, float delta int topc = new Rectangle(scrollbarPositionMinX, minY, scrollbarPositionMaxX - scrollbarPositionMinX, height).contains(PointHelper.ofMouse()) ? 222 : 172; Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); + BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); // Bottom - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - buffer.vertex(scrollbarPositionMinX, minY + height, 0.0D).color(bottomc, bottomc, bottomc, 255).endVertex(); - buffer.vertex(scrollbarPositionMaxX, minY + height, 0.0D).color(bottomc, bottomc, bottomc, 255).endVertex(); - buffer.vertex(scrollbarPositionMaxX, minY, 0.0D).color(bottomc, bottomc, bottomc, 255).endVertex(); - buffer.vertex(scrollbarPositionMinX, minY, 0.0D).color(bottomc, bottomc, bottomc, 255).endVertex(); + buffer.addVertex(scrollbarPositionMinX, minY + height, 0.0F).setColor(bottomc, bottomc, bottomc, 255); + buffer.addVertex(scrollbarPositionMaxX, minY + height, 0.0F).setColor(bottomc, bottomc, bottomc, 255); + buffer.addVertex(scrollbarPositionMaxX, minY, 0.0F).setColor(bottomc, bottomc, bottomc, 255); + buffer.addVertex(scrollbarPositionMinX, minY, 0.0F).setColor(bottomc, bottomc, bottomc, 255); // Top - buffer.vertex(scrollbarPositionMinX, (minY + height - 1), 0.0D).color(topc, topc, topc, 255).endVertex(); - buffer.vertex((scrollbarPositionMaxX - 1), (minY + height - 1), 0.0D).color(topc, topc, topc, 255).endVertex(); - buffer.vertex((scrollbarPositionMaxX - 1), minY, 0.0D).color(topc, topc, topc, 255).endVertex(); - buffer.vertex(scrollbarPositionMinX, minY, 0.0D).color(topc, topc, topc, 255).endVertex(); - tesselator.end(); + buffer.addVertex(scrollbarPositionMinX, (minY + height - 1), 0.0F).setColor(topc, topc, topc, 255); + buffer.addVertex((scrollbarPositionMaxX - 1), (minY + height - 1), 0.0F).setColor(topc, topc, topc, 255); + buffer.addVertex((scrollbarPositionMaxX - 1), minY, 0.0F).setColor(topc, topc, topc, 255); + buffer.addVertex(scrollbarPositionMinX, minY, 0.0F).setColor(topc, topc, topc, 255); } graphics.pose().popPose(); } diff --git a/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/MultiElementListEntry.java b/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/MultiElementListEntry.java index 22da29ce..f7fc1571 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/MultiElementListEntry.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/MultiElementListEntry.java @@ -45,7 +45,7 @@ @Environment(EnvType.CLIENT) public class MultiElementListEntry extends TooltipListEntry implements Expandable { - private static final ResourceLocation CONFIG_TEX = new ResourceLocation("cloth-config2", "textures/gui/cloth_config.png"); + private static final ResourceLocation CONFIG_TEX = ResourceLocation.fromNamespaceAndPath("cloth-config2", "textures/gui/cloth_config.png"); private final T object; private final List> entries; private final MultiElementListEntry.CategoryLabelWidget widget; diff --git a/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/SubCategoryListEntry.java b/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/SubCategoryListEntry.java index d6951650..4355c499 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/SubCategoryListEntry.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/gui/entries/SubCategoryListEntry.java @@ -46,7 +46,7 @@ @Environment(EnvType.CLIENT) public class SubCategoryListEntry extends TooltipListEntry> implements Expandable { - private static final ResourceLocation CONFIG_TEX = new ResourceLocation("cloth-config2", "textures/gui/cloth_config.png"); + private static final ResourceLocation CONFIG_TEX = ResourceLocation.fromNamespaceAndPath("cloth-config2", "textures/gui/cloth_config.png"); private final List entries; private final CategoryLabelWidget widget; private final List children; // GuiEventListener & NarratableEntry diff --git a/common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicEntryListWidget.java b/common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicEntryListWidget.java index 54d378b2..1428bd71 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicEntryListWidget.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/gui/widget/DynamicEntryListWidget.java @@ -54,8 +54,8 @@ @Environment(EnvType.CLIENT) public abstract class DynamicEntryListWidget> extends AbstractContainerEventHandler implements Renderable, NarratableEntry { - public static final ResourceLocation VERTICAL_HEADER_SEPARATOR = new ResourceLocation("cloth-config2:textures/gui/vertical_header_separator.png"); - public static final ResourceLocation VERTICAL_FOOTER_SEPARATOR = new ResourceLocation("cloth-config2:textures/gui/vertical_footer_separator.png"); + public static final ResourceLocation VERTICAL_HEADER_SEPARATOR = ResourceLocation.parse("cloth-config2:textures/gui/vertical_header_separator.png"); + public static final ResourceLocation VERTICAL_FOOTER_SEPARATOR = ResourceLocation.parse("cloth-config2:textures/gui/vertical_footer_separator.png"); protected static final int DRAG_OUTSIDE = -2; protected final Minecraft client; private final List entries = new Entries(); @@ -278,12 +278,11 @@ protected void renderBackBackground(GuiGraphics graphics, BufferBuilder buffer, RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); Matrix4f matrix = graphics.pose().last().pose(); float float_2 = 32.0F; - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - buffer.vertex(matrix, this.left, this.bottom, 0.0F).uv(this.left / 32.0F, ((this.bottom + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).endVertex(); - buffer.vertex(matrix, this.right, this.bottom, 0.0F).uv(this.right / 32.0F, ((this.bottom + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).endVertex(); - buffer.vertex(matrix, this.right, this.top, 0.0F).uv(this.right / 32.0F, ((this.top + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).endVertex(); - buffer.vertex(matrix, this.left, this.top, 0.0F).uv(this.left / 32.0F, ((this.top + (int) this.getScroll()) / 32.0F)).color(32, 32, 32, 255).endVertex(); - tessellator.end(); + tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + buffer.addVertex(matrix, this.left, this.bottom, 0.0F).setUv(this.left / 32.0F, ((this.bottom + (int) this.getScroll()) / 32.0F)).setColor(32, 32, 32, 255); + buffer.addVertex(matrix, this.right, this.bottom, 0.0F).setUv(this.right / 32.0F, ((this.bottom + (int) this.getScroll()) / 32.0F)).setColor(32, 32, 32, 255); + buffer.addVertex(matrix, this.right, this.top, 0.0F).setUv(this.right / 32.0F, ((this.top + (int) this.getScroll()) / 32.0F)).setColor(32, 32, 32, 255); + buffer.addVertex(matrix, this.left, this.top, 0.0F).setUv(this.left / 32.0F, ((this.top + (int) this.getScroll()) / 32.0F)).setColor(32, 32, 32, 255); } @Override @@ -298,7 +297,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { int scrollbarPosition = this.getScrollbarPosition(); int int_4 = scrollbarPosition + 6; Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); + BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); renderBackBackground(graphics, buffer, tesselator); int rowLeft = this.getRowLeft(); int startY = this.top + 4 - (int) this.getScroll(); @@ -544,7 +543,7 @@ public boolean isMouseOver(double double_1, double double_2) { protected void renderList(GuiGraphics graphics, int startX, int startY, int mouseX, int mouseY, float delta) { Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); + BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); hoveredItem = this.isMouseOver(mouseX, mouseY) ? this.getItemAtPosition(mouseX, mouseY) : null; @@ -601,17 +600,15 @@ public boolean isFocused() { protected void renderHoleBackground(GuiGraphics graphics, int y1, int y2, int alpha1, int alpha2) { Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder buffer = tesselator.getBuilder(); + BufferBuilder buffer = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); Matrix4f matrix = graphics.pose().last().pose(); RenderSystem.setShader(GameRenderer::getPositionTexColorShader); RenderSystem.setShaderTexture(0, backgroundLocation); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - buffer.vertex(matrix, this.left, y2, 0.0F).uv(0, ((float) y2 / 32.0F)).color(64, 64, 64, alpha2).endVertex(); - buffer.vertex(matrix, this.left + this.width, y2, 0.0F).uv(((float) this.width / 32.0F), ((float) y2 / 32.0F)).color(64, 64, 64, alpha2).endVertex(); - buffer.vertex(matrix, this.left + this.width, y1, 0.0F).uv(((float) this.width / 32.0F), ((float) y1 / 32.0F)).color(64, 64, 64, alpha1).endVertex(); - buffer.vertex(matrix, this.left, y1, 0.0F).uv(0, ((float) y1 / 32.0F)).color(64, 64, 64, alpha1).endVertex(); - tesselator.end(); + buffer.addVertex(matrix, this.left, y2, 0.0F).setUv(0, ((float) y2 / 32.0F)).setColor(64, 64, 64, alpha2); + buffer.addVertex(matrix, this.left + this.width, y2, 0.0F).setUv(((float) this.width / 32.0F), ((float) y2 / 32.0F)).setColor(64, 64, 64, alpha2); + buffer.addVertex(matrix, this.left + this.width, y1, 0.0F).setUv(((float) this.width / 32.0F), ((float) y1 / 32.0F)).setColor(64, 64, 64, alpha1); + buffer.addVertex(matrix, this.left, y1, 0.0F).setUv(0, ((float) y1 / 32.0F)).setColor(64, 64, 64, alpha1); } protected E remove(int index) { diff --git a/common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigBuilderImpl.java b/common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigBuilderImpl.java index 777a9c26..e6f6999f 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigBuilderImpl.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/impl/ConfigBuilderImpl.java @@ -50,7 +50,7 @@ public class ConfigBuilderImpl implements ConfigBuilder { private boolean listSmoothScroll = true; private boolean doesConfirmSave = true; private boolean transparentBackground = true; - private ResourceLocation defaultBackground = new ResourceLocation("textures/block/dirt.png"); + private ResourceLocation defaultBackground = ResourceLocation.withDefaultNamespace("textures/block/dirt.png"); private Consumer afterInitConsumer = screen -> {}; private final Map categoryMap = Maps.newLinkedHashMap(); private String fallbackCategory = null; diff --git a/common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DropdownMenuBuilder.java b/common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DropdownMenuBuilder.java index 0b6bd4fb..79ac96c5 100644 --- a/common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DropdownMenuBuilder.java +++ b/common/src/main/java/me/shedaniel/clothconfig2/impl/builders/DropdownMenuBuilder.java @@ -133,14 +133,14 @@ public DropdownBoxEntry build() { public static class TopCellElementBuilder { public static final Function IDENTIFIER_FUNCTION = str -> { try { - return new ResourceLocation(str); + return ResourceLocation.parse(str); } catch (NumberFormatException e) { return null; } }; public static final Function ITEM_IDENTIFIER_FUNCTION = str -> { try { - ResourceLocation identifier = new ResourceLocation(str); + ResourceLocation identifier = ResourceLocation.parse(str); if (BuiltInRegistries.ITEM.getOptional(identifier).isPresent()) return identifier; } catch (Exception ignored) { @@ -149,7 +149,7 @@ public static class TopCellElementBuilder { }; public static final Function BLOCK_IDENTIFIER_FUNCTION = str -> { try { - ResourceLocation identifier = new ResourceLocation(str); + ResourceLocation identifier = ResourceLocation.parse(str); if (BuiltInRegistries.BLOCK.getOptional(identifier).isPresent()) return identifier; } catch (Exception ignored) { @@ -158,14 +158,14 @@ public static class TopCellElementBuilder { }; public static final Function ITEM_FUNCTION = str -> { try { - return BuiltInRegistries.ITEM.getOptional(new ResourceLocation(str)).orElse(null); + return BuiltInRegistries.ITEM.getOptional(ResourceLocation.parse(str)).orElse(null); } catch (Exception ignored) { } return null; }; public static final Function BLOCK_FUNCTION = str -> { try { - return BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(str)).orElse(null); + return BuiltInRegistries.BLOCK.getOptional(ResourceLocation.parse(str)).orElse(null); } catch (Exception ignored) { } return null; diff --git a/fabric/build.gradle b/fabric/build.gradle index 5a321b2b..7da7ed05 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -121,7 +121,7 @@ unifiedPublishing { curseforge { token = project.hasProperty("curse_api_key") ? project.property("curse_api_key") : System.getenv("curse_api_key") id = project.curseforge_id - gameVersions.addAll "1.20.5", "Java 21" + gameVersions.addAll "1.21", "Java 21" } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index dcdf8a7f..060e1586 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "cloth-config", - "name": "Cloth Config v14", + "name": "Cloth Config v15", "description": "An API for config screens.", "version": "${version}", "authors": [ @@ -27,7 +27,7 @@ ], "depends": { "fabricloader": ">=0.14.0", - "minecraft": ">=1.20.5-" + "minecraft": ">=1.21-" }, "accessWidener": "cloth-config.accessWidener", "custom": { diff --git a/gradle.properties b/gradle.properties index 4157b325..23581ea6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,24 +1,24 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -minecraft_version=1.20.5 -supported_version=1.20.5 +minecraft_version=1.21 +supported_version=1.21 archives_base_name=cloth-config archives_base_name_snapshot=cloth-config-snapshot -base_version=14.0 +base_version=15.0 maven_group=me.shedaniel.cloth jankson_version=1.2.0 toml4j_version=0.7.2 snakeyaml_version=1.27 -fabric_loader_version=0.15.10 -fabric_api_version=0.97.6+1.20.5 -mod_menu_version=10.0.0-beta.1 +fabric_loader_version=0.15.11 +fabric_api_version=0.100.1+1.21 +mod_menu_version=11.0.0-beta.1 forge_version=49.0.3 -neoforge_version=20.5.0-beta +neoforge_version=21.0.0-beta neoforge_pr= curseforge_id=348521 diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 198a2a7c..18e9b855 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -32,7 +32,7 @@ dependencies { neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" - modLocalRuntime("me.shedaniel.cloth:basic-math:0.6.1") + compileOnly("me.shedaniel.cloth:basic-math:0.6.1") forgeRuntimeLibrary(shadowCommon("me.shedaniel.cloth:basic-math:0.6.1")) modLocalRuntime("blue.endless:jankson:${rootProject.jankson_version}") @@ -100,7 +100,7 @@ unifiedPublishing { project { displayName = "[NeoForge $rootProject.supported_version] v$project.version" releaseType = "release" - gameVersions = ["1.20.5"] + gameVersions = ["1.21"] gameLoaders = ["neoforge"] mainPublication remapJar diff --git a/neoforge/src/main/java/me/shedaniel/clothconfig/ClothConfigForge.java b/neoforge/src/main/java/me/shedaniel/clothconfig/ClothConfigForge.java index 638b7ccb..2b20c0b7 100644 --- a/neoforge/src/main/java/me/shedaniel/clothconfig/ClothConfigForge.java +++ b/neoforge/src/main/java/me/shedaniel/clothconfig/ClothConfigForge.java @@ -20,13 +20,14 @@ package me.shedaniel.clothconfig; import me.shedaniel.clothconfig2.ClothConfigInitializer; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.fml.DistExecutor; import net.neoforged.fml.common.Mod; +import net.neoforged.fml.loading.FMLEnvironment; @Mod(ClothConfigInitializer.MOD_ID) public class ClothConfigForge { public ClothConfigForge() { - DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ClothConfigForgeDemo::registerModsPage); + if (FMLEnvironment.dist.isClient()) { + ClothConfigForgeDemo.registerModsPage(); + } } } diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 6c5fe2d2..4052842d 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -9,7 +9,7 @@ license = "GNU LGPLv3" [[mods]] modId = "cloth_config" version = "${version}" -displayName = "Cloth Config v14 API" +displayName = "Cloth Config v15 API" description = ''' An API for config screens. '''