stonecutter: support 1.21.5

This commit is contained in:
Martin Prokoph
2025-11-19 19:04:04 +01:00
parent 36bc344b94
commit 8ed02fef87
4 changed files with 47 additions and 10 deletions

View File

@@ -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(")
}
}

View File

@@ -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) {

View File

@@ -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));
*///?}
}
}

View File

@@ -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<Void> 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<ResourceLocation, RenderType> 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<Void> 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));
}
}