From 8ed02fef87f13d92068db626643a3f72bfaecd7e Mon Sep 17 00:00:00 2001 From: Martin Prokoph Date: Wed, 19 Nov 2025 19:04:04 +0100 Subject: [PATCH] stonecutter: support 1.21.5 --- build.gradle.kts | 5 ++++ .../java/net/puzzlemc/core/PuzzleClient.java | 2 +- .../splashscreen/PuzzleSplashScreen.java | 22 +++++++++++---- .../splashscreen/mixin/MixinSplashScreen.java | 28 ++++++++++++++++--- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 309acea..c968de0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -245,4 +245,9 @@ stonecutter { constants { arrayOf("fabric", "neoforge", "forge").forEach { it -> put(it, loader == it) } } + + replacements.string { + direction = eval(current.version, ">=1.21.8") + replace("context.renderComponentTooltip(", "context.setComponentTooltipForNextFrame(") + } } diff --git a/src/main/java/net/puzzlemc/core/PuzzleClient.java b/src/main/java/net/puzzlemc/core/PuzzleClient.java index fbb7d66..6d98265 100644 --- a/src/main/java/net/puzzlemc/core/PuzzleClient.java +++ b/src/main/java/net/puzzlemc/core/PuzzleClient.java @@ -68,7 +68,7 @@ public class PuzzleClient { ModList.get().getModContainerById(MOD_ID).orElseThrow().registerExtensionPoint(IConfigScreenFactory.class, (client, parent) -> new PuzzleOptionsScreen(parent)); } - @EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT) + @EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT /^? if <= 1.21.5 {^/ /^, bus = EventBusSubscriber.Bus.MOD ^//^?}^/) public static class MidnightLibBusEvents { @SubscribeEvent public static void onResourceReload(AddClientReloadListenersEvent event) { diff --git a/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java b/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java index 0b853aa..517c194 100644 --- a/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java +++ b/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java @@ -34,6 +34,13 @@ import java.nio.file.StandardCopyOption; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; +//? if <= 1.21.5 { +/*import net.minecraft.client.gui.screens.LoadingOverlay; +import net.minecraft.client.renderer.RenderStateShard; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.util.TriState; +*///?} + import static net.puzzlemc.core.PuzzleCore.LOGGER; import static net.puzzlemc.core.PuzzleCore.MOD_ID; @@ -45,7 +52,9 @@ public class PuzzleSplashScreen { public static Path BACKGROUND_TEXTURE = Paths.get(CONFIG_PATH + "/splash_background.png"); private static Minecraft client = Minecraft.getInstance(); private static boolean keepBackground = false; - private static RenderPipeline CUSTOM_LOGO_PIPELINE; + public static RenderPipeline CUSTOM_LOGO_PIPELINE; + //? if <= 1.21.5 + /*public static RenderType CUSTOM_LOGO_LAYER;*/ public static void init() { if (!CONFIG_PATH.exists()) { // Run when config directory is nonexistent // @@ -59,10 +68,6 @@ public class PuzzleSplashScreen { buildRenderLayer(); } - public static RenderPipeline getCustomLogoRenderPipeline() { - return CUSTOM_LOGO_PIPELINE; - } - public static void buildRenderLayer() { if (PuzzleConfig.resourcepackSplashScreen) { BlendFunction blendFunction = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE); @@ -86,6 +91,13 @@ public class PuzzleSplashScreen { CUSTOM_LOGO_PIPELINE_BUILDER = blendFunction != null ? CUSTOM_LOGO_PIPELINE_BUILDER.withBlend(blendFunction) : CUSTOM_LOGO_PIPELINE_BUILDER.withoutBlend(); CUSTOM_LOGO_PIPELINE = CUSTOM_LOGO_PIPELINE_BUILDER.build(); + + //? if <= 1.21.5 { + /*CUSTOM_LOGO_LAYER = RenderType.create("mojang_logo_puzzle", 786432, CUSTOM_LOGO_PIPELINE, + RenderType.CompositeState.builder() + .setTextureState(new RenderStateShard.TextureStateShard(LoadingOverlay.MOJANG_STUDIOS_LOGO_LOCATION, TriState.DEFAULT, false)) + .createCompositeState(false)); + *///?} } } diff --git a/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java b/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java index a862dca..fdebe38 100644 --- a/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java +++ b/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java @@ -2,14 +2,12 @@ package net.puzzlemc.splashscreen.mixin; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.mojang.blaze3d.pipeline.RenderPipeline; import com.mojang.blaze3d.platform.NativeImage; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.LoadingOverlay; import net.minecraft.client.gui.screens.Overlay; -import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.resources.ResourceLocation; @@ -27,8 +25,16 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +import java.util.function.Function; import java.util.function.IntSupplier; +//? if >= 1.21.8 { +import com.mojang.blaze3d.pipeline.RenderPipeline; +import net.minecraft.client.renderer.RenderPipelines; +//?} else { +/*import net.minecraft.client.renderer.RenderType; +*///?} + import static net.puzzlemc.splashscreen.PuzzleSplashScreen.BACKGROUND; @Mixin(value = LoadingOverlay.class, priority = 2000) @@ -63,12 +69,21 @@ public abstract class MixinSplashScreen extends Overlay { return (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressBarBackgroundColor == 15675965) ? instance.getAsInt() : PuzzleConfig.backgroundColor | 255 << 24; } + //? if >= 1.21.8 { @WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blit(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/ResourceLocation;IIFFIIIIIII)V")) private void puzzle$modifyRenderLayer(GuiGraphics context, RenderPipeline pipeline, ResourceLocation sprite, int x, int y, float u, float v, int width, int height, int regionWidth, int regionHeight, int textureWidth, int textureHeight, int color, Operation original) { if (PuzzleConfig.resourcepackSplashScreen) - context.blit(PuzzleSplashScreen.getCustomLogoRenderPipeline(), sprite, x, y, u, v, width, height, regionWidth, regionHeight, textureWidth, textureHeight, color); + context.blit(PuzzleSplashScreen.CUSTOM_LOGO_PIPELINE, sprite, x, y, u, v, width, height, regionWidth, regionHeight, textureWidth, textureHeight, color); else context.blit(pipeline, sprite, x, y, u, v, width, height, textureWidth, textureHeight, color); } + //?} else { + /*@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blit(Ljava/util/function/Function;Lnet/minecraft/resources/ResourceLocation;IIFFIIIIIII)V")) + private void puzzle$modifyRenderLayer(GuiGraphics context, Function renderType, ResourceLocation sprite, int x, int y, float u, float v, int width, int height, int regionWidth, int regionHeight, int textureWidth, int textureHeight, int color, Operation original) { + if (PuzzleConfig.resourcepackSplashScreen) + context.blit(id -> PuzzleSplashScreen.CUSTOM_LOGO_LAYER, sprite, x, y, u, v, width, height, regionWidth, regionHeight, textureWidth, textureHeight, color); + else context.blit(renderType, sprite, x, y, u, v, width, height, textureWidth, textureHeight, color); + } + *///?} @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;guiWidth()I", ordinal = 2)) private void puzzle$renderSplashBackground(GuiGraphics context, int mouseX, int mouseY, float delta, CallbackInfo ci) { @@ -82,7 +97,12 @@ public abstract class MixinSplashScreen extends Overlay { if (f >= 1.0F) s = 1.0F - Mth.clamp(f - 1.0F, 0.0F, 1.0F); else if (fadeIn) s = Mth.clamp(g, 0.0F, 1.0F); else s = 1.0F; - context.blit(RenderPipelines.GUI_TEXTURED, BACKGROUND, 0, 0, 0, 0, width, height, width, height, ARGB.white(s)); + //? if >= 1.21.8 { + context.blit(RenderPipelines.GUI_TEXTURED + //?} else { + /*context.blit(RenderType::guiTextured + *///?} + , BACKGROUND, 0, 0, 0, 0, width, height, width, height, ARGB.white(s)); } }