7 Commits
v1.2.0 ... main

Author SHA1 Message Date
Martin Prokoph
644da0493d Update to 1.21.3
Also fix text clipping with custom backgrounds :)
2024-11-05 11:46:01 +01:00
Martin Prokoph
7a900716a8 Port to 1.21 & Improve Performance
- Only the required textures are now loaded on startup -> Faster startup, less RAM usage
- Removed Boss Bar loading bar design, as it became a huge maintenance burden
- Added unifiedPublishing to streamline update deployment
2024-06-17 12:49:52 +02:00
Martin Prokoph
9181ed02ee Merge pull request #21 from FireInstall/fix
Add missing ProgressBarMode translation
2024-06-17 12:45:48 +02:00
FireInstall
ce8f659929 Add missing ProgressBarMode translation 2024-03-13 14:24:35 +01:00
Motschen
84042deb0d CustomSplashScreen 2.1.1 - Port to 1.20 2023-06-11 12:40:28 +02:00
Motschen
45501668c1 CustomSplashScreen 2.1.0 - Fix crashes
- Fix crash on game start
- Fix compatibility with Puzzle
- Further improve boss bar loading bar
- Fix custom progress bar (closes #16)
2023-06-02 18:38:58 +02:00
Motschen
7b236188f6 CustomSplashScreen 2.0.0 - Rewrite
- Rewrite basically the entire mod for more stability and compatibility
- Now uses MidnightLib for configuration
- Added spinning loading indicator
- Support for random background images located in /config/customsplashscreen/backgrounds
- Boss Bar loading bar is now fixed and can be changed in color
- Splash screen can now be previewed!

All previous configs need to be rewritten, but all options are still available.
2023-05-26 21:56:20 +02:00
20 changed files with 613 additions and 531 deletions

View File

@@ -1,24 +1,20 @@
//file:noinspection GroovyAssignabilityCheck
//file:noinspection GrDeprecatedAPIUsage
plugins {
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
id "me.shedaniel.unified-publishing" version "0.1.+"
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
minecraft {
}
repositories {
maven { url "https://jitpack.io" }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases" }
maven { url = "https://api.modrinth.com/maven" }
}
loom {
}
dependencies {
@@ -29,11 +25,8 @@ dependencies {
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")
}
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
include "maven.modrinth:midnightlib:${project.midnightlib_version}"
}
processResources {
@@ -49,14 +42,7 @@ processResources {
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
it.options.release = 21
}
jar {
@@ -71,9 +57,6 @@ publishing {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
@@ -83,3 +66,55 @@ publishing {
// mavenLocal()
}
}
ext {
releaseChangelog = {
def changes = new StringBuilder()
changes << "## Custom Splash Screen v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/CustomSplashScreen/commits/)"
def proc = "git log --max-count=1 --pretty=format:%s".execute()
proc.in.eachLine { line ->
def processedLine = line.toString()
if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
changes << "\n- ${processedLine.capitalize()}"
}
}
proc.waitFor()
return changes.toString()
}
}
unifiedPublishing {
project {
displayName = "CustomSplashScreen v$project.version - Fabric $project.minecraft_version"
releaseType = "$project.release_type"
changelog = releaseChangelog()
gameVersions = []
gameLoaders = ["fabric","quilt"]
mainPublication remapJar
relations {
includes {
curseforge = "midnightlib"
modrinth = "midnightlib"
}
}
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
gameVersions.addAll "Java 21", project.minecraft_version
}
}
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
token = MODRINTH_TOKEN
id = rootProject.modrinth_id
version = "$project.version"
gameVersions.addAll project.minecraft_version
}
}
}
}

View File

@@ -3,19 +3,19 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.18
yarn_mappings=1.18+build.1
loader_version=0.12.8
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.9
# Mod Properties
mod_version = 1.2.0
mod_version = 2.3.0
maven_group = eu.midnightdust
archives_base_name = customsplashscreen
release_type=release
curseforge_id=438252
modrinth_id=BwFQLeCh
# 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.44.0+1.18
auto_config_version = 3.3.1
cloth_config_version = 6.0.42
mod_menu_version = 3.0.0
fabric_version=0.107.0+1.21.3
midnightlib_version=1.6.4-fabric

Binary file not shown.

View File

@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

41
gradlew vendored
View File

@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -205,6 +214,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

181
gradlew.bat vendored
View File

@@ -1,89 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -5,6 +5,7 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven { url "https://maven.architectury.dev/" }
gradlePluginPortal()
}
}

View File

