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.
This commit is contained in:
Motschen
2023-05-26 21:56:20 +02:00
parent 2137a1dbe4
commit 7b236188f6
15 changed files with 426 additions and 411 deletions

View File

@@ -1,7 +1,5 @@
//file:noinspection GroovyAssignabilityCheck
//file:noinspection GrDeprecatedAPIUsage
plugins {
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}
@@ -12,13 +10,10 @@ 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 +24,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 {

View File

@@ -3,19 +3,16 @@ 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.19.4
yarn_mappings=1.19.4+build.2
loader_version=0.14.19
# Mod Properties
mod_version = 1.2.0
mod_version = 2.0.0
maven_group = eu.midnightdust
archives_base_name = customsplashscreen
# 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.81.1+1.19.4
midnightlib_version=1.3.0-fabric

View File

@@ -1,8 +1,6 @@
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.loader.api.FabricLoader;
@@ -10,39 +8,35 @@ 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");
@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();
}
}
}

View File

@@ -1,59 +1,63 @@
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 backgroundColor = "#EF323D";
//"Change the color of the progress bar")
@Entry(category = colors, isColor = true)
public static String progressBarColor = "#FFFFFF";
//"Change the color of the progress bar frame")
@Entry(category = colors, isColor = true)
public static String progressFrameColor = "#FFFFFF";
@Entry(category = colors, isColor = true)
public static String progressBackgroundColor = "#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";
}
//"Change the color of the boss loading bar")
@Entry(category = loading)
public static BossBarColor bossBarColor = BossBarColor.MAGENTA;
//"Change the style of the boss loading bar")
@Entry(category = loading)
public static BossBarType bossBarType = BossBarType.NOTCHED_6;
@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, BossBar, Custom, SpinningCircle, Hidden;
}
public enum LogoStyle {
Mojang, Aspect1to1, Hidden;
@@ -61,6 +65,9 @@ public class CustomSplashScreenConfig implements ConfigData {
public enum ProgressBarMode {
Linear, Stretch;
}
public enum BossBarColor {
MAGENTA, CYAN, RED, LIME, YELLOW, PURPLE, WHITE;
}
public enum BossBarType {
PROGRESS, NOTCHED_6, NOTCHED_10, NOTCHED_12, NOTCHED_20;
}

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, remap = false)
public class MixinMidnightConfig extends Screen {
@Shadow @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 - 28, 50, 20).build());
}
}
}

View File

