From 422e54b488ee0267d8bb63f9d5fba9e6aa005b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20=C5=A0okala?= Date: Fri, 15 May 2026 18:59:34 +0200 Subject: [PATCH] ChangelogScreen for 1.12.2 --- buildSrc/src/main/groovy/dh-loader.gradle | 3 +- .../commonMixins/DhUpdateScreenBase.java | 18 +- .../gui/classicConfig/DhConfigScreen.java | 45 ++++- .../wrappers/gui/updater/ChangelogScreen.java | 179 ++++++++++++++++-- .../wrappers/gui/updater/UpdateModScreen.java | 107 +++++++++-- .../resources/1_12_2.distanthorizons_at.cfg | 3 +- 6 files changed, 305 insertions(+), 50 deletions(-) diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index 852d42f23..10874f545 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -131,7 +131,7 @@ if (isNotCommonProject) { 'MixinConfigs': "${mod_id}.default.mixin.json,${mod_id}.mod.mixin.json", 'FMLCorePlugin': 'com.seibel.distanthorizons.cleanroom.DistantHorizonsLoadingPlugin', 'FMLCorePluginContainsFMLMod': true, - 'FMLAT': "src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg" + 'FMLAT': "${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg" ) } } @@ -188,6 +188,7 @@ if (isNotCommonProject) { if (gradle.ext.minecraft_version.equals("1.12.2")) { cleanroom { loader gradle.ext.cleanroom_loader_version + accessTransformer project.file("src/main/resources/${gradle.ext.accessWidenerVersion}.distanthorizons_at.cfg") } } else { fabric { diff --git a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java index 98293d7c3..700b1d3c7 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/commonMixins/DhUpdateScreenBase.java @@ -1,6 +1,5 @@ package com.seibel.distanthorizons.common.commonMixins; -#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch; import com.seibel.distanthorizons.common.wrappers.gui.updater.UpdateModScreen; import com.seibel.distanthorizons.core.config.Config; @@ -13,7 +12,7 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants; import net.minecraft.client.Minecraft; #if MC_VER <= MC_1_12_2 - +import net.minecraft.client.gui.GuiMainMenu; #else import net.minecraft.client.gui.screens.TitleScreen; #endif @@ -23,8 +22,11 @@ public class DhUpdateScreenBase { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - private static final Minecraft MC = Minecraft #if MC_VER <= MC_1_12_2 .getMinecraft() #else .getInstance() #endif; - + #if MC_VER <= MC_1_12_2 + private static final Minecraft MC = Minecraft.getMinecraft(); + #else + private static final Minecraft MC = Minecraft.getInstance(); + #endif public static void tryShowUpdateScreenAndRunAutoUpdateStartup(Runnable runnable) { @@ -73,10 +75,17 @@ public class DhUpdateScreenBase try { + #if MC_VER <= MC_1_12_2 + MC.displayGuiScreen(new UpdateModScreen( + new GuiMainMenu(), + versionId + )); + #else MC.setScreen(new UpdateModScreen( new TitleScreen(false), versionId )); + #endif } catch (Exception e) { @@ -89,4 +98,3 @@ public class DhUpdateScreenBase } } -#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java index 073b6b242..7a25239e9 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/classicConfig/DhConfigScreen.java @@ -12,19 +12,15 @@ import java.util.function.Predicate; import java.util.regex.Pattern; import com.seibel.distanthorizons.api.enums.config.DisallowSelectingViaConfigGui; -import com.seibel.distanthorizons.common.wrappers.gui.DhScreen; -import com.seibel.distanthorizons.common.wrappers.gui.GuiHelper; -import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget; +import com.seibel.distanthorizons.common.wrappers.gui.*; import com.seibel.distanthorizons.common.wrappers.gui.config.ConfigGuiInfo; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.config.ConfigHandler; import com.seibel.distanthorizons.core.config.types.*; #if MC_VER <= MC_1_12_2 -import com.seibel.distanthorizons.common.wrappers.gui.OnPressed; -#else -import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen; #endif +import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen; import com.seibel.distanthorizons.core.config.types.enums.EConfigCommentTextPosition; import com.seibel.distanthorizons.core.config.types.enums.EConfigValidity; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; @@ -95,6 +91,10 @@ class DhConfigScreen extends DhScreen private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE; + #if MC_VER <= MC_1_12_2 + private static final int changelogButton_id = 101; + #endif + #if MC_VER <= MC_1_12_2 private final GuiScreen parent; #else @@ -176,13 +176,15 @@ class DhConfigScreen extends DhScreen ConfigHandler.INSTANCE.configFileHandler.loadFromFile(); } - #if MC_VER > MC_1_12_2 // Changelog button if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get() // we only have changelogs for stable builds && !ModInfo.IS_DEV_BUILD) { this.addBtn(new TexturedButtonWidget( + #if MC_VER <= MC_1_12_2 + changelogButton_id, + #endif // Where the button is on the screen this.width - 28, this.height - 28, // Width and height of the button @@ -200,6 +202,7 @@ class DhConfigScreen extends DhScreen #endif 20, 20, // Create the button and tell it where to go + #if MC_VER > MC_1_12_2 (buttonWidget) -> { ChangelogScreen changelogScreen = new ChangelogScreen(this); if (changelogScreen.usable) @@ -211,11 +214,15 @@ class DhConfigScreen extends DhScreen LOGGER.warn("Changelog was not able to open"); } }, + #endif // Add a title to the button + #if MC_VER <= MC_1_12_2 + Translatable(ModInfo.ID + ".updater.title").getFormattedText() + #else Translatable(ModInfo.ID + ".updater.title") + #endif )); } - #endif // back button @@ -1003,6 +1010,24 @@ class DhConfigScreen extends DhScreen } #if MC_VER <= MC_1_12_2 + @Override + protected void actionPerformed(GuiButton button) + { + super.actionPerformed(button); + if(button.id == changelogButton_id) + { + ChangelogScreen changelogScreen = new ChangelogScreen(this); + if (changelogScreen.usable) + { + Minecraft.getMinecraft().displayGuiScreen(changelogScreen); + } + else + { + LOGGER.warn("Changelog was not able to open"); + } + } + } + @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws java.io.IOException { @@ -1077,7 +1102,9 @@ class DhConfigScreen extends DhScreen #endif { ConfigHandler.INSTANCE.configFileHandler.saveToFile(); - #if MC_VER > MC_1_12_2 + #if MC_VER <= MC_1_12_2 + // Handled by button to avoid recursive loop + #else Objects.requireNonNull(this.minecraft).setScreen(this.parent); #endif ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java index 9f931db62..6e203480c 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/ChangelogScreen.java @@ -1,6 +1,6 @@ package com.seibel.distanthorizons.common.wrappers.gui.updater; -#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.common.wrappers.gui.DhScreen; +import com.seibel.distanthorizons.common.wrappers.gui.classicConfig.ClassicConfigGUI; import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.IVersionConstants; @@ -8,19 +8,30 @@ import com.seibel.distanthorizons.coreapi.ModInfo; import com.seibel.distanthorizons.core.jar.installer.MarkdownFormatter; import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter; import net.minecraft.client.Minecraft; +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiListExtended; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.text.ITextComponent; +#else import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.ContainerObjectSelectionList; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; +#endif import com.seibel.distanthorizons.core.logging.DhLogger; + #if MC_VER >= MC_1_17_1 import net.minecraft.client.gui.narration.NarratableEntry; #endif -#if MC_VER < MC_1_20_1 +#if MC_VER <= MC_1_12_2 +#elif MC_VER < MC_1_20_1 import net.minecraft.client.gui.GuiComponent; import com.mojang.blaze3d.vertex.PoseStack; #elif MC_VER <= MC_1_21_11 @@ -44,14 +55,22 @@ public class ChangelogScreen extends DhScreen private static final DhLogger LOGGER = new DhLoggerBuilder().build(); + #if MC_VER <= MC_1_12_2 + private GuiScreen parent; + #else private Screen parent; + #endif private String versionID; private List changelog; private TextArea changelogArea; public boolean usable = false; + #if MC_VER <= MC_1_12_2 + public ChangelogScreen(GuiScreen parent) + #else public ChangelogScreen(Screen parent) + #endif { this(parent, null); @@ -86,7 +105,11 @@ public class ChangelogScreen extends DhScreen } } + #if MC_VER <= MC_1_12_2 + public ChangelogScreen(GuiScreen parent, String versionID) + #else public ChangelogScreen(Screen parent, String versionID) + #endif { super(Translatable(ModInfo.ID + ".updater.title")); this.parent = parent; @@ -142,9 +165,18 @@ public class ChangelogScreen extends DhScreen @Override + #if MC_VER <= MC_1_12_2 + public void initGui() + #else protected void init() + #endif { + #if MC_VER <= MC_1_12_2 + super.initGui(); + #else super.init(); + #endif + if (!this.usable) { return; @@ -153,12 +185,19 @@ public class ChangelogScreen extends DhScreen this.addBtn( // Close MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> { + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else this.onClose(); + #endif }) ); - + #if MC_VER <= MC_1_12_2 + this.changelogArea = new TextArea(this.mc, this.width * 2, this.height, 32, 32, 10); + #else this.changelogArea = new TextArea(this.minecraft, this.width * 2, this.height, 32, 32, 10); + #endif for (int i = 0; i < this.changelog.size(); i++) { this.changelogArea.addButton(TextOrLiteral(this.changelog.get(i))); @@ -168,7 +207,9 @@ public class ChangelogScreen extends DhScreen } @Override - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + public void drawScreen(int mouseX, int mouseY, float delta) + #elif MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) #elif MC_VER <= MC_1_21_11 public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) @@ -176,7 +217,9 @@ public class ChangelogScreen extends DhScreen public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + this.drawDefaultBackground(); // Render background + #elif MC_VER < MC_1_20_2 this.renderBackground(matrices); // Render background #elif MC_VER < MC_1_21_6 this.renderBackground(matrices, mouseX, mouseY, delta); // Render background @@ -200,7 +243,9 @@ public class ChangelogScreen extends DhScreen // This is a bit of a hack as we cannot scroll on this area double scrollAmount = ((double) mouseY) / ((double) this.height) * 1.1 * maxScroll; - #if MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 + #if MC_VER <= MC_1_12_2 + this.changelogArea.amountScrolled = (float)scrollAmount; + #elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 this.changelogArea.setScrollAmount(scrollAmount); #elif MC_VER <= MC_1_21_3 this.changelogArea.scrollAmount = scrollAmount; @@ -208,9 +253,13 @@ public class ChangelogScreen extends DhScreen this.changelogArea.setScrollAmount(scrollAmount); #endif - - // render order matters, otherwise on 1.20.6+ the blurred background will render on top of the text - #if MC_VER <= MC_1_21_11 + // render order matters, otherwise on + // 1.12.2- buttons won't render + // 1.20.6+ the blurred background will render on top of the text + #if MC_VER <= MC_1_12_2 + this.changelogArea.drawScreen(mouseX, mouseY, delta); // Render the changelog + super.drawScreen(mouseX, mouseY, delta); // Render the buttons + #elif MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); // Render the buttons this.changelogArea.render(matrices, mouseX, mouseY, delta); // Render the changelog #else @@ -218,18 +267,44 @@ public class ChangelogScreen extends DhScreen this.changelogArea.extractRenderState(matrices, mouseX, mouseY, delta); // Render the changelog #endif - this.DhDrawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 0xFFFFFF); // Render title + // Render title + #if MC_VER <= MC_1_12_2 + this.DhDrawCenteredString(this.title, this.width / 2, 15, 0xFFFFFF); + #else + this.DhDrawCenteredString(matrices, this.font, this.title, this.width / 2, 15, 0xFFFFFF); + #endif } @Override + #if MC_VER <= MC_1_12_2 + public void onGuiClosed() + #else public void onClose() + #endif { - Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Goto the parent screen + // Go to the parent screen + #if MC_VER <= MC_1_12_2 + // Handled by button to avoid recursive loop + #else + Objects.requireNonNull(this.minecraft).setScreen(this.parent); + #endif } + #if MC_VER <= MC_1_12_2 + public static class TextArea extends GuiListExtended + #else public static class TextArea extends ContainerObjectSelectionList + #endif { + #if MC_VER <= MC_1_12_2 + public List children = new ArrayList<>(); + #endif + + #if MC_VER <= MC_1_12_2 + FontRenderer textRenderer; + #else Font textRenderer; + #endif public TextArea(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing) { @@ -238,63 +313,129 @@ public class ChangelogScreen extends DhScreen #else super(minecraftClient, canvasWidth, canvasHeight - (topMargin + botMargin), topMargin, itemSpacing); #endif + this.centerListVertically = false; + #if MC_VER <= MC_1_12_2 + this.textRenderer = minecraftClient.fontRenderer; + #else this.textRenderer = minecraftClient.font; + #endif } + #if MC_VER <= MC_1_12_2 + public void addButton(ITextComponent text) + #else public void addButton(Component text) + #endif { + #if MC_VER <= MC_1_12_2 + this.children.add(ButtonEntry.create(text)); + #else this.addEntry(ButtonEntry.create(text)); + #endif } @Override + #if MC_VER <= MC_1_12_2 + public int getListWidth() + #else public int getRowWidth() + #endif { - return 10000; + return 10_000; } + #if MC_VER <= MC_1_12_2 + @Override + protected int getSize() + { + return this.children.size(); + } + + @Override + public IGuiListEntry getListEntry(int index) + { + return this.children.get(index); + } + #endif + } + #if MC_VER <= MC_1_12_2 + public static class ButtonEntry implements GuiListExtended.IGuiListEntry + #else public static class ButtonEntry extends ContainerObjectSelectionList.Entry + #endif { + #if MC_VER <= MC_1_12_2 + private static final FontRenderer textRenderer = Minecraft.getMinecraft().fontRenderer; + #else private static final Font textRenderer = Minecraft.getInstance().font; + #endif + + #if MC_VER <= MC_1_12_2 + private final ITextComponent text; + #else private final Component text; + #endif + + #if MC_VER <= MC_1_12_2 + private final List children = new ArrayList<>(); + #else private final List children = new ArrayList<>(); + #endif + #if MC_VER <= MC_1_12_2 + private ButtonEntry(ITextComponent text) { this.text = text; } + #else private ButtonEntry(Component text) { this.text = text; } + #endif + #if MC_VER <= MC_1_12_2 + public static ButtonEntry create(ITextComponent text) + #else public static ButtonEntry create(Component text) + #endif { return new ButtonEntry(text); } - #if MC_VER < MC_1_20_1 @Override + #if MC_VER <= MC_1_12_2 + public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected, float tickDelta) + { textRenderer.drawString(text.getFormattedText(), 12, y + 5, 0xFFFFFF); } + #elif MC_VER < MC_1_20_1 public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { GuiComponent.drawString(matrices, textRenderer, text, 12, y + 5, 0xFFFFFF); } #elif MC_VER < MC_1_21_9 - @Override public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); } #elif MC_VER <= MC_1_21_11 - @Override public void renderContent(GuiGraphics matrices, int y, int x, boolean hovered, float tickDelta) { matrices.drawString(textRenderer, this.text, 12, y + 5, 0xFFFFFF); } #else - @Override public void extractContent(GuiGraphicsExtractor matrices, int y, int x, boolean hovered, float tickDelta) { matrices.text(textRenderer, this.text, 12, y + 5, 0xFFFFFF); } #endif + #if MC_VER > MC_1_12_2 @Override public List children() { return this.children; } + #endif #if MC_VER >= MC_1_17_1 @Override public List narratables() { return this.children; } #endif - - + #if MC_VER <= MC_1_12_2 + @Override + public void updatePosition(int slotIndex, int x, int y, float partialTicks) { } + + @Override + public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY) { return false; } + + @Override + public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) { } + #endif } } -#endif \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java index d254c0601..26e68a166 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/updater/UpdateModScreen.java @@ -1,5 +1,4 @@ package com.seibel.distanthorizons.common.wrappers.gui.updater; -#if MC_VER > MC_1_12_2 import com.seibel.distanthorizons.api.enums.config.EDhApiUpdateBranch; import com.seibel.distanthorizons.common.wrappers.gui.DhScreen; import com.seibel.distanthorizons.common.wrappers.gui.TexturedButtonWidget; @@ -10,10 +9,14 @@ import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter; import com.seibel.distanthorizons.core.jar.updater.SelfUpdater; import com.seibel.distanthorizons.core.logging.DhLogger; - +#if MC_VER <= MC_1_12_2 +import net.minecraft.client.gui.GuiScreen; +#else import net.minecraft.client.gui.screens.Screen; +#endif -#if MC_VER < MC_1_20_1 +#if MC_VER <= MC_1_12_2 +#elif MC_VER < MC_1_20_1 import com.mojang.blaze3d.vertex.PoseStack; #elif MC_VER <= MC_1_21_11 import net.minecraft.client.gui.GuiGraphics; @@ -21,7 +24,9 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.GuiGraphicsExtractor; #endif -#if MC_VER <= MC_1_21_10 +#if MC_VER <= MC_1_12_2 +import net.minecraft.util.ResourceLocation; +#elif MC_VER <= MC_1_21_10 import net.minecraft.resources.ResourceLocation; #else import net.minecraft.resources.Identifier; @@ -40,15 +45,26 @@ public class UpdateModScreen extends DhScreen { private static final DhLogger LOGGER = new DhLoggerBuilder().build(); - + #if MC_VER <= MC_1_12_2 + private GuiScreen parent; + #else private Screen parent; + #endif private String newVersionID; private String currentVer; private String nextVer; - + #if MC_VER <= MC_1_12_2 + private static final int logoButton_id = 100; + private static final int changelogButton_id = 101; + #endif + + #if MC_VER <= MC_1_12_2 + public UpdateModScreen(GuiScreen parent, String newVersionID) throws IllegalArgumentException + #else public UpdateModScreen(Screen parent, String newVersionID) throws IllegalArgumentException + #endif { super(Translatable(ModInfo.ID + ".updater.title")); this.parent = parent; @@ -76,10 +92,17 @@ public class UpdateModScreen extends DhScreen } @Override + #if MC_VER <= MC_1_12_2 + public void initGui() + #else protected void init() + #endif { + #if MC_VER <= MC_1_12_2 + super.initGui(); + #else super.init(); - + #endif try { @@ -87,6 +110,9 @@ public class UpdateModScreen extends DhScreen // Logo image this.addBtn(new TexturedButtonWidget( + #if MC_VER <= MC_1_12_2 + logoButton_id, + #endif // Where the button is on the screen this.width / 2 - 95, this.height / 2 - 110, // Width and height of the button @@ -105,9 +131,15 @@ public class UpdateModScreen extends DhScreen 195, 65, // Create the button and tell it where to go // For now it goes to the client option by default + #if MC_VER > MC_1_12_2 (buttonWidget) -> LOGGER.info("Nice, you found an Easter egg :)"), + #endif // Add a title to the button + #if MC_VER <= MC_1_12_2 + Translatable(ModInfo.ID + ".updater.title").getFormattedText(), + #else Translatable(ModInfo.ID + ".updater.title"), + #endif // Dont render the background of the button false )); @@ -120,6 +152,9 @@ public class UpdateModScreen extends DhScreen if (!ModInfo.IS_DEV_BUILD) { this.addBtn(new TexturedButtonWidget( + #if MC_VER <= MC_1_12_2 + changelogButton_id, + #endif // Where the button is on the screen this.width / 2 - 97, this.height / 2 + 8, // Width and height of the button @@ -137,9 +172,15 @@ public class UpdateModScreen extends DhScreen #endif 20, 20, // Create the button and tell it where to go + #if MC_VER > MC_1_12_2 (buttonWidget) -> Objects.requireNonNull(this.minecraft).setScreen(new ChangelogScreen(this, this.newVersionID)), + #endif // Add a title to the button + #if MC_VER <= MC_1_12_2 + Translatable(ModInfo.ID + ".updater.title").getFormattedText() + #else Translatable(ModInfo.ID + ".updater.title") + #endif )); } @@ -147,32 +188,50 @@ public class UpdateModScreen extends DhScreen this.addBtn( // Update MakeBtn(Translatable(ModInfo.ID + ".updater.update"), this.width / 2 - 75, this.height / 2 + 8, 150, 20, (btn) -> { SelfUpdater.updateMod(); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else this.onClose(); + #endif }) ); this.addBtn( // Silent update MakeBtn(Translatable(ModInfo.ID + ".updater.silent"), this.width / 2 - 75, this.height / 2 + 30, 150, 20, (btn) -> { Config.Client.Advanced.AutoUpdater.enableSilentUpdates.set(true); SelfUpdater.updateMod(); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else this.onClose(); + #endif }) ); this.addBtn( // Later (not now) MakeBtn(Translatable(ModInfo.ID + ".updater.later"), this.width / 2 + 2, this.height / 2 + 70, 100, 20, (btn) -> { + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else this.onClose(); + #endif }) ); this.addBtn( // Never MakeBtn(Translatable(ModInfo.ID + ".updater.never"), this.width / 2 - 102, this.height / 2 + 70, 100, 20, (btn) -> { Config.Client.Advanced.AutoUpdater.enableAutoUpdater.set(false); + #if MC_VER <= MC_1_12_2 + Objects.requireNonNull(this.mc).displayGuiScreen(this.parent); + #else this.onClose(); + #endif }) ); } @Override - #if MC_VER < MC_1_20_1 + #if MC_VER <= MC_1_12_2 + public void drawScreen(int mouseX, int mouseY, float delta) + #elif MC_VER < MC_1_20_1 public void render(PoseStack matrices, int mouseX, int mouseY, float delta) #elif MC_VER <= MC_1_21_11 public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta) @@ -180,7 +239,9 @@ public class UpdateModScreen extends DhScreen public void extractRenderState(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta) #endif { - #if MC_VER < MC_1_20_2 + #if MC_VER <= MC_1_12_2 + this.drawDefaultBackground(); // Render background + #elif MC_VER < MC_1_20_2 this.renderBackground(matrices); // Render background #elif MC_VER < MC_1_21_6 this.renderBackground(matrices, mouseX, mouseY, delta); // Render background @@ -188,14 +249,19 @@ public class UpdateModScreen extends DhScreen // background blur is already being rendered, rendering again causes the game to crash #endif - #if MC_VER <= MC_1_21_11 + #if MC_VER <= MC_1_12_2 + super.drawScreen(mouseX, mouseY, delta); // Render the buttons + #elif MC_VER <= MC_1_21_11 super.render(matrices, mouseX, mouseY, delta); // Render the buttons #else super.extractRenderState(matrices, mouseX, mouseY, delta); #endif // Render the text's - this.DhDrawCenteredString(matrices, this.font, + this.DhDrawCenteredString( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif Translatable(ModInfo.ID + ".updater.text1"), this.width / 2, this.height / 2 - 35, #if MC_VER < MC_1_21_6 @@ -204,7 +270,10 @@ public class UpdateModScreen extends DhScreen 0xFFFFFFFF // ARGB #endif ); - this.DhDrawCenteredString(matrices, this.font, + this.DhDrawCenteredString( + #if MC_VER > MC_1_12_2 + matrices, this.font, + #endif Translatable(ModInfo.ID + ".updater.text2", this.currentVer, this.nextVer), this.width / 2, this.height / 2 - 20, #if MC_VER < MC_1_21_6 @@ -216,10 +285,18 @@ public class UpdateModScreen extends DhScreen } @Override + #if MC_VER <= MC_1_12_2 + public void onGuiClosed() + #else public void onClose() + #endif { - Objects.requireNonNull(this.minecraft).setScreen(this.parent); // Go to the parent screen + // Go to the parent screen + #if MC_VER <= MC_1_12_2 + // Handled by button to avoid recursive loop + #else + Objects.requireNonNull(this.minecraft).setScreen(this.parent); + #endif } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/common/src/main/resources/1_12_2.distanthorizons_at.cfg b/common/src/main/resources/1_12_2.distanthorizons_at.cfg index 148f0fb86..015e604b1 100644 --- a/common/src/main/resources/1_12_2.distanthorizons_at.cfg +++ b/common/src/main/resources/1_12_2.distanthorizons_at.cfg @@ -1,3 +1,4 @@ public net.minecraft.client.renderer.EntityRenderer getFOVModifier(FZ)F public net.minecraft.client.renderer.ActiveRenderInfo MODELVIEW -public net.minecraft.client.renderer.ActiveRenderInfo PROJECTION \ No newline at end of file +public net.minecraft.client.renderer.ActiveRenderInfo PROJECTION +public net.minecraft.client.gui.GuiSlot amountScrolled \ No newline at end of file