@@ -1,48 +1,53 @@
package eu.midnightdust.customsplashscreen;
import eu.midnightdust.customsplashscreen.config.CustomSplashScreenConfig;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
import java.io.*;
import java.nio.file.*;
public class CustomSplashScreenClient implements ClientModInitializer {
public static CustomSplashScreenConfig CS_CONFIG;
public static File CONFIG_PATH = new File(FabricLoader.getInstance().getConfigDir() + "/customsplashscreen");
private static Path BackgroundTexture = Paths.get(CONFIG_PATH + "/background.png");
private static Path MojangTexture = Paths.get(CONFIG_PATH + "/mojangstudios.png");
private static Path MojankTexture = Paths.get(CONFIG_PATH + "/mojank.png");
private static Path ProgressBarTexture = Paths.get(CONFIG_PATH + "/progressbar.png");
private static Path ProgressBarBackgroundTexture = Paths.get(CONFIG_PATH + "/progressbar_background.png");
public static final Path BackgroundTexture = Paths.get(CONFIG_PATH + "/background.png");
public static final Path WideLogoTexture = Paths.get(CONFIG_PATH + "/wide_logo.png");
public static final Path SquareLogoTexture = Paths.get(CONFIG_PATH + "/square_logo.png");
public static final Path ProgressBarTexture = Paths.get(CONFIG_PATH + "/progressbar.png");
public static final Path ProgressBarBackgroundTexture = Paths.get(CONFIG_PATH + "/progressbar_background.png");
public static float spinningProgress;
@Override
public void onInitializeClient() {
AutoConfig.register(CustomSplashScreenConfig.class, JanksonConfigSerializer::new);
CS_CONFIG = AutoConfig.getConfigHolder(CustomSplashScreenConfig.class).getConfig();
CustomSplashScreenConfig.init("customsplashscreen", CustomSplashScreenConfig.class);
if (!CONFIG_PATH.exists()) { // Run when config directory is nonexistant //
CONFIG_PATH.mkdir(); // Create our custom config directory //
// Open Input Streams for copying the default textures to the config directory //
InputStream background = Thread.currentThread().getContextClassLoader().getResourceAsStream("background.png");
InputStream mojangstudios = Thread.currentThread().getContextClassLoader().getResourceAsStream("mojangstudios.png");
InputStream mojank = Thread.currentThread().getContextClassLoader().getResourceAsStream("mojank.png");
InputStream progressbar = Thread.currentThread().getContextClassLoader().getResourceAsStream("progressbar.png");
InputStream progressbarBG = Thread.currentThread().getContextClassLoader().getResourceAsStream("progressbar_background.png");
try {
// Copy the default textures into the config directory //
Files.copy(background,BackgroundTexture,StandardCopyOption.REPLACE_EXISTING);
Files.copy(mojangstudios,MojangTexture,StandardCopyOption.REPLACE_EXISTING);
Files.copy(mojank,MojankTexture,StandardCopyOption.REPLACE_EXISTING);
Files.copy(progressbar,ProgressBarTexture,StandardCopyOption.REPLACE_EXISTING);
Files.copy(progressbarBG,ProgressBarBackgroundTexture,StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
}
// Open Input Streams for copying the default textures to the config directory //
InputStream background = Thread.currentThread().getContextClassLoader().getResourceAsStream("background.png");
InputStream wide = Thread.currentThread().getContextClassLoader().getResourceAsStream("wide_logo.png");
InputStream square = Thread.currentThread().getContextClassLoader().getResourceAsStream("square_logo.png");
InputStream progressbar = Thread.currentThread().getContextClassLoader().getResourceAsStream("progressbar.png");
InputStream progressbarBG = Thread.currentThread().getContextClassLoader().getResourceAsStream("progressbar_background.png");
try {
// Copy the default textures into the config directory //
if (!BackgroundTexture.toFile().exists()) Files.copy(background,BackgroundTexture,StandardCopyOption.REPLACE_EXISTING);
if (!WideLogoTexture.toFile().exists()) Files.copy(wide,WideLogoTexture,StandardCopyOption.REPLACE_EXISTING);
if (!SquareLogoTexture.toFile().exists()) Files.copy(square,SquareLogoTexture,StandardCopyOption.REPLACE_EXISTING);
if (!ProgressBarTexture.toFile().exists()) Files.copy(progressbar,ProgressBarTexture,StandardCopyOption.REPLACE_EXISTING);
if (!ProgressBarBackgroundTexture.toFile().exists()) Files.copy(progressbarBG,ProgressBarBackgroundTexture,StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
e.printStackTrace();
}
ClientTickEvents.END_CLIENT_TICK.register((client -> {
if (spinningProgress > 1) spinningProgress = 0f;
spinningProgress = spinningProgress + 0.01f;
}));
}
public static Identifier id(String path) {
return Identifier.of("customsplashscreen", path);
}
}

View File

@@ -1,67 +1,62 @@
package eu.midnightdust.customsplashscreen.config;
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;
import eu.midnightdust.lib.config.MidnightConfig;
@Config(name = "customsplashscreen")
public class CustomSplashScreenConfig implements ConfigData {
public class CustomSplashScreenConfig extends MidnightConfig {
public static final String general = "general";
public static final String loading = "loading_indicator";
public static final String colors = "colors";
@Comment(value = "Change the design of the progress bar")
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public ProgressBarType progressBarType = ProgressBarType.Vanilla;
//"Change the design of the progress bar")
@Entry(category = loading)
public static ProgressBarType progressBarType = ProgressBarType.Vanilla;
@Comment(value = "Change the texture of the logo")
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public LogoStyle logoStyle = LogoStyle.Mojang;
//"Change the texture of the logo")
@Entry(category = general)
public static LogoStyle logoStyle = LogoStyle.Mojang;
@Comment(value = "Enable/Disable the background image")
public boolean backgroundImage = false;
//"Enable/Disable the background image")
@Entry(category = general)
public static boolean backgroundImage = false;
@Comment(value = "Change the color of the background")
@ConfigEntry.ColorPicker
public int backgroundColor = 15675965;
@Comment(value = "Change the color of the progress bar")
@ConfigEntry.ColorPicker
public int progressBarColor = 16777215;
@Comment(value = "Change the color of the progress bar frame")
@ConfigEntry.ColorPicker
public int progressFrameColor = 16777215;
//"Enable/Disable logo blend")
@Entry(category = general)
public static boolean logoBlend = true;
@Comment(value = "Change the mode of the custom loading bar")
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public ProgressBarMode customProgressBarMode = ProgressBarMode.Linear;
//"Change the color of the background")
@Entry(category = colors, isColor = true)
public static String splashBackgroundColor = "#EF323D";
//"Change the color of the progress bar")
@Entry(category = colors, isColor = true)
public static String splashProgressBarColor = "#FFFFFF";
//"Change the color of the progress bar frame")
@Entry(category = colors, isColor = true)
public static String splashProgressFrameColor = "#FFFFFF";
@Entry(category = colors, isColor = true)
public static String splashProgressBackgroundColor = "#000000";
@Comment(value = "Enable/Disable the custom progress bar background")
public boolean customProgressBarBackground = false;
//"Enable/Disable the progress bar background")
@Entry(category = loading)
public static boolean progressBarBackground = false;
@Comment(value = "Change the style of the boss loading bar")
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public BossBarType bossBarType = BossBarType.NOTCHED_6;
//"Change the mode of the custom loading bar")
@Entry(category = loading)
public static ProgressBarMode customProgressBarMode = ProgressBarMode.Linear;
@ConfigEntry.Gui.CollapsibleObject
public Textures textures = new Textures();
public static class Textures {
public String BackgroundTexture = "background.png";
public String MojangLogo = "mojangstudios.png";
public String Aspect1to1Logo = "mojank.png";
public String BossBarTexture = "textures/gui/bars.png";
public String CustomBarTexture = "progressbar.png";
public String CustomBarBackgroundTexture = "progressbar_background.png";
}
@Entry(category = loading, isSlider = true, min = 1, max = 10)
public static int spinningCircleSize = 2;
@Entry(category = loading, isSlider = true, min = 1, max = 10)
public static int spinningCircleSpeed = 4;
@Entry(category = loading, isSlider = true, min = 0, max = 23)
public static int spinningCircleTrail = 5;
public enum ProgressBarType {
Vanilla, BossBar, Custom, Hidden;
Vanilla, Custom, SpinningCircle, Hidden;
}
public enum LogoStyle {
Mojang, Aspect1to1, Hidden;
}
public enum ProgressBarMode {
Linear, Stretch;
}
public enum BossBarType {
PROGRESS, NOTCHED_6, NOTCHED_10, NOTCHED_12, NOTCHED_20;
Linear, Stretch, Slide;
}
}

View File

@@ -1,16 +0,0 @@
package eu.midnightdust.customsplashscreen.config;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class ModMenuIntegration implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() { // Provide our Config Screen to Mod Menu //
return parent -> AutoConfig.getConfigScreen(CustomSplashScreenConfig.class, parent).get();
}
}

View File

@@ -0,0 +1,41 @@
package eu.midnightdust.customsplashscreen.mixin;
import eu.midnightdust.lib.config.MidnightConfig;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.SplashOverlay;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.SimpleResourceReload;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Final;
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.callback.CallbackInfo;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
@Mixin(value = MidnightConfig.MidnightConfigScreen.class)
public class MixinMidnightConfig extends Screen {
@Shadow(remap = false) @Final
public String modid;
protected MixinMidnightConfig(Text title) {
super(title);
}
@Inject(at = @At("HEAD"), method = "init")
protected void init(CallbackInfo ci) {
if(this.modid.equals("customsplashscreen")) {
this.addDrawableChild(ButtonWidget.builder(Text.literal("Preview"), (button) -> {
MidnightConfig.write("customsplashscreen");
(Objects.requireNonNull(this.client)).setOverlay(
new SplashOverlay(client, SimpleResourceReload.create(ResourceManager.Empty.INSTANCE, List.of()
,Object::notify,Object::notify,new CompletableFuture<>()), throwable -> {}, true));
}).dimensions(this.width / 2 + 157, this.height - 26, 50, 20).build());
}
}
}

View File

@@ -0,0 +1,233 @@
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;
import eu.midnightdust.customsplashscreen.texture.BlurredConfigTexture;
import eu.midnightdust.customsplashscreen.texture.ConfigTexture;
import eu.midnightdust.customsplashscreen.texture.EmptyTexture;
import eu.midnightdust.lib.config.MidnightConfig;
import eu.midnightdust.lib.util.MidnightColorUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.ShaderProgram;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.SplashOverlay;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase;
import net.minecraft.resource.ResourceReload;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.IntSupplier;
import static eu.midnightdust.customsplashscreen.CustomSplashScreenClient.id;
@Mixin(value = SplashOverlay.class, priority = 3000)
public abstract class MixinSplashScreen {
@Shadow @Final public static Identifier LOGO;
@Shadow @Final private MinecraftClient client;
@Shadow @Final private boolean reloading;
@Shadow private float progress;
@Shadow private long reloadCompleteTime;
@Shadow private long reloadStartTime;
@Shadow
private static int withAlpha(int color, int alpha) {
return 0;
}
@Shadow @Final private static IntSupplier BRAND_ARGB;
@Unique private static final Identifier EMPTY_TEXTURE = id("empty.png");
@Unique private static final Identifier MOJANG_TEXTURE = id("wide_logo.png");
@Unique private static final Identifier ASPECT_1to1_TEXTURE = id("square_logo.png");
@Unique private static final Identifier CUSTOM_PROGRESS_BAR_TEXTURE = id("progressbar.png");
@Unique private static final Identifier CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE = id("progressbar_background.png");
@Unique private static final Identifier BACKGROUND_TEXTURE = id("background.png");
@Inject(method = "<init>", at = @At("TAIL"))
private void css$init(MinecraftClient client, ResourceReload monitor, Consumer<Optional<Throwable>> exceptionHandler, boolean reloading, CallbackInfo ci) { // Load our custom textures on screen init //
if (CustomSplashScreenConfig.logoStyle.equals(CustomSplashScreenConfig.LogoStyle.Mojang))
client.getTextureManager().registerTexture(LOGO, new BlurredConfigTexture(MOJANG_TEXTURE));
else client.getTextureManager().registerTexture(LOGO, new EmptyTexture(EMPTY_TEXTURE));
if (CustomSplashScreenConfig.logoStyle.equals(CustomSplashScreenConfig.LogoStyle.Aspect1to1)) {
client.getTextureManager().registerTexture(ASPECT_1to1_TEXTURE, new ConfigTexture(ASPECT_1to1_TEXTURE));
}
if (CustomSplashScreenConfig.backgroundImage) client.getTextureManager().registerTexture(BACKGROUND_TEXTURE, new ConfigTexture(BACKGROUND_TEXTURE));
if (CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Custom)) {
client.getTextureManager().registerTexture(CUSTOM_PROGRESS_BAR_TEXTURE, new ConfigTexture(CUSTOM_PROGRESS_BAR_TEXTURE));
client.getTextureManager().registerTexture(CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE, new ConfigTexture(CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE));
}
}
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;getScaledWindowWidth()I", ordinal = 2))
private void css$renderSplashBackground(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (CustomSplashScreenConfig.backgroundImage) {
context.getMatrices().translate(0, 0, 1f);
int width = client.getWindow().getScaledWidth();
int height = client.getWindow().getScaledHeight();
float f = this.reloadCompleteTime > -1L ? (float)(Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F;
float g = this.reloadStartTime> -1L ? (float)(Util.getMeasuringTimeMs() - 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.enableBlend();
RenderSystem.blendEquation(32774);
RenderSystem.defaultBlendFunc();
context.drawTexture(RenderLayer::getGuiTextured, BACKGROUND_TEXTURE, 0, 0, 0, 0, width, height, width, height, ColorHelper.fromFloats(s, 1.f, 1.f, 1.f));
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
}
}
@Inject(at = @At("TAIL"), method = "render")
public void css$render(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (CustomSplashScreenConfig.logoStyle == CustomSplashScreenConfig.LogoStyle.Aspect1to1) {
float f = this.reloadCompleteTime > -1L ? (float)(Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F;
float s = 1.0f;
if (f >= 1.0F) s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F);
else if (this.reloading) s = MathHelper.clamp((this.reloadStartTime > -1L ? (float)(Util.getMeasuringTimeMs() - this.reloadStartTime) / 500.0F : -1.0F), 0.0F, 1.0F);
double d = Math.min((double)this.client.getWindow().getScaledWidth() * 0.75D, this.client.getWindow().getScaledHeight()) * 0.25D;
int w = (int)(d * 2);
// Render the Logo
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
if (!CustomSplashScreenConfig.logoBlend) RenderSystem.defaultBlendFunc();
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));
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
}
if (client.currentScreen != null && client.currentScreen instanceof MidnightConfig.MidnightConfigScreen) this.progress = 1f;
}
@Inject(at = @At("TAIL"), method = "renderProgressBar")
private void css$renderProgressBar(DrawContext context, int x1, int y1, int x2, int y2, float opacity, CallbackInfo ci) {
int i = MathHelper.ceil((float)(x2 - x1 - 2) * this.progress);
// Custom Progress Bar
if (CustomSplashScreenConfig.progressBarType == CustomSplashScreenConfig.ProgressBarType.Custom) {
int regionWidth = CustomSplashScreenConfig.customProgressBarMode == CustomSplashScreenConfig.ProgressBarMode.Stretch ? x2 - x1 : i;
int height = (int) (((x2 - x1) / 400f) * 10);
int u = CustomSplashScreenConfig.customProgressBarMode.equals(CustomSplashScreenConfig.ProgressBarMode.Slide) ? x2 - x1 - i : 0;
if (CustomSplashScreenConfig.progressBarBackground) {
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));
}
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));
}
// Spinning Circle Progress Indicator
if (CustomSplashScreenConfig.progressBarType == CustomSplashScreenConfig.ProgressBarType.SpinningCircle) {
int centerX = x1+(x2-x1)/2;
int centerY = y1+(y2-y1)/2;
int size = (y2-y1)*CustomSplashScreenConfig.spinningCircleSize;
float f = this.reloadCompleteTime > -1L ? (float) (Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F;
int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F);
int time = (((int) (CustomSplashScreenClient.spinningProgress * 24 * CustomSplashScreenConfig.spinningCircleSpeed))%24)-1;
int color = withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBarColor).getRGB(), m);
for (int j = 0; j<=CustomSplashScreenConfig.spinningCircleTrail; j++) {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
renderSpinningCircle(context,(time+j) % 24,centerY - size,centerY + size, centerX - size, centerX + size,size/5,color);
}
}
}
@Unique
private void renderSpinningCircle(DrawContext context, int time, int top, int bottom, int left, int right, int blockSize, int color) {
switch (time) {
//top
case 0 -> context.fill(left + 4*blockSize, top, left + 3*blockSize, top + blockSize, color);
case 1 -> context.fill(left + 5*blockSize, top, left + 4*blockSize, top + blockSize, color);
case 2 -> context.fill(left + 6*blockSize, top, left + 5*blockSize, top + blockSize, color);
case 3 -> context.fill(left + 7*blockSize, top, left + 6*blockSize, top + blockSize, color);
//top right
case 4 -> context.fill(right - 3*blockSize, top + blockSize, right - 2*blockSize, top + 2*blockSize, color);
case 5 -> context.fill(right - 2*blockSize, top + 2*blockSize, right - blockSize, top + 3*blockSize, color);
//right
case 6 -> context.fill(right - blockSize, top + 3*blockSize, right, top + 4*blockSize, color);
case 7 -> context.fill(right - blockSize, top + 4*blockSize, right, top + 5*blockSize, color);
case 8 -> context.fill(right - blockSize, top + 5*blockSize, right, top + 6*blockSize, color);
case 9 -> context.fill(right - blockSize, top + 6*blockSize, right, top + 7*blockSize, color);
//bottom right
case 10 -> context.fill(right - 2*blockSize, bottom - 2*blockSize, right - blockSize, bottom - 3*blockSize, color);
case 11 -> context.fill(right - 3*blockSize, bottom - blockSize, right - 2*blockSize, bottom - 2*blockSize, color);
//bottom
case 12 -> context.fill(right - 4*blockSize, bottom, right - 3*blockSize, bottom - blockSize, color);
case 13 -> context.fill(right - 5*blockSize, bottom, right - 4*blockSize, bottom - blockSize, color);
case 14 -> context.fill(right - 6*blockSize, bottom, right - 5*blockSize, bottom - blockSize, color);
case 15 -> context.fill(right - 7*blockSize, bottom, right - 6*blockSize, bottom - blockSize, color);
//bottom left
case 16 -> context.fill(left + 3*blockSize, bottom - blockSize, left + 2*blockSize, bottom - 2*blockSize, color);
case 17 -> context.fill(left + 2*blockSize, bottom - 2*blockSize, left + blockSize, bottom - 3*blockSize, color);
//left
case 18 -> context.fill(left + blockSize, bottom - 3*blockSize, left, bottom - 4*blockSize, color);
case 19 -> context.fill(left + blockSize, bottom - 4*blockSize, left, bottom - 5*blockSize, color);
case 20 -> context.fill(left + blockSize, bottom - 5*blockSize, left, bottom - 6*blockSize, color);
case 21 -> context.fill(left + blockSize, bottom - 6*blockSize, left, bottom - 7*blockSize, color);
//top left
case 22 -> context.fill(left + 2*blockSize, top + 2*blockSize, left + blockSize, top + 3*blockSize, color);
case 23 -> context.fill(left + 3*blockSize, top + blockSize, left + 2 * blockSize, top + 2*blockSize, color);
}
}
// Replaced by the methods below for compatibility with Puzzle
// @Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/function/IntSupplier;getAsInt()I"))
// private int css$modifyBackground(IntSupplier instance) { // Set the Background Color to our configured value //
// return !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.backgroundColor).getRGB() | 255 << 24 : 0;
// }
@Inject(method = "withAlpha", at = @At("RETURN"), cancellable = true)
private static void css$modifyBackgroundColor(int color, int alpha, CallbackInfoReturnable<Integer> cir) {
if (color == BRAND_ARGB.getAsInt()) {
int configColor = !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashBackgroundColor).getRGB() | 255 << 24 : 0;
cir.setReturnValue(configColor & 16777215 | alpha << 24);
}
}
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_clearColor(FFFF)V"))
private void css$clearModifiedColor(float red, float green, float blue, float alpha) {
int k = !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashBackgroundColor).getRGB() : 0;
float m = (float)(k >> 16 & 255) / 255.0F;
float n = (float)(k >> 8 & 255) / 255.0F;
float o = (float)(k & 255) / 255.0F;
GlStateManager._clearColor(m, n, o, 1.0F);
}
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/ColorHelper;getWhite(F)I", shift = At.Shift.AFTER))
private void css$betterBlend(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (!CustomSplashScreenConfig.logoBlend) RenderSystem.defaultBlendFunc();
}
@Inject(method = "renderProgressBar", at = @At("HEAD"))
private void css$addProgressBarBackground(DrawContext context, int minX, int minY, int maxX, int maxY, float opacity, CallbackInfo ci) {
if (CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) && CustomSplashScreenConfig.progressBarBackground) {
float f = this.reloadCompleteTime > -1L ? (float) (Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F;
int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F);
RenderSystem.disableBlend();
context.fill(minX, minY, maxX, maxY, withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBackgroundColor).getRGB(), m));
}
}
@ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;fill(IIIII)V"), index = 4)
private int css$modifyProgressFrame(int color) { // Set the Progress Bar Frame Color to our configured value //
return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressFrameColor).getRGB() | 255 << 24 : 0;
}
@ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;fill(IIIII)V", ordinal = 0), index = 4)
private int css$modifyProgressColor(int color) { // Set the Progress Bar Color to our configured value //
return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBarColor).getRGB() | 255 << 24 : 0;
}
}