@@ -0,0 +1,234 @@
package eu.midnightdust.customsplashscreen.mixin;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
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.gui.DrawableHelper;
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.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 java.util.Optional;
import java.util.function.Consumer;
import java.util.function.IntSupplier;
import static net.minecraft.client.gui.DrawableHelper.drawTexture;
import static net.minecraft.client.gui.DrawableHelper.fill;
@Mixin(SplashOverlay.class)
public abstract class MixinSplashScreen {
@Shadow @Final 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;
}
private static final Identifier EMPTY_TEXTURE = new Identifier("customsplashscreen","empty.png");
private static final Identifier MOJANG_TEXTURE = new Identifier("customsplashscreen", "wide_logo.png");
private static final Identifier ASPECT_1to1_TEXTURE = new Identifier("customsplashscreen", "square_logo.png");
private static final Identifier BOSS_BAR_TEXTURE = new Identifier("textures/gui/bars.png");
private static final Identifier CUSTOM_PROGRESS_BAR_TEXTURE = new Identifier("customsplashscreen", "progressbar.png");
private static final Identifier CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE = new Identifier("customsplashscreen", "progressbar_background.png");
private static final Identifier BACKGROUND_TEXTURE = new Identifier("customsplashscreen", "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));
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));
}
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getScaledWidth()I", shift = At.Shift.BEFORE, ordinal = 2))
private void css$renderSplashBackground(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (CustomSplashScreenConfig.backgroundImage) {
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.setShaderTexture(0, BACKGROUND_TEXTURE);
RenderSystem.enableBlend();
RenderSystem.blendEquation(32774);
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s);
drawTexture(matrices, 0, 0, 0, 0, 0, width, height, width, height);
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
}
}
@Inject(at = @At("TAIL"), method = "render")
public void css$render(MatrixStack matrices, 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.setShaderTexture(0, ASPECT_1to1_TEXTURE);
RenderSystem.enableBlend();
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
if (!CustomSplashScreenConfig.logoBlend) RenderSystem.defaultBlendFunc();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s);
drawTexture(matrices, (int)(this.client.getWindow().getScaledWidth() * 0.5D) - (w / 2), (int)(d * 0.5D), w, w, 0, 0, 512, 512, 512, 512);
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(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 (CustomSplashScreenConfig.progressBarType == CustomSplashScreenConfig.ProgressBarType.BossBar) {
int color = CustomSplashScreenConfig.bossBarColor.ordinal() * 10;
RenderSystem.setShaderTexture(0, BOSS_BAR_TEXTURE);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
int overlay = 70 + CustomSplashScreenConfig.bossBarType.ordinal()*10;
drawTexture(matrices, x1, y1 + 1, x2 - x1, (int) ((y2-y1) / 1.4f), 0, color, 182, 5,256, 256);
drawTexture(matrices, x1, y1 + 1, i, (int) ((y2-y1) / 1.4f), 0, color+5, (int) (180 * this.progress), 5, 256, 256);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
if (overlay != 120) {
drawTexture(matrices, x1, y1 + 1, x2 - x1, (int) ((y2-y1) / 1.4f), 0, overlay, 182, 5,256, 256);
}
RenderSystem.disableBlend();
}
// Custom Progress Bar
if (CustomSplashScreenConfig.progressBarType == CustomSplashScreenConfig.ProgressBarType.Custom) {
int customWidth = CustomSplashScreenConfig.customProgressBarMode == CustomSplashScreenConfig.ProgressBarMode.Linear ? x2 - x1 : i;
if (CustomSplashScreenConfig.progressBarBackground) {
RenderSystem.setShaderTexture(0, CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
drawTexture(matrices, x1, y1, 0, 0, 6, x2 - x1, y2 - y1, 10, x2-x1);
}
RenderSystem.setShaderTexture(0, CUSTOM_PROGRESS_BAR_TEXTURE);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
drawTexture(matrices, x1, y1, 0, 0, 6, i, y2 - y1, customWidth, 10);
}
// 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) (MidnightColorUtil.hue * 24 * CustomSplashScreenConfig.spinningCircleSpeed))%24)-1;
int color = withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.progressBarColor).getRGB(), m);
for (int j = 0; j<=CustomSplashScreenConfig.spinningCircleTrail; j++) {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
renderSpinningCircle(matrices,(time+j) % 24,centerY - size,centerY + size, centerX - size, centerX + size,size/5,color);
}
}
}
@Unique
private void renderSpinningCircle(MatrixStack matrices, int time, int top, int bottom, int left, int right, int blockSize, int color) {
switch (time) {
//top
case 0 -> DrawableHelper.fill(matrices, left + 4*blockSize, top, left + 3*blockSize, top + blockSize, color);
case 1 -> DrawableHelper.fill(matrices, left + 5*blockSize, top, left + 4*blockSize, top + blockSize, color);
case 2 -> DrawableHelper.fill(matrices, left + 6*blockSize, top, left + 5*blockSize, top + blockSize, color);
case 3 -> DrawableHelper.fill(matrices, left + 7*blockSize, top, left + 6*blockSize, top + blockSize, color);
//top right
case 4 -> DrawableHelper.fill(matrices, right - 3*blockSize, top + blockSize, right - 2*blockSize, top + 2*blockSize, color);
case 5 -> DrawableHelper.fill(matrices, right - 2*blockSize, top + 2*blockSize, right - blockSize, top + 3*blockSize, color);
//right
case 6 -> DrawableHelper.fill(matrices, right - blockSize, top + 3*blockSize, right, top + 4*blockSize, color);
case 7 -> DrawableHelper.fill(matrices, right - blockSize, top + 4*blockSize, right, top + 5*blockSize, color);
case 8 -> DrawableHelper.fill(matrices, right - blockSize, top + 5*blockSize, right, top + 6*blockSize, color);
case 9 -> DrawableHelper.fill(matrices, right - blockSize, top + 6*blockSize, right, top + 7*blockSize, color);
//bottom right
case 10 -> DrawableHelper.fill(matrices, right - 2*blockSize, bottom - 2*blockSize, right - blockSize, bottom - 3*blockSize, color);
case 11 -> DrawableHelper.fill(matrices, right - 3*blockSize, bottom - blockSize, right - 2*blockSize, bottom - 2*blockSize, color);
//bottom
case 12 -> DrawableHelper.fill(matrices, right - 4*blockSize, bottom, right - 3*blockSize, bottom - blockSize, color);
case 13 -> DrawableHelper.fill(matrices, right - 5*blockSize, bottom, right - 4*blockSize, bottom - blockSize, color);
case 14 -> DrawableHelper.fill(matrices, right - 6*blockSize, bottom, right - 5*blockSize, bottom - blockSize, color);
case 15 -> DrawableHelper.fill(matrices, right - 7*blockSize, bottom, right - 6*blockSize, bottom - blockSize, color);
//bottom left
case 16 -> DrawableHelper.fill(matrices, left + 3*blockSize, bottom - blockSize, left + 2*blockSize, bottom - 2*blockSize, color);
case 17 -> DrawableHelper.fill(matrices, left + 2*blockSize, bottom - 2*blockSize, left + blockSize, bottom - 3*blockSize, color);
//left
case 18 -> DrawableHelper.fill(matrices, left + blockSize, bottom - 3*blockSize, left, bottom - 4*blockSize, color);
case 19 -> DrawableHelper.fill(matrices, left + blockSize, bottom - 4*blockSize, left, bottom - 5*blockSize, color);
case 20 -> DrawableHelper.fill(matrices, left + blockSize, bottom - 5*blockSize, left, bottom - 6*blockSize, color);
case 21 -> DrawableHelper.fill(matrices, left + blockSize, bottom - 6*blockSize, left, bottom - 7*blockSize, color);
//top left
case 22 -> DrawableHelper.fill(matrices, left + 2*blockSize, top + 2*blockSize, left + blockSize, top + 3*blockSize, color);
case 23 -> DrawableHelper.fill(matrices, left + 3*blockSize, top + blockSize, left + 2 * blockSize, top + 2*blockSize, color);
}
}
@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 = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;blendFunc(II)V", shift = At.Shift.AFTER), remap = false)
private void css$betterBlend(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (!CustomSplashScreenConfig.logoBlend) RenderSystem.defaultBlendFunc();
}
@Inject(method = "renderProgressBar", at = @At("HEAD"))
private void css$addProgressBarBackground(MatrixStack matrices, 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();
fill(matrices, minX, minY, maxX, maxY, withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.progressBackgroundColor).getRGB(), m));
}
}
@ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashOverlay;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V"), index = 5)
private int css$modifyProgressFrame(int color) { // Set the Progress Bar Frame Color to our configured value //
return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.progressFrameColor).getRGB() | 255 << 24 : 0;
}
@ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashOverlay;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V", ordinal = 0), index = 5)
private int css$modifyProgressColor(int color) { // Set the Progress Bar Color to our configured value //
return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.progressBarColor).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,43 @@
{
"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.backgroundColor":"Background Color",
"customsplashscreen.midnightconfig.progressBarColor":"Progress Bar Color",
"customsplashscreen.midnightconfig.progressFrameColor":"Progress Bar Frame Color",
"customsplashscreen.midnightconfig.progressBackgroundColor":"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.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"
}

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