├── src └── main │ ├── resources │ ├── empty.png │ ├── background.png │ ├── wide_logo.png │ ├── progressbar.png │ ├── square_logo.png │ ├── progressbar_background.png │ ├── assets │ │ └── customsplashscreen │ │ │ ├── icon.png │ │ │ └── lang │ │ │ └── en_us.json │ ├── customsplashscreen.mixins.json │ └── fabric.mod.json │ └── java │ └── eu │ └── midnightdust │ └── customsplashscreen │ ├── texture │ ├── BlurredConfigTexture.java │ ├── EmptyTexture.java │ └── ConfigTexture.java │ ├── mixin │ ├── MixinMidnightConfig.java │ └── MixinSplashScreen.java │ ├── config │ └── CustomSplashScreenConfig.java │ └── CustomSplashScreenClient.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── gradle.properties ├── README.md ├── LICENSE ├── gradlew.bat └── gradlew /src/main/resources/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamMidnightDust/CustomSplashScreen/HEAD/src/main/resources/empty.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamMidnightDust/CustomSplashScreen/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamMidnightDust/CustomSplashScreen/HEAD/src/main/resources/background.png -------------------------------------------------------------------------------- /src/main/resources/wide_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamMidnightDust/CustomSplashScreen/HEAD/src/main/resources/wide_logo.png -------------------------------------------------------------------------------- /src/main/resources/progressbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamMidnightDust/CustomSplashScreen/HEAD/src/main/resources/progressbar.png -------------------------------------------------------------------------------- /src/main/resources/square_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamMidnightDust/CustomSplashScreen/HEAD/src/main/resources/square_logo.png -------------------------------------------------------------------------------- /src/main/resources/progressbar_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamMidnightDust/CustomSplashScreen/HEAD/src/main/resources/progressbar_background.png -------------------------------------------------------------------------------- /src/main/resources/assets/customsplashscreen/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeamMidnightDust/CustomSplashScreen/HEAD/src/main/resources/assets/customsplashscreen/icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | out/ 5 | classes/ 6 | build/ 7 | 8 | # idea 9 | 10 | .idea/ 11 | *.iml 12 | *.ipr 13 | *.iws 14 | 15 | # vscode 16 | 17 | .settings/ 18 | .vscode/ 19 | bin/ 20 | .classpath 21 | .project 22 | 23 | # fabric 24 | 25 | run/ -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | jcenter() 4 | maven { 5 | name = 'Fabric' 6 | url = 'https://maven.fabricmc.net/' 7 | } 8 | maven { url "https://maven.architectury.dev/" } 9 | gradlePluginPortal() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/customsplashscreen.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "eu.midnightdust.customsplashscreen.mixin", 4 | "compatibilityLevel": "JAVA_17", 5 | "client": [ 6 | "MixinSplashScreen", 7 | "MixinMidnightConfig" 8 | ], 9 | "injectors": { 10 | "defaultRequire": 1 11 | } 12 | } -------------------------------------------------------------------------------- /src/main/java/eu/midnightdust/customsplashscreen/texture/BlurredConfigTexture.java: -------------------------------------------------------------------------------- 1 | package eu.midnightdust.customsplashscreen.texture; 2 | 3 | import net.minecraft.util.Identifier; 4 | 5 | public class BlurredConfigTexture extends ConfigTexture { 6 | // Load textures from the config directory // 7 | 8 | public BlurredConfigTexture(Identifier location) { 9 | super(location); 10 | shouldBlur = true; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx1G 3 | 4 | # Fabric Properties 5 | # check these on https://fabricmc.net/use 6 | minecraft_version=1.21.3 7 | yarn_mappings=1.21.3+build.2 8 | loader_version=0.16.9 9 | 10 | # Mod Properties 11 | mod_version = 2.3.0 12 | maven_group = eu.midnightdust 13 | archives_base_name = customsplashscreen 14 | release_type=release 15 | curseforge_id=438252 16 | modrinth_id=BwFQLeCh 17 | 18 | # Dependencies 19 | # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api 20 | fabric_version=0.107.0+1.21.3 21 | midnightlib_version=1.6.4-fabric -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CustomSplashScreen 2 | Change minecraft's loading screen to your liking! Completely configurable! 3 | Allows you to completely change the minecraft splash screen. 4 | Provides many config options so you can customize the loading screen to your liking. 5 | Just look at the examples below: 6 |

7 |

8 | 9 |

10 | 11 |

12 | -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "customsplashscreen", 4 | "version": "${version}", 5 | 6 | "name": "Custom Splash Screen", 7 | "description": "Change minecraft's loading screen to your liking! Completely configurable!", 8 | "authors": [ 9 | "Motschen", 10 | "TeamMidnightDust", 11 | "HypherionSA" 12 | ], 13 | "contact": { 14 | "homepage": "https://www.midnightdust.eu/", 15 | "sources": "https://github.com/TeamMidnightDust/CustomSplashScreen", 16 | "issues": "https://github.com/TeamMidnightDust/CustomSplashScreen/issues" 17 | }, 18 | 19 | "license": "MIT", 20 | "icon": "assets/customsplashscreen/icon.png", 21 | 22 | "environment": "client", 23 | "entrypoints": { 24 | "client": [ 25 | "eu.midnightdust.customsplashscreen.CustomSplashScreenClient" 26 | ] 27 | }, 28 | 29 | "mixins": [ 30 | "customsplashscreen.mixins.json" 31 | ], 32 | 33 | "depends": { 34 | "midnightlib": "*" 35 | }, 36 | "breaks": { 37 | "splash": "*", 38 | "dark-loading-screen": "*" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 MidnightDust 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/eu/midnightdust/customsplashscreen/texture/EmptyTexture.java: -------------------------------------------------------------------------------- 1 | package eu.midnightdust.customsplashscreen.texture; 2 | 3 | import net.minecraft.client.resource.metadata.TextureResourceMetadata; 4 | import net.minecraft.client.texture.NativeImage; 5 | import net.minecraft.client.texture.ResourceTexture; 6 | import net.minecraft.resource.ResourceManager; 7 | import net.minecraft.util.Identifier; 8 | 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | 12 | public class EmptyTexture extends ResourceTexture { 13 | // Empty texture used for hiding the default mojang logo when using other logo styles // 14 | 15 | public EmptyTexture(Identifier location) { 16 | super(location); 17 | } 18 | 19 | protected TextureData loadTextureData(ResourceManager resourceManager) { 20 | try { 21 | InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("empty.png"); 22 | TextureData texture = null; 23 | 24 | if( input != null ) { 25 | 26 | try { 27 | texture = new TextureData(new TextureResourceMetadata(true, true), NativeImage.read(input)); 28 | } finally { 29 | input.close(); 30 | } 31 | 32 | } 33 | 34 | return texture; 35 | } catch (IOException var18) { 36 | return new TextureData(var18); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/eu/midnightdust/customsplashscreen/mixin/MixinMidnightConfig.java: -------------------------------------------------------------------------------- 1 | package eu.midnightdust.customsplashscreen.mixin; 2 | 3 | import eu.midnightdust.lib.config.MidnightConfig; 4 | import net.minecraft.client.gui.screen.Screen; 5 | import net.minecraft.client.gui.screen.SplashOverlay; 6 | import net.minecraft.client.gui.widget.ButtonWidget; 7 | import net.minecraft.resource.ResourceManager; 8 | import net.minecraft.resource.SimpleResourceReload; 9 | import net.minecraft.text.Text; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 16 | 17 | import java.util.List; 18 | import java.util.Objects; 19 | import java.util.concurrent.CompletableFuture; 20 | 21 | @Mixin(value = MidnightConfig.MidnightConfigScreen.class) 22 | public class MixinMidnightConfig extends Screen { 23 | @Shadow(remap = false) @Final 24 | public String modid; 25 | 26 | protected MixinMidnightConfig(Text title) { 27 | super(title); 28 | } 29 | 30 | @Inject(at = @At("HEAD"), method = "init") 31 | protected void init(CallbackInfo ci) { 32 | if(this.modid.equals("customsplashscreen")) { 33 | this.addDrawableChild(ButtonWidget.builder(Text.literal("Preview"), (button) -> { 34 | MidnightConfig.write("customsplashscreen"); 35 | (Objects.requireNonNull(this.client)).setOverlay( 36 | new SplashOverlay(client, SimpleResourceReload.create(ResourceManager.Empty.INSTANCE, List.of() 37 | ,Object::notify,Object::notify,new CompletableFuture<>()), throwable -> {}, true)); 38 | }).dimensions(this.width / 2 + 157, this.height - 26, 50, 20).build()); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/eu/midnightdust/customsplashscreen/config/CustomSplashScreenConfig.java: -------------------------------------------------------------------------------- 1 | package eu.midnightdust.customsplashscreen.config; 2 | 3 | import eu.midnightdust.lib.config.MidnightConfig; 4 | 5 | public class CustomSplashScreenConfig extends MidnightConfig { 6 | public static final String general = "general"; 7 | public static final String loading = "loading_indicator"; 8 | public static final String colors = "colors"; 9 | 10 | //"Change the design of the progress bar") 11 | @Entry(category = loading) 12 | public static ProgressBarType progressBarType = ProgressBarType.Vanilla; 13 | 14 | //"Change the texture of the logo") 15 | @Entry(category = general) 16 | public static LogoStyle logoStyle = LogoStyle.Mojang; 17 | 18 | //"Enable/Disable the background image") 19 | @Entry(category = general) 20 | public static boolean backgroundImage = false; 21 | 22 | //"Enable/Disable logo blend") 23 | @Entry(category = general) 24 | public static boolean logoBlend = true; 25 | 26 | //"Change the color of the background") 27 | @Entry(category = colors, isColor = true) 28 | public static String splashBackgroundColor = "#EF323D"; 29 | //"Change the color of the progress bar") 30 | @Entry(category = colors, isColor = true) 31 | public static String splashProgressBarColor = "#FFFFFF"; 32 | //"Change the color of the progress bar frame") 33 | @Entry(category = colors, isColor = true) 34 | public static String splashProgressFrameColor = "#FFFFFF"; 35 | @Entry(category = colors, isColor = true) 36 | public static String splashProgressBackgroundColor = "#000000"; 37 | 38 | //"Enable/Disable the progress bar background") 39 | @Entry(category = loading) 40 | public static boolean progressBarBackground = false; 41 | 42 | //"Change the mode of the custom loading bar") 43 | @Entry(category = loading) 44 | public static ProgressBarMode customProgressBarMode = ProgressBarMode.Linear; 45 | 46 | @Entry(category = loading, isSlider = true, min = 1, max = 10) 47 | public static int spinningCircleSize = 2; 48 | @Entry(category = loading, isSlider = true, min = 1, max = 10) 49 | public static int spinningCircleSpeed = 4; 50 | @Entry(category = loading, isSlider = true, min = 0, max = 23) 51 | public static int spinningCircleTrail = 5; 52 | 53 | public enum ProgressBarType { 54 | Vanilla, Custom, SpinningCircle, Hidden; 55 | } 56 | public enum LogoStyle { 57 | Mojang, Aspect1to1, Hidden; 58 | } 59 | public enum ProgressBarMode { 60 | Linear, Stretch, Slide; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/eu/midnightdust/customsplashscreen/texture/ConfigTexture.java: -------------------------------------------------------------------------------- 1 | package eu.midnightdust.customsplashscreen.texture; 2 | 3 | import eu.midnightdust.customsplashscreen.CustomSplashScreenClient; 4 | import net.minecraft.client.resource.metadata.TextureResourceMetadata; 5 | import net.minecraft.client.texture.NativeImage; 6 | import net.minecraft.client.texture.ResourceTexture; 7 | import net.minecraft.resource.ResourceManager; 8 | import net.minecraft.util.Identifier; 9 | import net.minecraft.util.math.random.Random; 10 | 11 | import java.io.File; 12 | import java.io.FileInputStream; 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | import java.util.Arrays; 16 | import java.util.Objects; 17 | 18 | public class ConfigTexture extends ResourceTexture { 19 | public static int randomBackgroundId; 20 | public static int prevBackgroundLength; 21 | // Load textures from the config directory // 22 | public boolean shouldBlur = false; 23 | 24 | public ConfigTexture(Identifier location) { 25 | super(location); 26 | } 27 | 28 | protected TextureData loadTextureData(ResourceManager resourceManager) { 29 | try { 30 | InputStream input = new FileInputStream(CustomSplashScreenClient.CONFIG_PATH+"/"+this.location.getPath()); 31 | if (this.location.getPath().equals("background.png") && CustomSplashScreenClient.CONFIG_PATH.toPath().resolve("backgrounds").toFile().isDirectory()) { 32 | if (CustomSplashScreenClient.CONFIG_PATH.toPath().resolve("backgrounds").toFile().listFiles() != null) { 33 | File[] backgrounds = Arrays.stream(Objects.requireNonNull(CustomSplashScreenClient.CONFIG_PATH.toPath().resolve("backgrounds").toFile().listFiles())).filter(file -> file.toString().endsWith(".png") || file.toString().endsWith(".jpg") || file.toString().endsWith(".jpeg")).toList().toArray(new File[0]); 34 | if (backgrounds.length > 0) { 35 | if (ConfigTexture.randomBackgroundId == -1 || ConfigTexture.prevBackgroundLength != backgrounds.length) ConfigTexture.randomBackgroundId = Random.create().nextInt(backgrounds.length); 36 | input = new FileInputStream(backgrounds[ConfigTexture.randomBackgroundId]); 37 | ConfigTexture.prevBackgroundLength = backgrounds.length; 38 | } 39 | } 40 | } 41 | 42 | TextureData texture; 43 | 44 | try { 45 | texture = new TextureData(new TextureResourceMetadata(shouldBlur, true), NativeImage.read(input)); 46 | } finally { 47 | input.close(); 48 | } 49 | 50 | return texture; 51 | } catch (IOException var18) { 52 | return new TextureData(var18); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 1>&2 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 48 | echo. 1>&2 49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 50 | echo location of your Java installation. 1>&2 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 1>&2 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 62 | echo. 1>&2 63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 64 | echo location of your Java installation. 1>&2 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /src/main/resources/assets/customsplashscreen/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "customsplashscreen.midnightconfig.title":"Custom Splash Screen Config", 3 | "customsplashscreen.midnightconfig.category.general":"General", 4 | "customsplashscreen.midnightconfig.category.loading_indicator":"Loading Indicator", 5 | "customsplashscreen.midnightconfig.category.colors":"Colors", 6 | "customsplashscreen.midnightconfig.progressBarType":"Progress Bar Type", 7 | "customsplashscreen.midnightconfig.enum.ProgressBarType.Vanilla":"Vanilla", 8 | "customsplashscreen.midnightconfig.enum.ProgressBarType.BossBar":"Boss Bar", 9 | "customsplashscreen.midnightconfig.enum.ProgressBarType.Custom":"Custom", 10 | "customsplashscreen.midnightconfig.enum.ProgressBarType.SpinningCircle":"Spinning Circle", 11 | "customsplashscreen.midnightconfig.enum.ProgressBarType.Hidden":"Hidden", 12 | "customsplashscreen.midnightconfig.progressBarBackground":"Progress Bar Background", 13 | "customsplashscreen.midnightconfig.logoStyle":"Logo Style", 14 | "customsplashscreen.midnightconfig.enum.LogoStyle.Mojang":"Wide", 15 | "customsplashscreen.midnightconfig.enum.LogoStyle.Aspect1to1":"1to1", 16 | "customsplashscreen.midnightconfig.enum.LogoStyle.Hidden":"Hidden", 17 | "customsplashscreen.midnightconfig.logoBlend":"Use Blending on Logo", 18 | "customsplashscreen.midnightconfig.backgroundImage":"Background Image", 19 | "customsplashscreen.midnightconfig.splashBackgroundColor":"Background Color", 20 | "customsplashscreen.midnightconfig.splashProgressBarColor":"Progress Bar Color", 21 | "customsplashscreen.midnightconfig.splashProgressFrameColor":"Progress Bar Frame Color", 22 | "customsplashscreen.midnightconfig.splashProgressBackgroundColor":"Progress Bar Background Color", 23 | "customsplashscreen.midnightconfig.customProgressBarMode":"Custom Progress Bar Mode", 24 | "customsplashscreen.midnightconfig.enum.ProgressBarMode.Linear":"Linear", 25 | "customsplashscreen.midnightconfig.enum.ProgressBarMode.Stretch":"Stretch", 26 | "customsplashscreen.midnightconfig.enum.ProgressBarMode.Slide": "Slide", 27 | "customsplashscreen.midnightconfig.spinningCircleSize":"Spinning Circle Size", 28 | "customsplashscreen.midnightconfig.spinningCircleSpeed":"Spinning Circle Speed", 29 | "customsplashscreen.midnightconfig.spinningCircleTrail":"Spinning Circle Trail Length", 30 | "customsplashscreen.midnightconfig.bossBarColor":"Boss Bar Color", 31 | "customsplashscreen.midnightconfig.enum.BossBarColor.MAGENTA":"Magenta", 32 | "customsplashscreen.midnightconfig.enum.BossBarColor.CYAN":"Cyan", 33 | "customsplashscreen.midnightconfig.enum.BossBarColor.RED":"Red", 34 | "customsplashscreen.midnightconfig.enum.BossBarColor.LIME":"Lime", 35 | "customsplashscreen.midnightconfig.enum.BossBarColor.YELLOW":"Yellow", 36 | "customsplashscreen.midnightconfig.enum.BossBarColor.PURPLE":"Purple", 37 | "customsplashscreen.midnightconfig.enum.BossBarColor.WHITE":"White", 38 | "customsplashscreen.midnightconfig.bossBarType":"Boss Bar Style", 39 | "customsplashscreen.midnightconfig.enum.BossBarType.PROGRESS":"Progress", 40 | "customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_6":"6 Notches", 41 | "customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_10":"10 Notches", 42 | "customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_12":"12 Notches", 43 | "customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_20":"20 Notches", 44 | "customsplashscreen.midnightconfig.bossBarSize":"Boss Bar Size" 45 | } -------------------------------------------------------------------------------- /src/main/java/eu/midnightdust/customsplashscreen/CustomSplashScreenClient.java: -------------------------------------------------------------------------------- 1 | package eu.midnightdust.customsplashscreen; 2 | 3 | import eu.midnightdust.customsplashscreen.config.CustomSplashScreenConfig; 4 | import net.fabricmc.api.ClientModInitializer; 5 | import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; 6 | import net.fabricmc.loader.api.FabricLoader; 7 | import net.minecraft.util.Identifier; 8 | 9 | import java.io.*; 10 | import java.nio.file.*; 11 | 12 | public class CustomSplashScreenClient implements ClientModInitializer { 13 | public static File CONFIG_PATH = new File(FabricLoader.getInstance().getConfigDir() + "/customsplashscreen"); 14 | public static final Path BackgroundTexture = Paths.get(CONFIG_PATH + "/background.png"); 15 | public static final Path WideLogoTexture = Paths.get(CONFIG_PATH + "/wide_logo.png"); 16 | public static final Path SquareLogoTexture = Paths.get(CONFIG_PATH + "/square_logo.png"); 17 | public static final Path ProgressBarTexture = Paths.get(CONFIG_PATH + "/progressbar.png"); 18 | public static final Path ProgressBarBackgroundTexture = Paths.get(CONFIG_PATH + "/progressbar_background.png"); 19 | public static float spinningProgress; 20 | 21 | @Override 22 | public void onInitializeClient() { 23 | CustomSplashScreenConfig.init("customsplashscreen", CustomSplashScreenConfig.class); 24 | 25 | if (!CONFIG_PATH.exists()) { // Run when config directory is nonexistant // 26 | CONFIG_PATH.mkdir(); // Create our custom config directory // 27 | } 28 | // Open Input Streams for copying the default textures to the config directory // 29 | InputStream background = Thread.currentThread().getContextClassLoader().getResourceAsStream("background.png"); 30 | InputStream wide = Thread.currentThread().getContextClassLoader().getResourceAsStream("wide_logo.png"); 31 | InputStream square = Thread.currentThread().getContextClassLoader().getResourceAsStream("square_logo.png"); 32 | InputStream progressbar = Thread.currentThread().getContextClassLoader().getResourceAsStream("progressbar.png"); 33 | InputStream progressbarBG = Thread.currentThread().getContextClassLoader().getResourceAsStream("progressbar_background.png"); 34 | try { 35 | // Copy the default textures into the config directory // 36 | if (!BackgroundTexture.toFile().exists()) Files.copy(background,BackgroundTexture,StandardCopyOption.REPLACE_EXISTING); 37 | if (!WideLogoTexture.toFile().exists()) Files.copy(wide,WideLogoTexture,StandardCopyOption.REPLACE_EXISTING); 38 | if (!SquareLogoTexture.toFile().exists()) Files.copy(square,SquareLogoTexture,StandardCopyOption.REPLACE_EXISTING); 39 | if (!ProgressBarTexture.toFile().exists()) Files.copy(progressbar,ProgressBarTexture,StandardCopyOption.REPLACE_EXISTING); 40 | if (!ProgressBarBackgroundTexture.toFile().exists()) Files.copy(progressbarBG,ProgressBarBackgroundTexture,StandardCopyOption.REPLACE_EXISTING); 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | ClientTickEvents.END_CLIENT_TICK.register((client -> { 45 | if (spinningProgress > 1) spinningProgress = 0f; 46 | spinningProgress = spinningProgress + 0.01f; 47 | })); 48 | } 49 | 50 | public static Identifier id(String path) { 51 | return Identifier.of("customsplashscreen", path); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /src/main/java/eu/midnightdust/customsplashscreen/mixin/MixinSplashScreen.java: -------------------------------------------------------------------------------- 1 | package eu.midnightdust.customsplashscreen.mixin; 2 | 3 | import com.mojang.blaze3d.platform.GlStateManager; 4 | import com.mojang.blaze3d.systems.RenderSystem; 5 | import eu.midnightdust.customsplashscreen.CustomSplashScreenClient; 6 | import eu.midnightdust.customsplashscreen.config.CustomSplashScreenConfig; 7 | import eu.midnightdust.customsplashscreen.texture.BlurredConfigTexture; 8 | import eu.midnightdust.customsplashscreen.texture.ConfigTexture; 9 | import eu.midnightdust.customsplashscreen.texture.EmptyTexture; 10 | import eu.midnightdust.lib.config.MidnightConfig; 11 | import eu.midnightdust.lib.util.MidnightColorUtil; 12 | import net.minecraft.client.MinecraftClient; 13 | import net.minecraft.client.gl.ShaderProgram; 14 | import net.minecraft.client.gui.DrawContext; 15 | import net.minecraft.client.gui.screen.SplashOverlay; 16 | import net.minecraft.client.render.GameRenderer; 17 | import net.minecraft.client.render.RenderLayer; 18 | import net.minecraft.client.render.RenderPhase; 19 | import net.minecraft.resource.ResourceReload; 20 | import net.minecraft.util.Identifier; 21 | import net.minecraft.util.Util; 22 | import net.minecraft.util.math.ColorHelper; 23 | import net.minecraft.util.math.MathHelper; 24 | import org.spongepowered.asm.mixin.Final; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.Shadow; 27 | import org.spongepowered.asm.mixin.Unique; 28 | import org.spongepowered.asm.mixin.injection.At; 29 | import org.spongepowered.asm.mixin.injection.Inject; 30 | import org.spongepowered.asm.mixin.injection.ModifyArg; 31 | import org.spongepowered.asm.mixin.injection.Redirect; 32 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 33 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 34 | 35 | import java.util.Optional; 36 | import java.util.function.Consumer; 37 | import java.util.function.IntSupplier; 38 | 39 | import static eu.midnightdust.customsplashscreen.CustomSplashScreenClient.id; 40 | 41 | @Mixin(value = SplashOverlay.class, priority = 3000) 42 | public abstract class MixinSplashScreen { 43 | 44 | @Shadow @Final public static Identifier LOGO; 45 | @Shadow @Final private MinecraftClient client; 46 | @Shadow @Final private boolean reloading; 47 | @Shadow private float progress; 48 | @Shadow private long reloadCompleteTime; 49 | @Shadow private long reloadStartTime; 50 | 51 | @Shadow 52 | private static int withAlpha(int color, int alpha) { 53 | return 0; 54 | } 55 | 56 | @Shadow @Final private static IntSupplier BRAND_ARGB; 57 | @Unique private static final Identifier EMPTY_TEXTURE = id("empty.png"); 58 | @Unique private static final Identifier MOJANG_TEXTURE = id("wide_logo.png"); 59 | @Unique private static final Identifier ASPECT_1to1_TEXTURE = id("square_logo.png"); 60 | @Unique private static final Identifier CUSTOM_PROGRESS_BAR_TEXTURE = id("progressbar.png"); 61 | @Unique private static final Identifier CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE = id("progressbar_background.png"); 62 | @Unique private static final Identifier BACKGROUND_TEXTURE = id("background.png"); 63 | 64 | @Inject(method = "", at = @At("TAIL")) 65 | private void css$init(MinecraftClient client, ResourceReload monitor, Consumer> exceptionHandler, boolean reloading, CallbackInfo ci) { // Load our custom textures on screen init // 66 | if (CustomSplashScreenConfig.logoStyle.equals(CustomSplashScreenConfig.LogoStyle.Mojang)) 67 | client.getTextureManager().registerTexture(LOGO, new BlurredConfigTexture(MOJANG_TEXTURE)); 68 | else client.getTextureManager().registerTexture(LOGO, new EmptyTexture(EMPTY_TEXTURE)); 69 | 70 | if (CustomSplashScreenConfig.logoStyle.equals(CustomSplashScreenConfig.LogoStyle.Aspect1to1)) { 71 | client.getTextureManager().registerTexture(ASPECT_1to1_TEXTURE, new ConfigTexture(ASPECT_1to1_TEXTURE)); 72 | } 73 | if (CustomSplashScreenConfig.backgroundImage) client.getTextureManager().registerTexture(BACKGROUND_TEXTURE, new ConfigTexture(BACKGROUND_TEXTURE)); 74 | 75 | if (CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Custom)) { 76 | client.getTextureManager().registerTexture(CUSTOM_PROGRESS_BAR_TEXTURE, new ConfigTexture(CUSTOM_PROGRESS_BAR_TEXTURE)); 77 | client.getTextureManager().registerTexture(CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE, new ConfigTexture(CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE)); 78 | } 79 | } 80 | @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;getScaledWindowWidth()I", ordinal = 2)) 81 | private void css$renderSplashBackground(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { 82 | if (CustomSplashScreenConfig.backgroundImage) { 83 | context.getMatrices().translate(0, 0, 1f); 84 | int width = client.getWindow().getScaledWidth(); 85 | int height = client.getWindow().getScaledHeight(); 86 | float f = this.reloadCompleteTime > -1L ? (float)(Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F; 87 | float g = this.reloadStartTime> -1L ? (float)(Util.getMeasuringTimeMs() - this.reloadStartTime) / 500.0F : -1.0F; 88 | float s; 89 | if (f >= 1.0F) s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); 90 | else if (reloading) s = MathHelper.clamp(g, 0.0F, 1.0F); 91 | else s = 1.0F; 92 | RenderSystem.enableBlend(); 93 | RenderSystem.blendEquation(32774); 94 | RenderSystem.defaultBlendFunc(); 95 | context.drawTexture(RenderLayer::getGuiTextured, BACKGROUND_TEXTURE, 0, 0, 0, 0, width, height, width, height, ColorHelper.fromFloats(s, 1.f, 1.f, 1.f)); 96 | RenderSystem.defaultBlendFunc(); 97 | RenderSystem.disableBlend(); 98 | } 99 | } 100 | 101 | @Inject(at = @At("TAIL"), method = "render") 102 | public void css$render(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { 103 | if (CustomSplashScreenConfig.logoStyle == CustomSplashScreenConfig.LogoStyle.Aspect1to1) { 104 | float f = this.reloadCompleteTime > -1L ? (float)(Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F; 105 | float s = 1.0f; 106 | 107 | if (f >= 1.0F) s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); 108 | else if (this.reloading) s = MathHelper.clamp((this.reloadStartTime > -1L ? (float)(Util.getMeasuringTimeMs() - this.reloadStartTime) / 500.0F : -1.0F), 0.0F, 1.0F); 109 | 110 | double d = Math.min((double)this.client.getWindow().getScaledWidth() * 0.75D, this.client.getWindow().getScaledHeight()) * 0.25D; 111 | int w = (int)(d * 2); 112 | // Render the Logo 113 | RenderSystem.enableBlend(); 114 | RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); 115 | if (!CustomSplashScreenConfig.logoBlend) RenderSystem.defaultBlendFunc(); 116 | context.drawTexture(RenderLayer::getGuiTextured, ASPECT_1to1_TEXTURE,(int)(this.client.getWindow().getScaledWidth() * 0.5D) - (w / 2), (int)(d * 0.5D), 0, 0, w, w, 512, 512, 512, 512, ColorHelper.fromFloats(s, 1.f, 1.f, 1.f)); 117 | RenderSystem.defaultBlendFunc(); 118 | RenderSystem.disableBlend(); 119 | } 120 | if (client.currentScreen != null && client.currentScreen instanceof MidnightConfig.MidnightConfigScreen) this.progress = 1f; 121 | } 122 | 123 | @Inject(at = @At("TAIL"), method = "renderProgressBar") 124 | private void css$renderProgressBar(DrawContext context, int x1, int y1, int x2, int y2, float opacity, CallbackInfo ci) { 125 | int i = MathHelper.ceil((float)(x2 - x1 - 2) * this.progress); 126 | 127 | // Custom Progress Bar 128 | if (CustomSplashScreenConfig.progressBarType == CustomSplashScreenConfig.ProgressBarType.Custom) { 129 | int regionWidth = CustomSplashScreenConfig.customProgressBarMode == CustomSplashScreenConfig.ProgressBarMode.Stretch ? x2 - x1 : i; 130 | int height = (int) (((x2 - x1) / 400f) * 10); 131 | int u = CustomSplashScreenConfig.customProgressBarMode.equals(CustomSplashScreenConfig.ProgressBarMode.Slide) ? x2 - x1 - i : 0; 132 | if (CustomSplashScreenConfig.progressBarBackground) { 133 | context.drawTexture(RenderLayer::getGuiTextured, CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE, x1, y1, 0, 0, x2 - x1, height, x2 - x1, height, x2 - x1, height, ColorHelper.fromFloats(1.f, 1.f, 1.f, 1.f)); 134 | } 135 | context.drawTexture(RenderLayer::getGuiTextured, CUSTOM_PROGRESS_BAR_TEXTURE, x1, y1, u, 0, i, height, regionWidth, height, x2 - x1, height, ColorHelper.fromFloats(1.f, 1.f, 1.f, 1.f)); 136 | } 137 | // Spinning Circle Progress Indicator 138 | if (CustomSplashScreenConfig.progressBarType == CustomSplashScreenConfig.ProgressBarType.SpinningCircle) { 139 | int centerX = x1+(x2-x1)/2; 140 | int centerY = y1+(y2-y1)/2; 141 | int size = (y2-y1)*CustomSplashScreenConfig.spinningCircleSize; 142 | float f = this.reloadCompleteTime > -1L ? (float) (Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F; 143 | int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F); 144 | int time = (((int) (CustomSplashScreenClient.spinningProgress * 24 * CustomSplashScreenConfig.spinningCircleSpeed))%24)-1; 145 | 146 | int color = withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBarColor).getRGB(), m); 147 | for (int j = 0; j<=CustomSplashScreenConfig.spinningCircleTrail; j++) { 148 | RenderSystem.enableBlend(); 149 | RenderSystem.defaultBlendFunc(); 150 | renderSpinningCircle(context,(time+j) % 24,centerY - size,centerY + size, centerX - size, centerX + size,size/5,color); 151 | } 152 | } 153 | } 154 | @Unique 155 | private void renderSpinningCircle(DrawContext context, int time, int top, int bottom, int left, int right, int blockSize, int color) { 156 | switch (time) { 157 | //top 158 | case 0 -> context.fill(left + 4*blockSize, top, left + 3*blockSize, top + blockSize, color); 159 | case 1 -> context.fill(left + 5*blockSize, top, left + 4*blockSize, top + blockSize, color); 160 | case 2 -> context.fill(left + 6*blockSize, top, left + 5*blockSize, top + blockSize, color); 161 | case 3 -> context.fill(left + 7*blockSize, top, left + 6*blockSize, top + blockSize, color); 162 | //top right 163 | case 4 -> context.fill(right - 3*blockSize, top + blockSize, right - 2*blockSize, top + 2*blockSize, color); 164 | case 5 -> context.fill(right - 2*blockSize, top + 2*blockSize, right - blockSize, top + 3*blockSize, color); 165 | //right 166 | case 6 -> context.fill(right - blockSize, top + 3*blockSize, right, top + 4*blockSize, color); 167 | case 7 -> context.fill(right - blockSize, top + 4*blockSize, right, top + 5*blockSize, color); 168 | case 8 -> context.fill(right - blockSize, top + 5*blockSize, right, top + 6*blockSize, color); 169 | case 9 -> context.fill(right - blockSize, top + 6*blockSize, right, top + 7*blockSize, color); 170 | //bottom right 171 | case 10 -> context.fill(right - 2*blockSize, bottom - 2*blockSize, right - blockSize, bottom - 3*blockSize, color); 172 | case 11 -> context.fill(right - 3*blockSize, bottom - blockSize, right - 2*blockSize, bottom - 2*blockSize, color); 173 | //bottom 174 | case 12 -> context.fill(right - 4*blockSize, bottom, right - 3*blockSize, bottom - blockSize, color); 175 | case 13 -> context.fill(right - 5*blockSize, bottom, right - 4*blockSize, bottom - blockSize, color); 176 | case 14 -> context.fill(right - 6*blockSize, bottom, right - 5*blockSize, bottom - blockSize, color); 177 | case 15 -> context.fill(right - 7*blockSize, bottom, right - 6*blockSize, bottom - blockSize, color); 178 | //bottom left 179 | case 16 -> context.fill(left + 3*blockSize, bottom - blockSize, left + 2*blockSize, bottom - 2*blockSize, color); 180 | case 17 -> context.fill(left + 2*blockSize, bottom - 2*blockSize, left + blockSize, bottom - 3*blockSize, color); 181 | //left 182 | case 18 -> context.fill(left + blockSize, bottom - 3*blockSize, left, bottom - 4*blockSize, color); 183 | case 19 -> context.fill(left + blockSize, bottom - 4*blockSize, left, bottom - 5*blockSize, color); 184 | case 20 -> context.fill(left + blockSize, bottom - 5*blockSize, left, bottom - 6*blockSize, color); 185 | case 21 -> context.fill(left + blockSize, bottom - 6*blockSize, left, bottom - 7*blockSize, color); 186 | //top left 187 | case 22 -> context.fill(left + 2*blockSize, top + 2*blockSize, left + blockSize, top + 3*blockSize, color); 188 | case 23 -> context.fill(left + 3*blockSize, top + blockSize, left + 2 * blockSize, top + 2*blockSize, color); 189 | } 190 | } 191 | // Replaced by the methods below for compatibility with Puzzle 192 | // @Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/function/IntSupplier;getAsInt()I")) 193 | // private int css$modifyBackground(IntSupplier instance) { // Set the Background Color to our configured value // 194 | // return !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.backgroundColor).getRGB() | 255 << 24 : 0; 195 | // } 196 | @Inject(method = "withAlpha", at = @At("RETURN"), cancellable = true) 197 | private static void css$modifyBackgroundColor(int color, int alpha, CallbackInfoReturnable cir) { 198 | if (color == BRAND_ARGB.getAsInt()) { 199 | int configColor = !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashBackgroundColor).getRGB() | 255 << 24 : 0; 200 | cir.setReturnValue(configColor & 16777215 | alpha << 24); 201 | } 202 | } 203 | @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_clearColor(FFFF)V")) 204 | private void css$clearModifiedColor(float red, float green, float blue, float alpha) { 205 | int k = !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashBackgroundColor).getRGB() : 0; 206 | float m = (float)(k >> 16 & 255) / 255.0F; 207 | float n = (float)(k >> 8 & 255) / 255.0F; 208 | float o = (float)(k & 255) / 255.0F; 209 | GlStateManager._clearColor(m, n, o, 1.0F); 210 | } 211 | @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/ColorHelper;getWhite(F)I", shift = At.Shift.AFTER)) 212 | private void css$betterBlend(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { 213 | if (!CustomSplashScreenConfig.logoBlend) RenderSystem.defaultBlendFunc(); 214 | } 215 | @Inject(method = "renderProgressBar", at = @At("HEAD")) 216 | private void css$addProgressBarBackground(DrawContext context, int minX, int minY, int maxX, int maxY, float opacity, CallbackInfo ci) { 217 | if (CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) && CustomSplashScreenConfig.progressBarBackground) { 218 | float f = this.reloadCompleteTime > -1L ? (float) (Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F; 219 | int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F); 220 | RenderSystem.disableBlend(); 221 | context.fill(minX, minY, maxX, maxY, withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBackgroundColor).getRGB(), m)); 222 | } 223 | } 224 | 225 | @ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;fill(IIIII)V"), index = 4) 226 | private int css$modifyProgressFrame(int color) { // Set the Progress Bar Frame Color to our configured value // 227 | return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressFrameColor).getRGB() | 255 << 24 : 0; 228 | } 229 | @ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;fill(IIIII)V", ordinal = 0), index = 4) 230 | private int css$modifyProgressColor(int color) { // Set the Progress Bar Color to our configured value // 231 | return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBarColor).getRGB() | 255 << 24 : 0; 232 | } 233 | } --------------------------------------------------------------------------------