mirror of
https://github.com/PuzzleMC/Puzzle.git
synced 2025-12-16 03:45:10 +01:00
Puzzle 1.5.0 - 1.19.4, Options overhaul, Fixed splash screen
- Port to 1.19.4 - Overhaul the Puzzle Options screen - Categories are now displayed via tabs - Fix #50 (Splash screen logo being pixelated) - Add compatibility with Exordium
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package net.puzzlemc.splashscreen;
|
||||
|
||||
import com.mojang.blaze3d.platform.TextureUtil;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import eu.midnightdust.lib.util.MidnightColorUtil;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.minecraft.client.texture.AbstractTexture;
|
||||
import net.minecraft.client.texture.NativeImageBackedTexture;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
@@ -22,10 +25,8 @@ import net.minecraft.util.Identifier;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -67,10 +68,6 @@ public class PuzzleSplashScreen implements ClientModInitializer {
|
||||
public Identifier getFabricId() {
|
||||
return new Identifier("puzzle", "splash_screen");
|
||||
}
|
||||
|
||||
public void method_14491(ResourceManager manager) {
|
||||
reload(manager);
|
||||
}
|
||||
@Override
|
||||
public void reload(ResourceManager manager) {
|
||||
if (PuzzleConfig.resourcepackSplashScreen) {
|
||||
@@ -107,8 +104,7 @@ public class PuzzleSplashScreen implements ClientModInitializer {
|
||||
manager.findResources("textures", path -> path.getPath().contains("mojangstudios.png")).forEach((id, resource) -> {
|
||||
try (InputStream stream = manager.getResource(id).get().getInputStream()) {
|
||||
Files.copy(stream, LOGO_TEXTURE, StandardCopyOption.REPLACE_EXISTING);
|
||||
InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE));
|
||||
client.getTextureManager().registerTexture(LOGO, new NativeImageBackedTexture(NativeImage.read(input)));
|
||||
client.getTextureManager().registerTexture(LOGO, new DynamicLogoTexture());
|
||||
} catch (Exception e) {
|
||||
LogManager.getLogger("Puzzle").error("Error occurred while loading custom minecraft logo " + id.toString(), e);
|
||||
}
|
||||
@@ -156,4 +152,18 @@ public class PuzzleSplashScreen implements ClientModInitializer {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class DynamicLogoTexture extends ResourceTexture {
|
||||
public DynamicLogoTexture() {
|
||||
super(LOGO);
|
||||
}
|
||||
protected TextureData loadTextureData(ResourceManager resourceManager) {
|
||||
try {
|
||||
InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE));
|
||||
return new TextureData(new TextureResourceMetadata(true, true), NativeImage.read(input));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +45,7 @@ public abstract class MixinSplashScreen extends Overlay {
|
||||
private static void puzzle$initSplashscreen(MinecraftClient client, CallbackInfo ci) { // Load our custom textures at game start //
|
||||
if (PuzzleConfig.resourcepackSplashScreen) {
|
||||
if (PuzzleSplashScreen.LOGO_TEXTURE.toFile().exists()) {
|
||||
try {
|
||||
InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE));
|
||||
client.getTextureManager().registerTexture(LOGO, new NativeImageBackedTexture(NativeImage.read(input)));
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
client.getTextureManager().registerTexture(LOGO, new PuzzleSplashScreen.DynamicLogoTexture());
|
||||
}
|
||||
if (PuzzleSplashScreen.BACKGROUND_TEXTURE.toFile().exists()) {
|
||||
try {
|
||||
@@ -68,7 +64,7 @@ public abstract class MixinSplashScreen extends Overlay {
|
||||
private void puzzle$betterBlend(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (PuzzleConfig.disableBlend) RenderSystem.defaultBlendFunc();
|
||||
}
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getScaledWidth()I", shift = At.Shift.BEFORE))
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getScaledWidth()I", shift = At.Shift.BEFORE, ordinal = 2))
|
||||
private void puzzle$renderSplashBackground(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (Files.exists(PuzzleSplashScreen.BACKGROUND_TEXTURE)) {
|
||||
int width = client.getWindow().getScaledWidth();
|
||||
@@ -96,11 +92,11 @@ public abstract class MixinSplashScreen extends Overlay {
|
||||
}
|
||||
@Inject(method = "renderProgressBar", at = @At("HEAD"))
|
||||
private void puzzle$addProgressBarBackground(MatrixStack matrices, int minX, int minY, int maxX, int maxY, float opacity, CallbackInfo ci) {
|
||||
RenderSystem.disableBlend();
|
||||
if (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressBarBackgroundColor == 15675965) return;
|
||||
long l = Util.getMeasuringTimeMs();
|
||||
float f = this.reloadCompleteTime > -1L ? (float)(l - this.reloadCompleteTime) / 1000.0F : -1.0F;
|
||||
int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F);
|
||||
RenderSystem.disableBlend();
|
||||
fill(matrices, minX, minY, maxX, maxY, withAlpha(PuzzleConfig.progressBarBackgroundColor, m));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user