diff --git a/gradle.properties b/gradle.properties index f675a92..c6b340a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 loader_version=0.18.3 # Mod Properties -mod_version=26.2.16 +mod_version=26.2.17 maven_group=dev.tggamesyt archives_base_name=szar # Dependencies diff --git a/src/client/java/dev/tggamesyt/szar/client/CustomLogoTexture.java b/src/client/java/dev/tggamesyt/szar/client/CustomLogoTexture.java new file mode 100644 index 0000000..f69d4e7 --- /dev/null +++ b/src/client/java/dev/tggamesyt/szar/client/CustomLogoTexture.java @@ -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); + } + } +} + diff --git a/src/client/java/dev/tggamesyt/szar/client/SzarTosHandler.java b/src/client/java/dev/tggamesyt/szar/client/SzarTosHandler.java index 0032268..c572a8e 100644 --- a/src/client/java/dev/tggamesyt/szar/client/SzarTosHandler.java +++ b/src/client/java/dev/tggamesyt/szar/client/SzarTosHandler.java @@ -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 diff --git a/src/client/java/dev/tggamesyt/szar/client/mixin/SplashOverlayMixin.java b/src/client/java/dev/tggamesyt/szar/client/mixin/SplashOverlayMixin.java new file mode 100644 index 0000000..005da24 --- /dev/null +++ b/src/client/java/dev/tggamesyt/szar/client/mixin/SplashOverlayMixin.java @@ -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 = "", 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); + } +} diff --git a/src/client/resources/szar.client.mixins.json b/src/client/resources/szar.client.mixins.json index 7b2bfbc..e96ea3c 100644 --- a/src/client/resources/szar.client.mixins.json +++ b/src/client/resources/szar.client.mixins.json @@ -6,7 +6,8 @@ "client": [ "MouseMixin", "RadiationHeartMixin", - "RadiatedItemRendererMixin" + "RadiatedItemRendererMixin", + "SplashOverlayMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/assets/minecraft/textures/gui/title/mojangstudios.png b/src/main/resources/assets/minecraft/textures/gui/title/mojangstudios.png deleted file mode 100644 index d97d580..0000000 Binary files a/src/main/resources/assets/minecraft/textures/gui/title/mojangstudios.png and /dev/null differ diff --git a/src/main/resources/assets/szar/textures/gui/szarmod.png b/src/main/resources/assets/szar/textures/gui/szarmod.png new file mode 100644 index 0000000..2333f53 Binary files /dev/null and b/src/main/resources/assets/szar/textures/gui/szarmod.png differ