diff options
author | isXander <xandersmith2008@gmail.com> | 2022-11-17 17:18:19 +0000 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2022-11-17 17:18:19 +0000 |
commit | 3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e (patch) | |
tree | d3617930fed50a945ce4ff9ee76b8dbd7df46968 | |
parent | af4484ecee46300a26952b9b9b41e7a2e80d3f78 (diff) | |
download | YetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.tar.gz YetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.tar.bz2 YetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.zip |
22w46a
17 files changed, 82 insertions, 69 deletions
diff --git a/.github/workflows/snapshot-publish.yml b/.github/workflows/snapshot-publish.yml index 49129b3..1529da3 100644 --- a/.github/workflows/snapshot-publish.yml +++ b/.github/workflows/snapshot-publish.yml @@ -2,8 +2,6 @@ name: Publish Snapshot on: push: - branches: - - '1.19' paths-ignore: - 'README.md' - 'LICENSE' diff --git a/build.gradle.kts b/build.gradle.kts index 6b58d99..eea4cdb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,10 +16,10 @@ plugins { val ciRun = System.getenv().containsKey("GITHUB_ACTIONS") group = "dev.isxander" -version = "1.7.1" +version = "2.0.0" if (ciRun) - version = "$version-SNAPSHOT" + version = "$version+${grgit.branch.current().name}-SNAPSHOT" val testmod by sourceSets.registering { compileClasspath += sourceSets.main.get().compileClasspath @@ -54,12 +54,9 @@ dependencies { mappings("net.fabricmc:yarn:$minecraftVersion+build.+:v2") modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") - modImplementation(fabricApi.module("fabric-resource-loader-v0", "0.66.0+1.19.2")) + modImplementation(fabricApi.module("fabric-resource-loader-v0", "0.66.2+1.19.3")) "testmodImplementation"(sourceSets.main.get().output) - "modTestmodImplementation"("com.terraformersmc:modmenu:4.0.6") { - exclude(module = "fabric-loader") - } } java { diff --git a/changelogs/2.0.0.md b/changelogs/2.0.0.md new file mode 100644 index 0000000..832c84c --- /dev/null +++ b/changelogs/2.0.0.md @@ -0,0 +1 @@ +- Update to 1.19.3 diff --git a/gradle.properties b/gradle.properties index 0f0b15f..a7543f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx3G -minecraftVersion=1.19.2 +minecraftVersion=22w46a fabricLoaderVersion=0.14.10 modId=yet-another-config-lib diff --git a/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java b/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java index 03dc9b9..bede0ae 100644 --- a/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/AbstractWidget.java @@ -82,7 +82,7 @@ public abstract class AbstractWidget implements Element, Drawable, Selectable { int width = x2 - x1; int height = y2 - y1; - RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderTexture(0, ClickableWidget.WIDGETS_TEXTURE); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); int i = !enabled ? 0 : hovered ? 2 : 1; diff --git a/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java b/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java index 2cb6bb6..46a9fdf 100644 --- a/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/CategoryListWidget.java @@ -15,7 +15,7 @@ public class CategoryListWidget extends ElementListWidget<CategoryListWidget.Cat private final YACLScreen yaclScreen; public CategoryListWidget(MinecraftClient client, YACLScreen yaclScreen, int screenWidth, int screenHeight) { - super(client, screenWidth / 3, yaclScreen.searchFieldWidget.y - 5, 0, yaclScreen.searchFieldWidget.y - 5, 21); + super(client, screenWidth / 3, yaclScreen.searchFieldWidget.getY() - 5, 0, yaclScreen.searchFieldWidget.getY() - 5, 21); this.yaclScreen = yaclScreen; setRenderBackground(false); setRenderHorizontalShadows(false); @@ -75,7 +75,7 @@ public class CategoryListWidget extends ElementListWidget<CategoryListWidget.Cat mouseY = -20; } - categoryButton.y = y; + categoryButton.setY(y); categoryButton.render(matrices, mouseX, mouseY, tickDelta); } diff --git a/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java index 240cfb2..a4d6304 100644 --- a/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/LowProfileButtonWidget.java @@ -1,6 +1,7 @@ package dev.isxander.yacl.gui; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; @@ -8,18 +9,19 @@ import net.minecraft.util.math.MathHelper; public class LowProfileButtonWidget extends ButtonWidget { public LowProfileButtonWidget(int x, int y, int width, int height, Text message, PressAction onPress) { - super(x, y, width, height, message, onPress); + super(x, y, width, height, message, onPress, ButtonWidget.DEFAULT_NARRATION_SUPPLIER); } - public LowProfileButtonWidget(int x, int y, int width, int height, Text message, PressAction onPress, TooltipSupplier tooltipSupplier) { - super(x, y, width, height, message, onPress, tooltipSupplier); + public LowProfileButtonWidget(int x, int y, int width, int height, Text message, PressAction onPress, Tooltip tooltip) { + this(x, y, width, height, message, onPress); + setTooltip(tooltip); } @Override public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) { if (!isHovered()) { int j = this.active ? 0xFFFFFF : 0xA0A0A0; - drawCenteredText(matrices, MinecraftClient.getInstance().textRenderer, this.getMessage(), this.x + this.width / 2, this.y + (this.height - 8) / 2, j | MathHelper.ceil(this.alpha * 255.0F) << 24); + drawCenteredText(matrices, MinecraftClient.getInstance().textRenderer, this.getMessage(), this.getX() + this.width / 2, this.getY() + (this.height - 8) / 2, j | MathHelper.ceil(this.alpha * 255.0F) << 24); } else { super.renderButton(matrices, mouseX, mouseY, delta); } diff --git a/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java b/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java index cf50a58..eed3aff 100644 --- a/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/OptionListWidget.java @@ -312,7 +312,7 @@ public class OptionListWidget extends ElementListWidget<OptionListWidget.Entry> widget.render(matrices, mouseX, mouseY, tickDelta); if (resetButton != null) { - resetButton.y = y; + resetButton.setY(y); resetButton.render(matrices, mouseX, mouseY, tickDelta); } } @@ -402,8 +402,8 @@ public class OptionListWidget extends ElementListWidget<OptionListWidget.Entry> public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { this.y = y; - expandMinimizeButton.x = x; - expandMinimizeButton.y = y + entryHeight / 2 - expandMinimizeButton.getHeight() / 2; + expandMinimizeButton.setX(x); + expandMinimizeButton.setY(y + entryHeight / 2 - expandMinimizeButton.getHeight() / 2); expandMinimizeButton.render(matrices, mouseX, mouseY, tickDelta); wrappedName.drawCenterWithShadow(matrices, x + entryWidth / 2, y + getYPadding()); diff --git a/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java b/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java index 6184405..5b7c9dc 100644 --- a/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/SearchFieldWidget.java @@ -25,7 +25,7 @@ public class SearchFieldWidget extends TextFieldWidget { public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) { super.renderButton(matrices, mouseX, mouseY, delta); if (isVisible() && isEmpty()) { - textRenderer.drawWithShadow(matrices, emptyText, x + 4, this.y + (this.height - 8) / 2f, 0x707070); + textRenderer.drawWithShadow(matrices, emptyText, getX() + 4, this.getY() + (this.height - 8) / 2f, 0x707070); } } diff --git a/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java index d588d52..197a162 100644 --- a/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/TextScaledButtonWidget.java @@ -2,6 +2,7 @@ package dev.isxander.yacl.gui; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.screen.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.OrderedText; @@ -12,13 +13,13 @@ public class TextScaledButtonWidget extends ButtonWidget { public float textScale; public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress) { - super(x, y, width, height, message, onPress); + super(x, y, width, height, message, onPress, ButtonWidget.DEFAULT_NARRATION_SUPPLIER); this.textScale = textScale; } - public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress, TooltipSupplier tooltipSupplier) { - super(x, y, width, height, message, onPress, tooltipSupplier); - this.textScale = textScale; + public TextScaledButtonWidget(int x, int y, int width, int height, float textScale, Text message, PressAction onPress, Tooltip tooltip) { + this(x, y, width, height, textScale, message, onPress); + setTooltip(tooltip); } @Override @@ -35,7 +36,7 @@ public class TextScaledButtonWidget extends ButtonWidget { TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; matrices.push(); - matrices.translate(((this.x + this.width / 2f) - textRenderer.getWidth(orderedText) * textScale / 2), (float)this.y + (this.height - 8 * textScale) / 2f / textScale, 0); + matrices.translate(((this.getX() + this.width / 2f) - textRenderer.getWidth(orderedText) * textScale / 2), (float)this.getY() + (this.height - 8 * textScale) / 2f / textScale, 0); matrices.scale(textScale, textScale, 1); textRenderer.drawWithShadow(matrices, orderedText, 0, 0, j | MathHelper.ceil(this.alpha * 255.0F) << 24); matrices.pop(); diff --git a/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java b/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java index d105f7b..706765a 100644 --- a/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java +++ b/src/main/java/dev/isxander/yacl/gui/TooltipButtonWidget.java @@ -13,14 +13,14 @@ public class TooltipButtonWidget extends ButtonWidget { protected MultilineText wrappedDescription; public TooltipButtonWidget(Screen screen, int x, int y, int width, int height, Text message, Text tooltip, PressAction onPress) { - super(x, y, width, height, message, onPress); + super(x, y, width, height, message, onPress, ButtonWidget.DEFAULT_NARRATION_SUPPLIER); this.screen = screen; setTooltip(tooltip); } public void renderHoveredTooltip(MatrixStack matrices) { if (isHovered()) { - YACLScreen.renderMultilineTooltip(matrices, MinecraftClient.getInstance().textRenderer, wrappedDescription, x + width / 2, y - 4, y + height + 4, screen.width, screen.height); + YACLScreen.renderMultilineTooltip(matrices, MinecraftClient.getInstance().textRenderer, wrappedDescription, getX() + width / 2, getY() - 4, getY() + height + 4, screen.width, screen.height); } } diff --git a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java index 629fd4c..e36c8e8 100644 --- a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java +++ b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java @@ -13,8 +13,7 @@ import net.minecraft.client.render.*; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Matrix4f; +import org.joml.Matrix4f; import java.util.HashSet; import java.util.Set; @@ -85,7 +84,7 @@ public class YACLScreen extends Screen { OptionUtils.forEachOptions(config, Option::forgetPendingValue); }); - searchFieldWidget = new SearchFieldWidget(this, textRenderer, width / 3 / 2 - paddedWidth / 2 + 1, undoButton.y - 22, paddedWidth - 2, 18, Text.translatable("gui.recipebook.search_hint"), Text.translatable("gui.recipebook.search_hint")); + searchFieldWidget = new SearchFieldWidget(this, textRenderer, width / 3 / 2 - paddedWidth / 2 + 1, undoButton.getY() - 22, paddedWidth - 2, 18, Text.translatable("gui.recipebook.search_hint"), Text.translatable("gui.recipebook.search_hint")); categoryList = new CategoryListWidget(client, this, width, height); addSelectableChild(categoryList); @@ -241,7 +240,7 @@ public class YACLScreen extends Screen { matrices.push(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); - RenderSystem.setShader(GameRenderer::getPositionColorShader); + RenderSystem.setShader(GameRenderer::getPositionColorProgram); bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); Matrix4f matrix4f = matrices.peek().getPositionMatrix(); fillGradient(matrix4f, bufferBuilder, drawX - 3, drawY - 4, drawX + maxWidth + 3, drawY - 3, 400, -267386864, -267386864); @@ -257,7 +256,7 @@ public class YACLScreen extends Screen { RenderSystem.disableTexture(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - BufferRenderer.drawWithShader(bufferBuilder.end()); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); RenderSystem.disableBlend(); RenderSystem.enableTexture(); matrices.translate(0.0, 0.0, 400.0); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fc5a14f..37b150e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,8 +20,9 @@ }, "depends": { "fabricloader": ">=0.14.0", - "minecraft": "1.19.x", - "java": ">=17" + "minecraft": "~1.19.3-alpha.22.46.a", + "java": ">=17", + "fabric-resource-loader-v0": "*" }, "mixins": [ "yet-another-config-lib.mixins.json" diff --git a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java b/src/testmod/java/dev/isxander/yacl/test/GuiTest.java index 596a0bf..449a081 100644 --- a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java +++ b/src/testmod/java/dev/isxander/yacl/test/GuiTest.java @@ -1,7 +1,5 @@ package dev.isxander.yacl.test; -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; import dev.isxander.yacl.api.*; import dev.isxander.yacl.gui.RequireRestartScreen; import dev.isxander.yacl.gui.controllers.*; @@ -23,10 +21,9 @@ import net.minecraft.text.Text; import java.awt.*; -public class ModMenuIntegration implements ModMenuApi { - @Override - public ConfigScreenFactory<?> getModConfigScreenFactory() { - return (parent) -> Entrypoint.getConfig().buildConfig((config, builder) -> builder +public class GuiTest { + public static Screen getModConfigScreenFactory(Screen parent) { + return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.of("Test Suites")) .category(ConfigCategory.createBuilder() .name(Text.of("Suites")) @@ -55,7 +52,7 @@ public class ModMenuIntegration implements ModMenuApi { .generateScreen(parent); } - private Screen getFullTestSuite(Screen parent) { + private static Screen getFullTestSuite(Screen parent) { return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.of("Test GUI")) .category(ConfigCategory.createBuilder() @@ -340,7 +337,7 @@ public class ModMenuIntegration implements ModMenuApi { .generateScreen(parent); } - private Screen getDisabledTest(Screen parent) { + private static Screen getDisabledTest(Screen parent) { return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.empty()) .category(ConfigCategory.createBuilder() @@ -373,7 +370,7 @@ public class ModMenuIntegration implements ModMenuApi { .generateScreen(parent); } - private Screen getWikiBasic(Screen parent) { + private static Screen getWikiBasic(Screen parent) { return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.of("Mod Name")) .category(ConfigCategory.createBuilder() @@ -394,7 +391,7 @@ public class ModMenuIntegration implements ModMenuApi { .generateScreen(parent); } - private Screen getWikiGroups(Screen parent) { + private static Screen getWikiGroups(Screen parent) { return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.of("Mod Name")) .category(ConfigCategory.createBuilder() @@ -417,21 +414,4 @@ public class ModMenuIntegration implements ModMenuApi { ) .generateScreen(parent); } - - private ConfigScreenFactory<?> getWikiButton() { - return (parent) -> Entrypoint.getConfig().buildConfig((config, builder) -> builder - .title(Text.of("Mod Name")) - .category(ConfigCategory.createBuilder() - .name(Text.of("My Category")) - .tooltip(Text.of("This displays when you hover over a category button")) // optional - .option(ButtonOption.createBuilder() - .name(Text.of("Pressable Button")) - .tooltip(Text.of("This is so easy!")) // optional - .action(screen -> {}) - .controller(ActionController::new) - .build()) - .build()) - ) - .generateScreen(parent); - } } diff --git a/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java b/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java new file mode 100644 index 0000000..b32a392 --- /dev/null +++ b/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java @@ -0,0 +1,26 @@ +package dev.isxander.yacl.test.mixins; + +import dev.isxander.yacl.test.GuiTest; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.TitleScreen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(TitleScreen.class) +public abstract class TitleScreenMixin extends Screen { + protected TitleScreenMixin(Text title) { + super(title); + } + + @Inject(method = "init", at = @At("RETURN")) + private void injectTestButton(CallbackInfo ci) { + addDrawableChild(ButtonWidget.createBuilder(Text.of("YACL"), button -> client.setScreen(GuiTest.getModConfigScreenFactory(client.currentScreen))) + .setPosition(0, 0) + .setWidth(50) + .build()); + } +} diff --git a/src/testmod/resources/fabric.mod.json b/src/testmod/resources/fabric.mod.json index 1360a5e..5fe0919 100644 --- a/src/testmod/resources/fabric.mod.json +++ b/src/testmod/resources/fabric.mod.json @@ -11,15 +11,12 @@ "entrypoints": { "client": [ "dev.isxander.yacl.test.config.Entrypoint" - ], - "modmenu": [ - "dev.isxander.yacl.test.ModMenuIntegration" ] }, "depends": { - "fabricloader": ">=0.14.0", - "minecraft": "1.19.x", - "java": ">=17", - "fabric-resource-loader-v0": "*" - } + "yet-another-config-lib": "*" + }, + "mixins": [ + "yet-another-config-lib.test.mixins.json" + ] } diff --git a/src/testmod/resources/yet-another-config-lib.test.mixins.json b/src/testmod/resources/yet-another-config-lib.test.mixins.json new file mode 100644 index 0000000..9287cdd --- /dev/null +++ b/src/testmod/resources/yet-another-config-lib.test.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "dev.isxander.yacl.test.mixins", + "compatibilityLevel": "JAVA_17", + "injectors": { + "defaultRequire": 1 + }, + "client": [ + "TitleScreenMixin" + ] +} |