From c0796d82aa731a9462b65e453595a663f532f798 Mon Sep 17 00:00:00 2001 From: HypherionMC Date: Mon, 12 Jul 2021 14:17:36 +0200 Subject: [PATCH] Ported to 1.17 and updated Cloth Config/Mod Menu dependencies --- build.gradle | 35 ++- gradle.properties | 12 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../CustomSplashScreenClient.java | 11 +- .../config/CustomSplashScreenConfig.java | 9 +- .../config/ModMenuIntegration.java | 2 +- .../mixin/SplashScreenMixin.java | 249 ++++++++++-------- src/main/resources/fabric.mod.json | 4 +- 8 files changed, 177 insertions(+), 147 deletions(-) diff --git a/build.gradle b/build.gradle index 6ae580f..80207b6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ plugins { - id 'fabric-loom' version '0.5-SNAPSHOT' + id 'fabric-loom' version '0.8-SNAPSHOT' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_16 +targetCompatibility = JavaVersion.VERSION_16 archivesBaseName = project.archives_base_name version = project.mod_version @@ -15,38 +15,33 @@ minecraft { repositories { maven { url "https://jitpack.io" } + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/" } } dependencies { //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modCompile "net.fabricmc:fabric-loader:${project.loader_version}" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") { + exclude(group: "net.fabricmc.fabric-api") + } - modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - - modImplementation ("me.sargunvohra.mcmods:autoconfig1u:${project.auto_config_version}"){ - exclude module: "fabric-api" - } - modImplementation ("me.shedaniel.cloth:config-2:${project.cloth_config_version}"){ - exclude module: "fabric-api" - } modImplementation ("io.github.prospector:modmenu:${project.mod_menu_version}"){ - exclude module: "fabric-api" - } + exclude(group: "net.fabricmc.fabric-api") + } } processResources { inputs.property "version", project.version - from(sourceSets.main.resources.srcDirs) { - include "fabric.mod.json" + filesMatching("fabric.mod.json") { expand "version": project.version } - - from(sourceSets.main.resources.srcDirs) { - exclude "fabric.mod.json" - } } // ensure that the encoding is set to UTF-8, no matter what the system default is diff --git a/gradle.properties b/gradle.properties index f2844e9..cb13fb2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.16.4 - yarn_mappings=1.16.4+build.7 - loader_version=0.10.8 + minecraft_version=1.17.1 + yarn_mappings=1.17.1+build.10 + loader_version=0.11.6 # Mod Properties mod_version = 1.0.0 @@ -14,8 +14,8 @@ org.gradle.jvmargs=-Xmx1G # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.26.1+1.16 + fabric_version=0.36.1+1.17 auto_config_version = 3.3.1 - cloth_config_version = 4.8.3 - mod_menu_version = 1.14.6+build.31 \ No newline at end of file + cloth_config_version = 5.0.34 + mod_menu_version = 2.0.0-beta.1+build.2 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4b7e1f3..f371643 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/eu/midnightdust/customsplashscreen/CustomSplashScreenClient.java b/src/main/java/eu/midnightdust/customsplashscreen/CustomSplashScreenClient.java index 0aa0d84..32f293b 100644 --- a/src/main/java/eu/midnightdust/customsplashscreen/CustomSplashScreenClient.java +++ b/src/main/java/eu/midnightdust/customsplashscreen/CustomSplashScreenClient.java @@ -1,20 +1,13 @@ package eu.midnightdust.customsplashscreen; import eu.midnightdust.customsplashscreen.config.CustomSplashScreenConfig; -import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; -import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer; +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer; import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderingRegistry; -import net.fabricmc.fabric.impl.client.indigo.renderer.helper.TextureHelper; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.texture.TextureManager; -import net.minecraft.client.texture.TextureUtil; -import net.minecraft.data.client.model.Texture; -import org.jetbrains.annotations.Nullable; import java.io.*; import java.nio.file.*; -import java.util.logging.FileHandler; public class CustomSplashScreenClient implements ClientModInitializer { diff --git a/src/main/java/eu/midnightdust/customsplashscreen/config/CustomSplashScreenConfig.java b/src/main/java/eu/midnightdust/customsplashscreen/config/CustomSplashScreenConfig.java index f66e0fc..f28e0f7 100644 --- a/src/main/java/eu/midnightdust/customsplashscreen/config/CustomSplashScreenConfig.java +++ b/src/main/java/eu/midnightdust/customsplashscreen/config/CustomSplashScreenConfig.java @@ -1,9 +1,9 @@ package eu.midnightdust.customsplashscreen.config; -import me.sargunvohra.mcmods.autoconfig1u.ConfigData; -import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; -import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry; -import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment; +import me.shedaniel.autoconfig.ConfigData; +import me.shedaniel.autoconfig.annotation.Config; +import me.shedaniel.autoconfig.annotation.ConfigEntry; +import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment; @Config(name = "customsplashscreen") public class CustomSplashScreenConfig implements ConfigData { @@ -40,7 +40,6 @@ public class CustomSplashScreenConfig implements ConfigData { @ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON) public BossBarType bossBarType = BossBarType.NOTCHED_6; - @ConfigEntry.Gui.CollapsibleObject public Textures textures = new Textures(); diff --git a/src/main/java/eu/midnightdust/customsplashscreen/config/ModMenuIntegration.java b/src/main/java/eu/midnightdust/customsplashscreen/config/ModMenuIntegration.java index f4585d4..c3e28bc 100644 --- a/src/main/java/eu/midnightdust/customsplashscreen/config/ModMenuIntegration.java +++ b/src/main/java/eu/midnightdust/customsplashscreen/config/ModMenuIntegration.java @@ -2,7 +2,7 @@ package eu.midnightdust.customsplashscreen.config; import io.github.prospector.modmenu.api.ConfigScreenFactory; import io.github.prospector.modmenu.api.ModMenuApi; -import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; +import me.shedaniel.autoconfig.AutoConfig; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/src/main/java/eu/midnightdust/customsplashscreen/mixin/SplashScreenMixin.java b/src/main/java/eu/midnightdust/customsplashscreen/mixin/SplashScreenMixin.java index 67b9372..17c0fee 100644 --- a/src/main/java/eu/midnightdust/customsplashscreen/mixin/SplashScreenMixin.java +++ b/src/main/java/eu/midnightdust/customsplashscreen/mixin/SplashScreenMixin.java @@ -1,5 +1,6 @@ package eu.midnightdust.customsplashscreen.mixin; +import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import eu.midnightdust.customsplashscreen.CustomSplashScreenClient; import eu.midnightdust.customsplashscreen.config.CustomSplashScreenConfig; @@ -8,9 +9,10 @@ import eu.midnightdust.customsplashscreen.texture.ConfigTexture; import eu.midnightdust.customsplashscreen.texture.EmptyTexture; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.BackgroundHelper; -import net.minecraft.client.gui.screen.SplashScreen; +import net.minecraft.client.gui.screen.SplashOverlay; +import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.resource.ResourceReloadMonitor; +import net.minecraft.resource.ResourceReload; import net.minecraft.util.Identifier; import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; @@ -19,25 +21,28 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static net.minecraft.client.gui.DrawableHelper.drawTexture; +import java.util.Optional; +import java.util.function.Consumer; -@Mixin(SplashScreen.class) +import static net.minecraft.client.gui.DrawableHelper.drawTexture; +import static net.minecraft.client.gui.DrawableHelper.fill; + +@Mixin(SplashOverlay.class) public class SplashScreenMixin { - @Shadow @Final private static Identifier LOGO; + @Shadow @Final static Identifier LOGO; @Shadow @Final private MinecraftClient client; @Shadow @Final private boolean reloading; - @Shadow private long applyCompleteTime; - @Shadow @Final private ResourceReloadMonitor reloadMonitor; - @Shadow private long prepareCompleteTime; + @Shadow @Final private ResourceReload reload; @Shadow private float progress; + @Shadow private long reloadCompleteTime; + @Shadow private long reloadStartTime; + @Shadow @Final private Consumer> exceptionHandler; private static final CustomSplashScreenConfig CS_CONFIG = CustomSplashScreenClient.CS_CONFIG; - private static final Identifier EMPTY_TEXTURE = new Identifier("empty.png"); private static final Identifier MOJANG_TEXTURE = new Identifier(CS_CONFIG.textures.MojangLogo); private static final Identifier ASPECT_1to1_TEXTURE = new Identifier(CS_CONFIG.textures.Aspect1to1Logo); @@ -46,7 +51,7 @@ public class SplashScreenMixin { private static final Identifier CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE = new Identifier(CS_CONFIG.textures.CustomBarBackgroundTexture); private static final Identifier BACKGROUND_TEXTURE = new Identifier(CS_CONFIG.textures.BackgroundTexture); - @Inject(method = "init(Lnet/minecraft/client/MinecraftClient;)V", at = @At("HEAD"), cancellable=true) + @Inject(method = "init(Lnet/minecraft/client/MinecraftClient;)V", at = @At("HEAD"), cancellable = true) private static void init(MinecraftClient client, CallbackInfo ci) { // Load our custom textures at game start // if (CS_CONFIG.logoStyle == CustomSplashScreenConfig.LogoStyle.Mojang) { client.getTextureManager().registerTexture(LOGO, new BlurredConfigTexture(MOJANG_TEXTURE)); @@ -63,113 +68,134 @@ public class SplashScreenMixin { ci.cancel(); } - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/TextureManager;bindTexture(Lnet/minecraft/util/Identifier;)V",shift = At.Shift.BEFORE), method = "render") - private void renderBackground(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { // Render our background image // + @Inject(at = @At("TAIL"), method = "render", cancellable = false) + public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { + int i = this.client.getWindow().getScaledWidth(); + int j = this.client.getWindow().getScaledHeight(); long l = Util.getMeasuringTimeMs(); - if (this.reloading && (this.reloadMonitor.isPrepareStageComplete() || this.client.currentScreen != null) && this.prepareCompleteTime == -1L) { - this.prepareCompleteTime = l; + if (this.reloading && this.reloadStartTime == -1L) { + this.reloadStartTime = l; } - float f = this.applyCompleteTime > -1L ? (float)(l - this.applyCompleteTime) / 1000.0F : -1.0F; - float g = this.prepareCompleteTime > -1L ? (float)(l - this.prepareCompleteTime) / 500.0F : -1.0F; - float o; - if (f >= 1.0F) { - o = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); - } else if (this.reloading) { - o = MathHelper.clamp(g, 0.0F, 1.0F); - } else { - o = 1.0F; - } - - int maxX = this.client.getWindow().getScaledWidth(); - int maxY = this.client.getWindow().getScaledHeight(); - - if (CS_CONFIG.backgroundImage) { - client.getTextureManager().bindTexture(BACKGROUND_TEXTURE); - RenderSystem.enableBlend(); - RenderSystem.alphaFunc(516, 0.0F); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, o); - drawTexture(matrices, 0, 0, 0, 0, 0, maxX, maxY, maxY, maxX); - RenderSystem.defaultBlendFunc(); - RenderSystem.defaultAlphaFunc(); - RenderSystem.disableBlend(); - } - } - - @Inject(at = @At("TAIL"), method = "render") - private void renderLogo(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { // Render our 1 to 1 logo // - long l = Util.getMeasuringTimeMs(); - if (this.reloading && (this.reloadMonitor.isPrepareStageComplete() || this.client.currentScreen != null) && this.prepareCompleteTime == -1L) { - this.prepareCompleteTime = l; - } - float f = this.applyCompleteTime > -1L ? (float)(l - this.applyCompleteTime) / 1000.0F : -1.0F; - float g = this.prepareCompleteTime > -1L ? (float)(l - this.prepareCompleteTime) / 500.0F : -1.0F; - float o; + float f = this.reloadCompleteTime > -1L ? (float)(l - this.reloadCompleteTime) / 1000.0F : -1.0F; + float g = this.reloadStartTime > -1L ? (float)(l - this.reloadStartTime) / 500.0F : -1.0F; + float s; int m; + + // Render our custom color if (f >= 1.0F) { - o = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); + if (this.client.currentScreen != null) { + this.client.currentScreen.render(matrices, 0, 0, delta); + } + + m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F); + fill(matrices, 0, 0, i, j, withAlpha(m)); + s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); } else if (this.reloading) { - o = MathHelper.clamp(g, 0.0F, 1.0F); + if (this.client.currentScreen != null && g < 1.0F) { + this.client.currentScreen.render(matrices, mouseX, mouseY, delta); + } + + m = MathHelper.ceil(MathHelper.clamp((double)g, 0.15D, 1.0D) * 255.0D); + fill(matrices, 0, 0, i, j, withAlpha(m)); + s = MathHelper.clamp(g, 0.0F, 1.0F); } else { - o = 1.0F; + m = getBackgroundColor(); + float p = (float)(m >> 16 & 255) / 255.0F; + float q = (float)(m >> 8 & 255) / 255.0F; + float r = (float)(m & 255) / 255.0F; + GlStateManager._clearColor(p, q, r, 1.0F); + GlStateManager._clear(16384, MinecraftClient.IS_SYSTEM_MAC); + s = 1.0F; } m = (int)((double)this.client.getWindow().getScaledWidth() * 0.5D); + int u = (int)((double)this.client.getWindow().getScaledHeight() * 0.5D); + double d = Math.min((double)this.client.getWindow().getScaledWidth() * 0.75D, (double)this.client.getWindow().getScaledHeight()) * 0.25D; + int v = (int)(d * 0.5D); + double e = d * 4.0D; + int w = (int)(e * 0.5D); + + // Render our custom background image + if (CS_CONFIG.backgroundImage) { + RenderSystem.setShaderTexture(0, BACKGROUND_TEXTURE); + RenderSystem.enableBlend(); + RenderSystem.blendEquation(32774); + RenderSystem.blendFunc(770, 1); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s); + drawTexture(matrices, 0, 0, 0, 0, 0, i, j, j, i); + RenderSystem.defaultBlendFunc(); + RenderSystem.disableBlend(); + } + + // Render the Logo + RenderSystem.setShaderTexture(0, CustomSplashScreenClient.CS_CONFIG.logoStyle == CustomSplashScreenConfig.LogoStyle.Aspect1to1 ? ASPECT_1to1_TEXTURE : LOGO); + RenderSystem.enableBlend(); + RenderSystem.setShader(GameRenderer::getPositionTexShader); if (CustomSplashScreenClient.CS_CONFIG.logoStyle == CustomSplashScreenConfig.LogoStyle.Aspect1to1) { - double d = Math.min((double)this.client.getWindow().getScaledWidth() * 0.75D, this.client.getWindow().getScaledHeight()) * 0.25D; - int r = (int)(d * 0.5D); - double e = d * 4.0D; - int s = (int)(e * 0.5D); - client.getTextureManager().bindTexture(ASPECT_1to1_TEXTURE); - RenderSystem.enableBlend(); - RenderSystem.alphaFunc(516, 0.0F); - RenderSystem.color4f(1.0F, 1.0F, 1.0F, o); - drawTexture(matrices, m - (s / 2), r, s, s, 0, 0, 512, 512, 512, 512); - RenderSystem.defaultBlendFunc(); - RenderSystem.defaultAlphaFunc(); - RenderSystem.disableBlend(); + RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s); + drawTexture(matrices, m - (w / 2), v, w, w, 0, 0, 512, 512, 512, 512); + } else if (CustomSplashScreenClient.CS_CONFIG.logoStyle == CustomSplashScreenConfig.LogoStyle.Mojang) { + RenderSystem.blendFunc(770, 1); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s); + drawTexture(matrices, m - w, u - v, w, (int)d, -0.0625F, 0.0F, 120, 60, 120, 120); + drawTexture(matrices, m, u - v, w, (int)d, 0.0625F, 60.0F, 120, 60, 120, 120); + } + + RenderSystem.defaultBlendFunc(); + RenderSystem.disableBlend(); + + int x = (int)((double)this.client.getWindow().getScaledHeight() * 0.8325D); + float y = this.reload.getProgress(); + this.progress = MathHelper.clamp(this.progress * 0.95F + y * 0.050000012F, 0.0F, 1.0F); + if (f < 1.0F) { + this.renderProgressBar(matrices, i / 2 - w, x - 5, i / 2 + w, x + 5, 1.0F - MathHelper.clamp(f, 0.0F, 1.0F), null); + } + + if (f >= 2.0F) { + this.client.setOverlay(null); + } + + if (this.reloadCompleteTime == -1L && this.reload.isComplete() && (!this.reloading || g >= 2.0F)) { + try { + this.reload.throwException(); + this.exceptionHandler.accept(Optional.empty()); + } catch (Throwable var23) { + this.exceptionHandler.accept(Optional.of(var23)); + } + + this.reloadCompleteTime = Util.getMeasuringTimeMs(); + if (this.client.currentScreen != null) { + this.client.currentScreen.init(this.client, this.client.getWindow().getScaledWidth(), this.client.getWindow().getScaledHeight()); + } } } - @ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashScreen;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V"), index = 5) - private int modifyBackgroundColor(int color) { // Set the Background Color to our configured value // - long l = Util.getMeasuringTimeMs(); - if (this.reloading && (this.reloadMonitor.isPrepareStageComplete() || this.client.currentScreen != null) && this.prepareCompleteTime == -1L) { - this.prepareCompleteTime = l; - } - float f = this.applyCompleteTime > -1L ? (float)(l - this.applyCompleteTime) / 1000.0F : -1.0F; - int m; - m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F); - + private static int getBackgroundColor() { if (CS_CONFIG.backgroundImage) { return BackgroundHelper.ColorMixer.getArgb(0, 0, 0, 0); } else { - return CustomSplashScreenClient.CS_CONFIG.backgroundColor | m << 24; + return CustomSplashScreenClient.CS_CONFIG.backgroundColor; } } - @ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashScreen;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V"), index = 5) - private int modifyProgressFrame(int color) { // Set the Progress Bar Frame Color to our configured value // - if (CustomSplashScreenClient.CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.BossBar || CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.Hidden) { - return BackgroundHelper.ColorMixer.getArgb(0, 0, 0, 0); - } - else return CustomSplashScreenClient.CS_CONFIG.progressFrameColor | 255 << 24; - } - @ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashScreen;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V", ordinal = 4), index = 5) - private int modifyProgressColor(int color) { // Set the Progress Bar Color to our configured value // - if (CustomSplashScreenClient.CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.BossBar || CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.Hidden || CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.Custom) { - return BackgroundHelper.ColorMixer.getArgb(0, 0, 0, 0); - } - else return CustomSplashScreenClient.CS_CONFIG.progressBarColor | 255 << 24; + private static int withAlpha(int alpha) { + return getBackgroundColor() | alpha << 24; } - @Inject(at = @At("TAIL"), method = "renderProgressBar", cancellable = true) - private void renderCSProgressBar(MatrixStack matrices, int x1, int y1, int x2, int y2, float opacity, CallbackInfo ci) { // Render our custom Progress Bar // + @Inject(at = @At("TAIL"), method = "renderProgressBar", cancellable = false) + private void renderProgressBar(MatrixStack matrices, int x1, int y1, int x2, int y2, float opacity, CallbackInfo ci) { int i = MathHelper.ceil((float)(x2 - x1 - 2) * this.progress); - if (CustomSplashScreenClient.CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.BossBar) { // Bossbar Style Progress Bar // - client.getTextureManager().bindTexture(BOSS_BAR_TEXTURE); + + // Bossbar Progress Bar + if (CustomSplashScreenClient.CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.BossBar) { + RenderSystem.setShaderTexture(0, BOSS_BAR_TEXTURE); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + int overlay = 0; if (CustomSplashScreenClient.CS_CONFIG.bossBarType == CustomSplashScreenConfig.BossBarType.NOTCHED_6) {overlay = 93;} @@ -179,27 +205,44 @@ public class SplashScreenMixin { int bbWidth = (int) ((x2 - x1+1) * 1.4f); int bbHeight = (y2 - y1) * 30; - drawTexture(matrices, x1, y1 + 1, 0, 0, 0, x2-x1, (int) ((y2-y1)/1.4f), bbHeight, bbWidth); - drawTexture(matrices, x1, y1 + 1, 0, 0, 5f, i, (int) ((y2-y1)/1.4f), bbHeight, bbWidth); + drawTexture(matrices, x1, y1 + 1, 0, 0, 0, x2 - x1, (int) ((y2-y1) / 1.4f), bbHeight, bbWidth); + drawTexture(matrices, x1, y1 + 1, 0, 0, 5f, i, (int) ((y2 - y1) / 1.4f), bbHeight, bbWidth); - RenderSystem.alphaFunc(516, 0.0F); RenderSystem.enableBlend(); + RenderSystem.blendEquation(32774); + RenderSystem.blendFunc(770, 1); if (overlay != 0) { drawTexture(matrices, x1, y1 + 1, 0, 0, overlay, x2 - x1, (int) ((y2 - y1) / 1.4f), bbHeight, bbWidth); } RenderSystem.defaultBlendFunc(); - RenderSystem.defaultAlphaFunc(); RenderSystem.disableBlend(); } - if (CustomSplashScreenClient.CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.Custom) { // Custom Progress Bar // - int customWidth = CustomSplashScreenClient.CS_CONFIG.customProgressBarMode == CustomSplashScreenConfig.ProgressBarMode.Linear ? x2-x1 : i; + + // Custom Progress Bar + if (CustomSplashScreenClient.CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.Custom) { + int customWidth = CustomSplashScreenClient.CS_CONFIG.customProgressBarMode == CustomSplashScreenConfig.ProgressBarMode.Linear ? x2 - x1 : i; if (CS_CONFIG.customProgressBarBackground) { - client.getTextureManager().bindTexture(CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE); - drawTexture(matrices, x1, y1, 0, 0, 6, x2-x1, y2-y1, 10, x2-x1); + RenderSystem.setShaderTexture(0, CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + drawTexture(matrices, x1, y1, 0, 0, 6, x2 - x1, y2 - y1, 10, x2-x1); } - client.getTextureManager().bindTexture(CUSTOM_PROGRESS_BAR_TEXTURE); - drawTexture(matrices, x1, y1, 0, 0, 6, i, y2-y1, 10, customWidth); + RenderSystem.setShaderTexture(0, CUSTOM_PROGRESS_BAR_TEXTURE); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + drawTexture(matrices, x1, y1, 0, 0, 6, i, y2 - y1, 10, customWidth); } + + // Vanilla / With Color progress bar + if (CustomSplashScreenClient.CS_CONFIG.progressBarType == CustomSplashScreenConfig.ProgressBarType.Vanilla) { + int j = Math.round(opacity * 255.0F); + int k = CustomSplashScreenClient.CS_CONFIG.progressBarColor | 255 << 24; + int kk = CustomSplashScreenClient.CS_CONFIG.progressFrameColor | 255 << 24; + fill(matrices, x1 + 2, y1 + 2, x1 + i, y2 - 2, k); + fill(matrices, x1 + 1, y1, x2 - 1, y1 + 1, kk); + fill(matrices, x1 + 1, y2, x2 - 1, y2 - 1, kk); + fill(matrices, x1, y1, x1 + 1, y2, kk); + fill(matrices, x2, y1, x2 - 1, y2, kk); + } + } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a1f9d0b..89ff682 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -7,7 +7,8 @@ "description": "Change minecraft's loading screen to your liking! Completely configurable!", "authors": [ "Motschen", - "TeamMidnightDust" + "TeamMidnightDust", + "HypherionSA" ], "contact": { "homepage": "https://www.midnightdust.eu/", @@ -33,7 +34,6 @@ ], "depends": { - "autoconfig1u": "*", "cloth-config2": "*" }, "breaks": {