View File

@@ -1,248 +0,0 @@
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;
import eu.midnightdust.customsplashscreen.texture.BlurredConfigTexture;
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.SplashOverlay;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.resource.ResourceReload;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Final;
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.callback.CallbackInfo;
import java.util.Optional;
import java.util.function.Consumer;
import static net.minecraft.client.gui.DrawableHelper.drawTexture;
import static net.minecraft.client.gui.DrawableHelper.fill;
@Mixin(SplashOverlay.class)
public class SplashScreenMixin {
@Shadow @Final static Identifier LOGO;
@Shadow @Final private MinecraftClient client;
@Shadow @Final private boolean reloading;
@Shadow @Final private ResourceReload reload;
@Shadow private float progress;
@Shadow private long reloadCompleteTime;
@Shadow private long reloadStartTime;
@Shadow @Final private Consumer<Optional<Throwable>> 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);
private static final Identifier BOSS_BAR_TEXTURE = new Identifier(CS_CONFIG.textures.BossBarTexture);
private static final Identifier CUSTOM_PROGRESS_BAR_TEXTURE = new Identifier(CS_CONFIG.textures.CustomBarTexture);
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)
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));
}
else {
client.getTextureManager().registerTexture(LOGO, new EmptyTexture(EMPTY_TEXTURE));
}
client.getTextureManager().registerTexture(ASPECT_1to1_TEXTURE, new ConfigTexture(ASPECT_1to1_TEXTURE));
client.getTextureManager().registerTexture(BACKGROUND_TEXTURE, new ConfigTexture(BACKGROUND_TEXTURE));
client.getTextureManager().registerTexture(CUSTOM_PROGRESS_BAR_TEXTURE, new ConfigTexture(CUSTOM_PROGRESS_BAR_TEXTURE));
client.getTextureManager().registerTexture(CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE, new ConfigTexture(CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE));
ci.cancel();
}
@Inject(at = @At("TAIL"), method = "render")
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
int width = this.client.getWindow().getScaledWidth();
int height = this.client.getWindow().getScaledHeight();
long l = Util.getMeasuringTimeMs();
if (this.reloading && this.reloadStartTime == -1L) {
this.reloadStartTime = l;
}
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) {
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, width, height, withAlpha(m));
s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F);
} else if (this.reloading) {
if (this.client.currentScreen != null && g < 1.0F) {
this.client.currentScreen.render(matrices, mouseX, mouseY, delta);
}
m = MathHelper.ceil(MathHelper.clamp(g, 0.15D, 1.0D) * 255.0D);
fill(matrices, 0, 0, width, height, withAlpha(m));
s = MathHelper.clamp(g, 0.0F, 1.0F);
} else {
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, 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, width, height, width, height);
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) {
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, width / 2 - w, x - 5, width / 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());
}
}
}
private static int getBackgroundColor() {
if (CS_CONFIG.backgroundImage) {
return BackgroundHelper.ColorMixer.getArgb(0, 0, 0, 0);
}
else {
return CustomSplashScreenClient.CS_CONFIG.backgroundColor;
}
}
private static int withAlpha(int alpha) {
return getBackgroundColor() | alpha << 24;
}
@Inject(at = @At("TAIL"), method = "renderProgressBar")
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);
// 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;}
else if (CustomSplashScreenClient.CS_CONFIG.bossBarType == CustomSplashScreenConfig.BossBarType.NOTCHED_10) {overlay = 105;}
else if (CustomSplashScreenClient.CS_CONFIG.bossBarType == CustomSplashScreenConfig.BossBarType.NOTCHED_12) {overlay = 117;}
else if (CustomSplashScreenClient.CS_CONFIG.bossBarType == CustomSplashScreenConfig.BossBarType.NOTCHED_20) {overlay = 129;}
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), bbWidth, bbHeight);
drawTexture(matrices, x1, y1 + 1, 0, 0, 5f, i, (int) ((y2 - y1) / 1.4f), bbWidth, bbHeight);
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), bbWidth, bbHeight);
}
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
}
// 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) {
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);
}
RenderSystem.setShaderTexture(0, CUSTOM_PROGRESS_BAR_TEXTURE);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
drawTexture(matrices, x1, y1, 0, 0, 6, i, y2 - y1, customWidth, 10);
}
// 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);
}
}
}

