diff --git a/buildSrc/src/main/groovy/dh-loader.gradle b/buildSrc/src/main/groovy/dh-loader.gradle index ef135bf68..5e57cc02f 100644 --- a/buildSrc/src/main/groovy/dh-loader.gradle +++ b/buildSrc/src/main/groovy/dh-loader.gradle @@ -578,7 +578,8 @@ if (isNotCommonProject) { new JsonSlurper() .parse(input) .each { key, value -> - writer.writeLine("${key}=${value.toString().replace("%", "%%").replace("\n", "\\n")}") + def text = value.toString().replaceAll(/%(?!((\d+)\$)?s|%)/, "%%").replace("\n", "\\n") + writer.writeLine("${key}=${text}") } } } diff --git a/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinMinecraft.java b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinMinecraft.java new file mode 100644 index 000000000..b62b1a810 --- /dev/null +++ b/cleanroom/src/main/java/com/seibel/distanthorizons/cleanroom/mixins/client/MixinMinecraft.java @@ -0,0 +1,24 @@ +package com.seibel.distanthorizons.cleanroom.mixins.client; + +import com.seibel.distanthorizons.common.commonMixins.DhUpdateScreenBase; +import com.seibel.distanthorizons.core.config.Config; +import com.seibel.distanthorizons.coreapi.ModInfo; +import net.minecraft.client.Minecraft; +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(Minecraft.class) +public class MixinMinecraft +{ + + @Inject(method = "init", at = @At("TAIL")) + private void onInit(CallbackInfo ci) + { + if(Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get() && !ModInfo.IS_DEV_BUILD) // weird lib class not found error can occur if we don't check if we are in dev + { + DhUpdateScreenBase.tryShowUpdateScreenAndRunAutoUpdateStartup(null); + } + } +} diff --git a/cleanroom/src/main/resources/distanthorizons.default.mixin.json b/cleanroom/src/main/resources/distanthorizons.default.mixin.json index 148bb7f05..38ac125f8 100644 --- a/cleanroom/src/main/resources/distanthorizons.default.mixin.json +++ b/cleanroom/src/main/resources/distanthorizons.default.mixin.json @@ -1,19 +1,20 @@ { - "required": true, - "package": "com.seibel.distanthorizons.cleanroom.mixins", - "compatibilityLevel": "JAVA_8", - "target": "@env(DEFAULT)", - "mixins": [ - "common.MixinThreadedFileIOBase" - ], - "minVersion": "0.8.7", - "server": [ - "server.MixinEntityPlayerMP" - ], - "client": [ - "client.MixinEntityRenderer", - "client.MixinNetHandlerPlayClient", - "client.MixinOptionsScreen", - "client.MixinRenderGlobal" - ] + "required": true, + "package": "com.seibel.distanthorizons.cleanroom.mixins", + "compatibilityLevel": "JAVA_8", + "target": "@env(DEFAULT)", + "mixins": [ + "common.MixinThreadedFileIOBase" + ], + "minVersion": "0.8.7", + "server": [ + "server.MixinEntityPlayerMP" + ], + "client": [ + "client.MixinEntityRenderer", + "client.MixinMinecraft", + "client.MixinNetHandlerPlayClient", + "client.MixinOptionsScreen", + "client.MixinRenderGlobal" + ] } \ No newline at end of file diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java index 5609f5749..00faeac1a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/TexturedButtonWidget.java @@ -155,16 +155,21 @@ public class TexturedButtonWidget extends Button @Override public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) { if (this.visible) { - //Render vanilla background - mc.getTextureManager().bindTexture(BUTTON_TEXTURES); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; int i = this.getHoverState(this.hovered); + GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height); - this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + + if (this.renderBackground) + { + //Render vanilla background + mc.getTextureManager().bindTexture(BUTTON_TEXTURES); + this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height); + this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); + } //Render DH texture mc.getTextureManager().bindTexture(textureResourceLocation); 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 5e0f0d1d5..619034ad6 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 @@ -1030,7 +1030,7 @@ class DhConfigScreen extends DhScreen ChangelogScreen changelogScreen = new ChangelogScreen(this); if (changelogScreen.usable) { - Minecraft.getMinecraft().displayGuiScreen(changelogScreen); + DhScreenUtil.setScreen(changelogScreen); } else { 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 f3e06b5cd..253c1552c 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 @@ -186,7 +186,7 @@ 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); + DhScreenUtil.setScreen(this.parent); #else this.onClose(); #endif 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 099c3f04c..cd001a728 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 @@ -11,6 +11,7 @@ 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.GuiButton; import net.minecraft.client.gui.GuiScreen; #else import net.minecraft.client.gui.screens.Screen; @@ -298,4 +299,24 @@ public class UpdateModScreen extends DhScreen #endif } + #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) + { + DhScreenUtil.setScreen(changelogScreen); + } + else + { + LOGGER.warn("Changelog was not able to open"); + } + } + } + #endif + } \ No newline at end of file