diff --git a/build.gradle b/build.gradle index c9d818a..ef71cdc 100755 --- a/build.gradle +++ b/build.gradle @@ -124,7 +124,7 @@ dependencies { modImplementation ("maven.modrinth:lambdynamiclights:${project.ldl_version}") modImplementation ("maven.modrinth:lambdabettergrass:${project.lbg_version}") modImplementation ("maven.modrinth:iris:${project.iris_version}") - modImplementation ("maven.modrinth:cit-resewn:${project.cit_resewn_version}") + modCompileOnly ("maven.modrinth:cit-resewn:${project.cit_resewn_version}") modImplementation ("maven.modrinth:continuity:${project.continuity_version}") modImplementation ("maven.modrinth:animatica:${project.animatica_version}") modImplementation ("maven.modrinth:entitytexturefeatures:${project.entitytexturefeatures_version}") diff --git a/gradle.properties b/gradle.properties index eb3f62c..836aacf 100755 --- a/gradle.properties +++ b/gradle.properties @@ -4,28 +4,28 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use minecraft_version=1.19 - yarn_mappings=1.19+build.1 - loader_version=0.14.6 + yarn_mappings=1.19+build.4 + loader_version=0.14.8 # Mod Properties - mod_version = 1.3.3 + mod_version = 1.3.4 maven_group = net.puzzlemc archives_base_name = puzzle # 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.55.1+1.19 - mod_menu_version = 2.0.13 + fabric_version=0.57.0+1.19 + mod_menu_version = 4.0.0 cull_leaves_version = 2.3.3 - ldl_version = 2.1.0+1.17 - lbg_version = 1.2.3+1.18 - iris_version = 1.18.x-v1.2.4 - continuity_version = 1.0.3+1.18 - animatica_version = 0.2+1.18 + ldl_version = 2.1.2+1.19 + lbg_version = 1.3.0+1.19 + iris_version = 1.19.x-v1.2.5 + continuity_version = 2.0.0+1.19 + animatica_version = 0.5+1.19 cit_resewn_version = 1.0.1+1.18.2 - cem_version = 0.7.1 + cem_version = 0.7.1-1.19 complete_config_version = 1.0.0 - spruceui_version=3.3.3+1.18 + spruceui_version=4.0.0+1.19 midnightlib_version=0.5.2 - entitytexturefeatures_version=3.0.0 + entitytexturefeatures_version=3.1.5 diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java b/puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java index 1d95676..63ed02c 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java +++ b/puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java @@ -52,7 +52,7 @@ public class PuzzleClient implements ClientModInitializer { PuzzleConfig.resourcepackSplashScreen = !PuzzleConfig.resourcepackSplashScreen; PuzzleConfig.write(id); PuzzleSplashScreen.resetColors(); - MinecraftClient.getInstance().getTextureManager().registerTexture(PuzzleSplashScreen.LOGO, new PuzzleSplashScreen.LogoTexture()); + MinecraftClient.getInstance().getTextureManager().registerTexture(PuzzleSplashScreen.LOGO, new PuzzleSplashScreen.LogoTexture(PuzzleSplashScreen.LOGO)); })); } if (FabricLoader.getInstance().isModLoaded("puzzle-models") && !PuzzleConfig.disabledIntegrations.contains("puzzle-models")) { diff --git a/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java b/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java index d1f5d2c..b9e6064 100755 --- a/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java +++ b/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java @@ -34,9 +34,12 @@ import java.util.Properties; public class PuzzleSplashScreen implements ClientModInitializer { public static final Identifier LOGO = new Identifier("textures/gui/title/mojangstudios.png"); + public static final Identifier BACKGROUND = new Identifier("optifine/splash_background.png"); public static File CONFIG_PATH = new File(String.valueOf(FabricLoader.getInstance().getConfigDir().resolve(".puzzle_cache"))); public static Path LOGO_TEXTURE = Paths.get(CONFIG_PATH + "/mojangstudios.png"); + public static Path BACKGROUND_TEXTURE = Paths.get(CONFIG_PATH + "/splash_background.png"); private static final MinecraftClient client = MinecraftClient.getInstance(); + private static boolean keepBackground = true; public static void resetColors() { PuzzleConfig.backgroundColor = 15675965; @@ -71,7 +74,8 @@ public class PuzzleSplashScreen implements ClientModInitializer { public void reload(ResourceManager manager) { if (PuzzleConfig.resourcepackSplashScreen) { PuzzleSplashScreen.resetColors(); - client.getTextureManager().registerTexture(LOGO, new LogoTexture()); + client.getTextureManager().registerTexture(LOGO, new LogoTexture(LOGO)); + client.getTextureManager().registerTexture(BACKGROUND, new LogoTexture(BACKGROUND)); manager.findResources("optifine", path -> path.getPath().contains("color.properties")).forEach((id, resource) -> { try (InputStream stream = manager.getResource(id).get().getInputStream()) { @@ -102,23 +106,35 @@ public class PuzzleSplashScreen implements ClientModInitializer { manager.findResources("textures", path -> path.getPath().contains("mojangstudios.png")).forEach((id, resource) -> { try (InputStream stream = manager.getResource(id).get().getInputStream()) { Files.copy(stream, LOGO_TEXTURE, StandardCopyOption.REPLACE_EXISTING); - DefaultResourcePack defaultResourcePack = client.getResourcePackProvider().getPack(); - InputStream defaultLogo = defaultResourcePack.open(ResourceType.CLIENT_RESOURCES, LOGO); InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE)); - if (input != defaultLogo) client.getTextureManager().registerTexture(LOGO, new NativeImageBackedTexture(NativeImage.read(input))); - else Files.delete(LOGO_TEXTURE); } catch (Exception e) { LogManager.getLogger("Puzzle").error("Error occurred while loading custom minecraft logo " + id.toString(), e); } }); + manager.findResources("puzzle", path -> path.getPath().contains("splash_background.png")).forEach((id, resource) -> { + try (InputStream stream = manager.getResource(id).get().getInputStream()) { + Files.copy(stream, BACKGROUND_TEXTURE, StandardCopyOption.REPLACE_EXISTING); + InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE)); + client.getTextureManager().registerTexture(BACKGROUND, new NativeImageBackedTexture(NativeImage.read(input))); + keepBackground = true; + } catch (Exception e) { + LogManager.getLogger("Puzzle").error("Error occurred while loading custom splash background " + id.toString(), e); + } + }); + if (!keepBackground) { + try { + Files.delete(BACKGROUND_TEXTURE); + } catch (Exception ignored) {} + } + keepBackground = false; } } }); } @Environment(EnvType.CLIENT) public static class LogoTexture extends ResourceTexture { - public LogoTexture() { super(LOGO); } + public LogoTexture(Identifier logo) { super(logo); } protected TextureData loadTextureData(ResourceManager resourceManager) { MinecraftClient minecraftClient = MinecraftClient.getInstance(); diff --git a/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java b/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java index 4857da5..96979ab 100755 --- a/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java +++ b/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Overlay; import net.minecraft.client.gui.screen.SplashOverlay; +import net.minecraft.client.render.GameRenderer; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.client.util.math.MatrixStack; @@ -21,6 +22,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import java.util.function.IntSupplier; @Mixin(value = SplashOverlay.class, priority = 2000) @@ -33,13 +35,29 @@ public abstract class MixinSplashScreen extends Overlay { return 0; } + @Shadow @Final private MinecraftClient client; + + @Shadow @Final private boolean reloading; + + @Shadow private long reloadStartTime; + @Inject(method = "init(Lnet/minecraft/client/MinecraftClient;)V", at = @At("TAIL")) private static void puzzle$initSplashscreen(MinecraftClient client, CallbackInfo ci) { // Load our custom textures at game start // - if (PuzzleConfig.resourcepackSplashScreen && PuzzleSplashScreen.LOGO_TEXTURE.toFile().exists()) { - try { - InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE)); - client.getTextureManager().registerTexture(LOGO, new NativeImageBackedTexture(NativeImage.read(input))); - } catch (IOException ignored) {} + if (PuzzleConfig.resourcepackSplashScreen) { + if (PuzzleSplashScreen.LOGO_TEXTURE.toFile().exists()) { + try { + InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE)); + client.getTextureManager().registerTexture(LOGO, new NativeImageBackedTexture(NativeImage.read(input))); + } catch (IOException ignored) { + } + } + if (PuzzleSplashScreen.BACKGROUND_TEXTURE.toFile().exists()) { + try { + InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE)); + client.getTextureManager().registerTexture(PuzzleSplashScreen.BACKGROUND, new NativeImageBackedTexture(NativeImage.read(input))); + } catch (IOException ignored) { + } + } } } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/function/IntSupplier;getAsInt()I")) @@ -50,6 +68,32 @@ public abstract class MixinSplashScreen extends Overlay { private void puzzle$betterBlend(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { if (PuzzleConfig.disableBlend) RenderSystem.defaultBlendFunc(); } + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getScaledWidth()I", shift = At.Shift.BEFORE)) + private void puzzle$renderSplashBackground(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { + if (Files.exists(PuzzleSplashScreen.BACKGROUND_TEXTURE)) { + int width = client.getWindow().getScaledWidth(); + int height = client.getWindow().getScaledHeight(); + long l = Util.getMeasuringTimeMs(); + 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; + if (f >= 1.0F) + s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); + else if (reloading) + s = MathHelper.clamp(g, 0.0F, 1.0F); + else + s = 1.0F; + RenderSystem.setShaderTexture(0, PuzzleSplashScreen.BACKGROUND); + RenderSystem.enableBlend(); + RenderSystem.blendEquation(32774); + RenderSystem.defaultBlendFunc(); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s); + drawTexture(matrices, 0, 0, 0, 0, 0, width, height, width, height); + RenderSystem.defaultBlendFunc(); + RenderSystem.disableBlend(); + } + } @Inject(method = "renderProgressBar", at = @At("HEAD")) private void puzzle$addProgressBarBackground(MatrixStack matrices, int minX, int minY, int maxX, int maxY, float opacity, CallbackInfo ci) { RenderSystem.disableBlend(); @@ -59,20 +103,12 @@ public abstract class MixinSplashScreen extends Overlay { int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F); fill(matrices, minX, minY, maxX, maxY, withAlpha(PuzzleConfig.progressBarBackgroundColor, m)); } - @Inject(method = "renderProgressBar", at = @At("TAIL")) - private void puzzle$fixProgressBarEnd(MatrixStack matrices, int minX, int minY, int maxX, int maxY, float opacity, CallbackInfo ci) { // For some reason the end of the progressbar is colored wrong - if (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressFrameColor == 16777215) return; - long l = Util.getMeasuringTimeMs(); - float f = this.reloadCompleteTime > -1L ? (float)(l - this.reloadCompleteTime) / 1000.0F : -1.0F; - int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F); - fill(matrices, maxX-1, minY, maxX, maxY, withAlpha(PuzzleConfig.progressFrameColor, m)); - } @ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashOverlay;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V"), index = 5) private int puzzle$modifyProgressFrame(int color) { // Set the Progress Bar Frame Color to our configured value // return (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressFrameColor == 16777215) ? color : PuzzleConfig.progressFrameColor | 255 << 24; } - @ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashOverlay;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V", ordinal = 4), index = 5) + @ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashOverlay;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V", ordinal = 0), index = 5) private int puzzle$modifyProgressColor(int color) { // Set the Progress Bar Color to our configured value // return (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressBarColor == 16777215) ? color : PuzzleConfig.progressBarColor | 255 << 24; } diff --git a/puzzle-splashscreen_example_pack.zip b/puzzle-splashscreen_example_pack.zip new file mode 100644 index 0000000..d862f2f Binary files /dev/null and b/puzzle-splashscreen_example_pack.zip differ