View File

@@ -1,38 +1,12 @@
package eu.midnightdust.customsplashscreen.texture;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.resource.metadata.TextureResourceMetadata;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.ResourceTexture;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
public class BlurredConfigTexture extends ResourceTexture {
public class BlurredConfigTexture extends ConfigTexture {
// Load textures from the config directory //
public BlurredConfigTexture(Identifier location) {
super(location);
shouldBlur = true;
}
protected TextureData loadTextureData(ResourceManager resourceManager) {
try {
InputStream input = new FileInputStream(FabricLoader.getInstance().getConfigDir()+"/customsplashscreen/"+this.location.toString().replace("minecraft:",""));
TextureData texture;
try {
texture = new TextureData(new TextureResourceMetadata(true, true), NativeImage.read(input));
} finally {
input.close();
}
return texture;
} catch (IOException var18) {
return new TextureData(var18);
}
}
}

View File

@@ -1,18 +1,25 @@
package eu.midnightdust.customsplashscreen.texture;
import net.fabricmc.loader.api.FabricLoader;
import eu.midnightdust.customsplashscreen.CustomSplashScreenClient;
import net.minecraft.client.resource.metadata.TextureResourceMetadata;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.ResourceTexture;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.random.Random;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Objects;
public class ConfigTexture extends ResourceTexture {
public static int randomBackgroundId;
public static int prevBackgroundLength;
// Load textures from the config directory //
public boolean shouldBlur = false;
public ConfigTexture(Identifier location) {
super(location);
@@ -20,11 +27,22 @@ public class ConfigTexture extends ResourceTexture {
protected TextureData loadTextureData(ResourceManager resourceManager) {
try {
InputStream input = new FileInputStream(FabricLoader.getInstance().getConfigDir()+"/customsplashscreen/"+this.location.toString().replace("minecraft:",""));
InputStream input = new FileInputStream(CustomSplashScreenClient.CONFIG_PATH+"/"+this.location.getPath());
if (this.location.getPath().equals("background.png") && CustomSplashScreenClient.CONFIG_PATH.toPath().resolve("backgrounds").toFile().isDirectory()) {
if (CustomSplashScreenClient.CONFIG_PATH.toPath().resolve("backgrounds").toFile().listFiles() != null) {
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]);
if (backgrounds.length > 0) {
if (ConfigTexture.randomBackgroundId == -1 || ConfigTexture.prevBackgroundLength != backgrounds.length) ConfigTexture.randomBackgroundId = Random.create().nextInt(backgrounds.length);
input = new FileInputStream(backgrounds[ConfigTexture.randomBackgroundId]);
ConfigTexture.prevBackgroundLength = backgrounds.length;
}
}
}
TextureData texture;
try {
texture = new TextureData(new TextureResourceMetadata(false, true), NativeImage.read(input));
texture = new TextureData(new TextureResourceMetadata(shouldBlur, true), NativeImage.read(input));
} finally {
input.close();
}

View File

@@ -1,19 +1,45 @@
{
"text.autoconfig.customsplashscreen.title":"Custom Splash Screen Config",
"text.autoconfig.customsplashscreen.option.progressBarType":"Progress Bar Type",
"text.autoconfig.customsplashscreen.option.logoStyle":"Logo Style",
"text.autoconfig.customsplashscreen.option.backgroundImage":"Background Image",
"text.autoconfig.customsplashscreen.option.backgroundColor":"Background Color",
"text.autoconfig.customsplashscreen.option.progressBarColor":"Progress Bar Color",
"text.autoconfig.customsplashscreen.option.progressFrameColor":"Progress Bar Frame Color",
"text.autoconfig.customsplashscreen.option.customProgressBarMode":"Custom Progress Bar Mode",
"text.autoconfig.customsplashscreen.option.customProgressBarBackground":"Custom Progress Bar Background",
"text.autoconfig.customsplashscreen.option.bossBarType":"Boss Bar Style",
"text.autoconfig.customsplashscreen.option.textures":"Texture Locations",
"text.autoconfig.customsplashscreen.option.textures.MojangLogo":"Mojang Logo",
"text.autoconfig.customsplashscreen.option.textures.Aspect1to1Logo":"Aspect 1 to 1 Logo",
"text.autoconfig.customsplashscreen.option.textures.BossBarTexture":"Boss Bar Texture",
"text.autoconfig.customsplashscreen.option.textures.CustomBarTexture":"Custom Progress Bar Texture",
"text.autoconfig.customsplashscreen.option.textures.CustomBarBackgroundTexture":"Custom Progress Bar Background Texture",
"text.autoconfig.customsplashscreen.option.textures.BackgroundTexture":"Background Texture"
"customsplashscreen.midnightconfig.title":"Custom Splash Screen Config",
"customsplashscreen.midnightconfig.category.general":"General",
"customsplashscreen.midnightconfig.category.loading_indicator":"Loading Indicator",
"customsplashscreen.midnightconfig.category.colors":"Colors",
"customsplashscreen.midnightconfig.progressBarType":"Progress Bar Type",
"customsplashscreen.midnightconfig.enum.ProgressBarType.Vanilla":"Vanilla",
"customsplashscreen.midnightconfig.enum.ProgressBarType.BossBar":"Boss Bar",
"customsplashscreen.midnightconfig.enum.ProgressBarType.Custom":"Custom",
"customsplashscreen.midnightconfig.enum.ProgressBarType.SpinningCircle":"Spinning Circle",
"customsplashscreen.midnightconfig.enum.ProgressBarType.Hidden":"Hidden",
"customsplashscreen.midnightconfig.progressBarBackground":"Progress Bar Background",
"customsplashscreen.midnightconfig.logoStyle":"Logo Style",
"customsplashscreen.midnightconfig.enum.LogoStyle.Mojang":"Wide",
"customsplashscreen.midnightconfig.enum.LogoStyle.Aspect1to1":"1to1",
"customsplashscreen.midnightconfig.enum.LogoStyle.Hidden":"Hidden",
"customsplashscreen.midnightconfig.logoBlend":"Use Blending on Logo",
"customsplashscreen.midnightconfig.backgroundImage":"Background Image",
"customsplashscreen.midnightconfig.splashBackgroundColor":"Background Color",
"customsplashscreen.midnightconfig.splashProgressBarColor":"Progress Bar Color",
"customsplashscreen.midnightconfig.splashProgressFrameColor":"Progress Bar Frame Color",
"customsplashscreen.midnightconfig.splashProgressBackgroundColor":"Progress Bar Background Color",
"customsplashscreen.midnightconfig.customProgressBarMode":"Custom Progress Bar Mode",
"customsplashscreen.midnightconfig.enum.ProgressBarMode.Linear":"Linear",
"customsplashscreen.midnightconfig.enum.ProgressBarMode.Stretch":"Stretch",
"customsplashscreen.midnightconfig.enum.ProgressBarMode.Slide": "Slide",
"customsplashscreen.midnightconfig.spinningCircleSize":"Spinning Circle Size",
"customsplashscreen.midnightconfig.spinningCircleSpeed":"Spinning Circle Speed",
"customsplashscreen.midnightconfig.spinningCircleTrail":"Spinning Circle Trail Length",
"customsplashscreen.midnightconfig.bossBarColor":"Boss Bar Color",
"customsplashscreen.midnightconfig.enum.BossBarColor.MAGENTA":"Magenta",
"customsplashscreen.midnightconfig.enum.BossBarColor.CYAN":"Cyan",
"customsplashscreen.midnightconfig.enum.BossBarColor.RED":"Red",
"customsplashscreen.midnightconfig.enum.BossBarColor.LIME":"Lime",
"customsplashscreen.midnightconfig.enum.BossBarColor.YELLOW":"Yellow",
"customsplashscreen.midnightconfig.enum.BossBarColor.PURPLE":"Purple",
"customsplashscreen.midnightconfig.enum.BossBarColor.WHITE":"White",
"customsplashscreen.midnightconfig.bossBarType":"Boss Bar Style",
"customsplashscreen.midnightconfig.enum.BossBarType.PROGRESS":"Progress",
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_6":"6 Notches",
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_10":"10 Notches",
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_12":"12 Notches",
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_20":"20 Notches",
"customsplashscreen.midnightconfig.bossBarSize":"Boss Bar Size"
}

View File

@@ -3,7 +3,8 @@
"package": "eu.midnightdust.customsplashscreen.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"SplashScreenMixin"
"MixinSplashScreen",
"MixinMidnightConfig"
],
"injectors": {
"defaultRequire": 1

View File

@@ -23,9 +23,6 @@
"entrypoints": {
"client": [
"eu.midnightdust.customsplashscreen.CustomSplashScreenClient"
],
"modmenu": [
"eu.midnightdust.customsplashscreen.config.ModMenuIntegration"
]
},
@@ -34,7 +31,7 @@
],
"depends": {
"cloth-config2": "*"
"midnightlib": "*"
},
"breaks": {
"splash": "*",

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB