loading screen

This commit is contained in:
2026-02-17 13:09:38 +01:00
parent 49e91b8cc4
commit f06a3d6a99
7 changed files with 136 additions and 3 deletions

View File

@@ -0,0 +1,45 @@
package dev.tggamesyt.szar.client;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
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.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@Environment(EnvType.CLIENT)
public class CustomLogoTexture extends ResourceTexture {
public CustomLogoTexture(Identifier id) {
super(id);
}
@Override
protected TextureData loadTextureData(ResourceManager resourceManager) {
try {
InputStream inputStream = MinecraftClient.class
.getResourceAsStream("/assets/szar/textures/gui/szarmod.png");
if (inputStream == null) {
return new TextureData(
new FileNotFoundException(this.location.toString())
);
}
return new TextureData(
new TextureResourceMetadata(true, true),
NativeImage.read(inputStream)
);
} catch (IOException e) {
return new TextureData(e);
}
}
}

View File

@@ -151,7 +151,7 @@ If you do not agree, click "Decline" and close the game.
private String[] lines;
protected TosScreen() {
super(Text.literal("Szar Fantasy Mod - Terms of Service"));
super(Text.literal("Szar Mod - Information and Terms of Service"));
}
@Override

View File

@@ -0,0 +1,87 @@
package dev.tggamesyt.szar.client.mixin;
import dev.tggamesyt.szar.Szar;
import dev.tggamesyt.szar.client.CustomLogoTexture;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.SplashOverlay;
import net.minecraft.client.texture.ResourceTexture;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.function.IntSupplier;
@Mixin(SplashOverlay.class)
public abstract class SplashOverlayMixin {
@Shadow @Final @Mutable
private static Identifier LOGO;
@Inject(method = "<clinit>", at = @At("TAIL"))
private static void modifyStatic(CallbackInfo ci) {
LOGO = new Identifier(Szar.MOD_ID, "textures/gui/szarmod.png");
}
@Inject(method = "init", at = @At("HEAD"), cancellable = true)
private static void replaceInit(MinecraftClient client, CallbackInfo ci) {
client.getTextureManager().registerTexture(LOGO, new CustomLogoTexture(LOGO));
ci.cancel();
}
@Unique
private static final float SCALE = 2.0F;
@Redirect(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIFFIIII)V"
)
)
private void scaleLogo(
DrawContext context,
Identifier texture,
int x, int y,
int width, int height,
float u, float v,
int regionWidth, int regionHeight,
int textureWidth, int textureHeight
) {
if (!texture.equals(LOGO)) {
context.drawTexture(texture, x, y,
width, height,
u, v,
regionWidth, regionHeight,
textureWidth, textureHeight);
return;
}
int scaledWidth = (int)(width * SCALE);
int scaledHeight = (int)(height * SCALE);
int centerX;
// Determine shared center
if (u < 0) {
// Left half
centerX = x + width;
x = centerX - scaledWidth;
} else {
// Right half
centerX = x;
}
// Vertically scale from center
int centerY = y + height / 2;
y = centerY - scaledHeight / 2;
context.drawTexture(texture,
x, y,
scaledWidth, scaledHeight,
u, v,
regionWidth, regionHeight,
textureWidth, textureHeight);
}
}

View File

@@ -6,7 +6,8 @@
"client": [
"MouseMixin",
"RadiationHeartMixin",
"RadiatedItemRendererMixin"
"RadiatedItemRendererMixin",
"SplashOverlayMixin"
],
"injectors": {
"defaultRequire": 1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB