stonecutter: support 1.21.1

This commit is contained in:
Martin Prokoph
2025-11-19 20:50:38 +01:00
parent 8ed02fef87
commit 6e270b1a4d
7 changed files with 127 additions and 49 deletions

View File

@@ -250,4 +250,16 @@ stonecutter {
direction = eval(current.version, ">=1.21.8") direction = eval(current.version, ">=1.21.8")
replace("context.renderComponentTooltip(", "context.setComponentTooltipForNextFrame(") replace("context.renderComponentTooltip(", "context.setComponentTooltipForNextFrame(")
} }
replacements.string {
direction = eval(current.version, ">=1.21.5")
replace("getTextureImage", "loadContents")
}
replacements.string {
direction = eval(current.version, ">=1.21.5")
replace("TextureImage", "TextureContents")
}
replacements.string {
direction = eval(current.version, ">=1.21.5")
replace("SimpleTexture", "ReloadableTexture")
}
} }

View File

@@ -1,7 +1,5 @@
package net.puzzlemc.core; package net.puzzlemc.core;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.puzzlemc.gui.screen.PuzzleOptionsScreen; import net.puzzlemc.gui.screen.PuzzleOptionsScreen;
@@ -58,8 +56,13 @@ import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModList; import net.neoforged.fml.ModList;
import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod; import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory; import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
//? if >= 1.21.5 {
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
//?} else {
/^import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
^///?}
@Mod(value = MOD_ID, dist = Dist.CLIENT) @Mod(value = MOD_ID, dist = Dist.CLIENT)
public class PuzzleClient { public class PuzzleClient {
@@ -70,10 +73,17 @@ public class PuzzleClient {
@EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT /^? if <= 1.21.5 {^/ /^, bus = EventBusSubscriber.Bus.MOD ^//^?}^/) @EventBusSubscriber(modid = MOD_ID, value = Dist.CLIENT /^? if <= 1.21.5 {^/ /^, bus = EventBusSubscriber.Bus.MOD ^//^?}^/)
public static class MidnightLibBusEvents { public static class MidnightLibBusEvents {
//? if >= 1.21.5 {
@SubscribeEvent @SubscribeEvent
public static void onResourceReload(AddClientReloadListenersEvent event) { public static void onResourceReload(AddClientReloadListenersEvent event) {
event.addListener(ResourceLocation.fromNamespaceAndPath(MOD_ID, "splash_screen"), PuzzleSplashScreen.ReloadListener.INSTANCE); event.addListener(ResourceLocation.fromNamespaceAndPath(MOD_ID, "splash_screen"), PuzzleSplashScreen.ReloadListener.INSTANCE);
} }
//?} else {
/^@SubscribeEvent
public static void onResourceReload(RegisterClientReloadListenersEvent event) {
event.registerReloadListener(PuzzleSplashScreen.ReloadListener.INSTANCE);
}
^///?}
} }
} }
*///?} *///?}

View File

@@ -30,7 +30,7 @@ public class PuzzleGui {
PuzzleConfig.resourcepackSplashScreen = !PuzzleConfig.resourcepackSplashScreen; PuzzleConfig.resourcepackSplashScreen = !PuzzleConfig.resourcepackSplashScreen;
PuzzleSplashScreen.resetColors(); PuzzleSplashScreen.resetColors();
PuzzleConfig.write(MOD_ID); PuzzleConfig.write(MOD_ID);
Minecraft.getInstance().getTextureManager().registerAndLoad(PuzzleSplashScreen.LOGO, new PuzzleSplashScreen.LogoTexture(PuzzleSplashScreen.LOGO)); Minecraft.getInstance().getTextureManager()./*? if >= 1.21.5 {*/ registerAndLoad /*?} else {*//*register*//*?}*/(PuzzleSplashScreen.LOGO, new PuzzleSplashScreen.LogoTexture(PuzzleSplashScreen.LOGO));
})); }));
PuzzleApi.addToResourceOptions(new PuzzleWidget(Component.translatable("puzzle.option.unlimited_model_rotations"), (button) -> button.setMessage(PuzzleConfig.unlimitedRotations ? YES : NO), (button) -> { PuzzleApi.addToResourceOptions(new PuzzleWidget(Component.translatable("puzzle.option.unlimited_model_rotations"), (button) -> button.setMessage(PuzzleConfig.unlimitedRotations ? YES : NO), (button) -> {
PuzzleConfig.unlimitedRotations = !PuzzleConfig.unlimitedRotations; PuzzleConfig.unlimitedRotations = !PuzzleConfig.unlimitedRotations;

View File

@@ -1,6 +1,5 @@
package net.puzzlemc.gui.screen.widget; package net.puzzlemc.gui.screen.widget;
import net.minecraft.client.gui.components.AbstractTextAreaWidget;
import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.EditBox;

View File

@@ -1,18 +1,13 @@
package net.puzzlemc.splashscreen; package net.puzzlemc.splashscreen;
import com.mojang.blaze3d.pipeline.BlendFunction;
import com.mojang.blaze3d.pipeline.RenderPipeline; import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.platform.DepthTestFunction;
import com.mojang.blaze3d.platform.DestFactor;
import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.platform.SourceFactor;
import eu.midnightdust.lib.util.MidnightColorUtil; import eu.midnightdust.lib.util.MidnightColorUtil;
import eu.midnightdust.lib.util.PlatformFunctions; import eu.midnightdust.lib.util.PlatformFunctions;
import net.minecraft.Util; import net.minecraft.Util;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.ReloadableTexture; import net.minecraft.client.renderer.texture.ReloadableTexture;
import net.minecraft.client.renderer.texture.TextureContents;
import net.minecraft.client.resources.metadata.texture.TextureMetadataSection; import net.minecraft.client.resources.metadata.texture.TextureMetadataSection;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.PackType;
@@ -20,7 +15,6 @@ import net.minecraft.server.packs.VanillaPackResources;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
import net.puzzlemc.core.config.PuzzleConfig; import net.puzzlemc.core.config.PuzzleConfig;
import net.puzzlemc.splashscreen.mixin.RenderPipelinesAccessor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
@@ -34,7 +28,16 @@ import java.nio.file.StandardCopyOption;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
//? if <= 1.21.5 { //? if >= 1.21.5 {
import com.mojang.blaze3d.pipeline.BlendFunction;
import com.mojang.blaze3d.platform.DepthTestFunction;
import com.mojang.blaze3d.platform.DestFactor;
import com.mojang.blaze3d.platform.SourceFactor;
import net.minecraft.client.renderer.texture.TextureContents;
import net.puzzlemc.splashscreen.mixin.RenderPipelinesAccessor;
//?}
//? if = 1.21.5 {
/*import net.minecraft.client.gui.screens.LoadingOverlay; /*import net.minecraft.client.gui.screens.LoadingOverlay;
import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
@@ -53,7 +56,7 @@ public class PuzzleSplashScreen {
private static Minecraft client = Minecraft.getInstance(); private static Minecraft client = Minecraft.getInstance();
private static boolean keepBackground = false; private static boolean keepBackground = false;
public static RenderPipeline CUSTOM_LOGO_PIPELINE; public static RenderPipeline CUSTOM_LOGO_PIPELINE;
//? if <= 1.21.5 //? if = 1.21.5
/*public static RenderType CUSTOM_LOGO_LAYER;*/ /*public static RenderType CUSTOM_LOGO_LAYER;*/
public static void init() { public static void init() {
@@ -65,9 +68,11 @@ public class PuzzleSplashScreen {
} }
} }
} }
//? if >= 1.21.5
buildRenderLayer(); buildRenderLayer();
} }
//? if >= 1.21.5 {
public static void buildRenderLayer() { public static void buildRenderLayer() {
if (PuzzleConfig.resourcepackSplashScreen) { if (PuzzleConfig.resourcepackSplashScreen) {
BlendFunction blendFunction = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE); BlendFunction blendFunction = new BlendFunction(SourceFactor.SRC_ALPHA, DestFactor.ONE);
@@ -100,6 +105,7 @@ public class PuzzleSplashScreen {
*///?} *///?}
} }
} }
//?}
public static class ReloadListener implements ResourceManagerReloadListener { public static class ReloadListener implements ResourceManagerReloadListener {
public static final ReloadListener INSTANCE = new ReloadListener(); public static final ReloadListener INSTANCE = new ReloadListener();
@@ -111,8 +117,8 @@ public class PuzzleSplashScreen {
client = Minecraft.getInstance(); client = Minecraft.getInstance();
if (PuzzleConfig.resourcepackSplashScreen) { if (PuzzleConfig.resourcepackSplashScreen) {
PuzzleSplashScreen.resetColors(); PuzzleSplashScreen.resetColors();
client.getTextureManager().registerAndLoad(LOGO, new LogoTexture(LOGO)); client.getTextureManager()./*? if >= 1.21.5 {*/ registerAndLoad /*?} else {*//*register*//*?}*/(LOGO, new LogoTexture(LOGO));
client.getTextureManager().registerAndLoad(BACKGROUND, new LogoTexture(BACKGROUND)); client.getTextureManager()./*? if >= 1.21.5 {*/ registerAndLoad /*?} else {*//*register*//*?}*/(BACKGROUND, new LogoTexture(BACKGROUND));
manager.listResources("optifine", path -> path.getPath().contains("color.properties")).forEach((id, resource) -> { manager.listResources("optifine", path -> path.getPath().contains("color.properties")).forEach((id, resource) -> {
try (InputStream stream = resource.open()) { try (InputStream stream = resource.open()) {
@@ -150,7 +156,7 @@ public class PuzzleSplashScreen {
manager.listResources("textures", path -> path.getPath().contains("mojangstudios.png")).forEach((id, resource) -> { manager.listResources("textures", path -> path.getPath().contains("mojangstudios.png")).forEach((id, resource) -> {
try (InputStream stream = resource.open()) { try (InputStream stream = resource.open()) {
Files.copy(stream, LOGO_TEXTURE, StandardCopyOption.REPLACE_EXISTING); Files.copy(stream, LOGO_TEXTURE, StandardCopyOption.REPLACE_EXISTING);
client.getTextureManager().registerAndLoad(LOGO, new DynamicLogoTexture()); client.getTextureManager()./*? if >= 1.21.5 {*/ registerAndLoad /*?} else {*//*register*//*?}*/(LOGO, new DynamicLogoTexture());
if (logoCount.get() > 0) PuzzleConfig.hasCustomSplashScreen = true; if (logoCount.get() > 0) PuzzleConfig.hasCustomSplashScreen = true;
logoCount.getAndIncrement(); logoCount.getAndIncrement();
} catch (Exception e) { } catch (Exception e) {
@@ -161,7 +167,7 @@ public class PuzzleSplashScreen {
try (InputStream stream = resource.open()) { try (InputStream stream = resource.open()) {
Files.copy(stream, BACKGROUND_TEXTURE, StandardCopyOption.REPLACE_EXISTING); Files.copy(stream, BACKGROUND_TEXTURE, StandardCopyOption.REPLACE_EXISTING);
InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE)); InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE));
client.getTextureManager().register(BACKGROUND, new DynamicTexture(() -> "splash_screen_background", NativeImage.read(input))); client.getTextureManager().register(BACKGROUND, new DynamicTexture(/*? if >= 1.21.5 {*/() -> "splash_screen_background",/*?}*/ NativeImage.read(input)));
keepBackground = true; keepBackground = true;
PuzzleConfig.hasCustomSplashScreen = true; PuzzleConfig.hasCustomSplashScreen = true;
} catch (Exception e) { } catch (Exception e) {
@@ -175,6 +181,7 @@ public class PuzzleSplashScreen {
} }
keepBackground = false; keepBackground = false;
PuzzleConfig.write(MOD_ID); PuzzleConfig.write(MOD_ID);
//? if >= 1.21.5
buildRenderLayer(); buildRenderLayer();
} }
} }
@@ -190,24 +197,20 @@ public class PuzzleSplashScreen {
PuzzleConfig.hasCustomSplashScreen = false; PuzzleConfig.hasCustomSplashScreen = false;
} }
public static class LogoTexture extends ReloadableTexture { public static class LogoTexture extends ReloadableTexture {
public LogoTexture(ResourceLocation logo) { super(logo); } public LogoTexture(ResourceLocation logo) {
super(logo);
}
@Override @Override
public @NotNull TextureContents loadContents(ResourceManager resourceManager) { public @NotNull TextureContents loadContents(ResourceManager resourceManager) {
Minecraft client = Minecraft.getInstance(); Minecraft client = Minecraft.getInstance();
VanillaPackResources defaultResourcePack = client.getVanillaPackResources(); VanillaPackResources defaultResourcePack = client.getVanillaPackResources();
try { try (InputStream input = Objects.requireNonNull(defaultResourcePack.getResource(PackType.CLIENT_RESOURCES, LOGO)).get()) {
InputStream inputStream = Objects.requireNonNull(defaultResourcePack.getResource(PackType.CLIENT_RESOURCES, LOGO)).get(); return /*? if >= 1.21.5 {*/ new TextureContents(NativeImage.read(input), new TextureMetadataSection(true, true)) /*?} else {*/ /*new TextureContents(new TextureMetadataSection(true, true), NativeImage.read(input)) *//*?}*/;
TextureContents tex; } catch (IOException ex) {
try { return /*? if >= 1.21.5 {*/ TextureContents.createMissing() /*?} else {*/ /*new TextureContents(ex) *//*?}*/;
tex = new TextureContents(NativeImage.read(inputStream), new TextureMetadataSection(true, true));
} finally {
inputStream.close();
}
return tex;
} catch (IOException var18) {
return TextureContents.createMissing();
} }
} }
} }
@@ -218,17 +221,20 @@ public class PuzzleSplashScreen {
} }
@Override @Override
public @NotNull TextureContents loadContents(ResourceManager resourceManager) { public @NotNull TextureContents loadContents(ResourceManager resourceManager) {
try { try (InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE))) {
InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE)); return /*? if >= 1.21.5 {*/ new TextureContents(NativeImage.read(input), new TextureMetadataSection(true, true)) /*?} else {*/ /*new TextureContents(new TextureMetadataSection(true, true), NativeImage.read(input)) *//*?}*/;
return new TextureContents(NativeImage.read(input), new TextureMetadataSection(true, true));
} catch (IOException e) { } catch (IOException e) {
LOGGER.error("Encountered an error during logo loading: ", e); LOGGER.error("Encountered an error during logo loading: ", e);
//? if >= 1.21.5 {
try { try {
return TextureContents.load(resourceManager, LOGO); return TextureContents.load(resourceManager, LOGO);
} catch (IOException ex) { } catch (IOException ex) {
return TextureContents.createMissing(); return TextureContents.createMissing();
} }
//?} else {
/*return TextureContents.load(resourceManager, LOGO);
*///?}
} }
} }
} }
} }

View File

@@ -1,7 +1,5 @@
package net.puzzlemc.splashscreen.mixin; package net.puzzlemc.splashscreen.mixin;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.NativeImage;
import net.minecraft.Util; import net.minecraft.Util;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -11,7 +9,6 @@ import net.minecraft.client.gui.screens.Overlay;
import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ARGB;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.puzzlemc.core.config.PuzzleConfig; import net.puzzlemc.core.config.PuzzleConfig;
import net.puzzlemc.splashscreen.PuzzleSplashScreen; import net.puzzlemc.splashscreen.PuzzleSplashScreen;
@@ -25,21 +22,34 @@ import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.function.Function;
import java.util.function.IntSupplier; import java.util.function.IntSupplier;
//? if >= 1.21.8 { //? if >= 1.21.8 {
import net.minecraft.util.ARGB;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.pipeline.RenderPipeline; import com.mojang.blaze3d.pipeline.RenderPipeline;
import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.renderer.RenderPipelines;
//?} else { //?} else if >= 1.21.5 {
/*import net.minecraft.client.renderer.RenderType; /*import net.minecraft.util.ARGB;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.client.renderer.RenderType;
import java.util.function.Function;
*///?} else {
/*import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.GameRenderer;
import static net.puzzlemc.core.PuzzleCore.LOGGER;
*///?} *///?}
import static net.puzzlemc.splashscreen.PuzzleSplashScreen.BACKGROUND; import static net.puzzlemc.splashscreen.PuzzleSplashScreen.BACKGROUND;
//? if >= 1.21.5
import static net.minecraft.client.gui.screens.LoadingOverlay.MOJANG_STUDIOS_LOGO_LOCATION;
@Mixin(value = LoadingOverlay.class, priority = 2000) @Mixin(value = LoadingOverlay.class, priority = 2000)
public abstract class MixinSplashScreen extends Overlay { public abstract class MixinSplashScreen extends Overlay {
@Shadow @Final public static ResourceLocation MOJANG_STUDIOS_LOGO_LOCATION;
@Shadow private long fadeInStart; @Shadow private long fadeInStart;
@Shadow @Final private Minecraft minecraft; @Shadow @Final private Minecraft minecraft;
@Shadow @Final private boolean fadeIn; @Shadow @Final private boolean fadeIn;
@@ -48,17 +58,24 @@ public abstract class MixinSplashScreen extends Overlay {
private static int replaceAlpha(int color, int alpha) { private static int replaceAlpha(int color, int alpha) {
return 0; return 0;
} }
//? if < 1.21.5
/*@Shadow @Final static ResourceLocation MOJANG_STUDIOS_LOGO_LOCATION;*/
@Inject(method = "registerTextures", at = @At("TAIL")) @Inject(method = "registerTextures", at = @At("TAIL")) // Load our custom textures at game start //
private static void puzzle$initSplashscreen(TextureManager textureManager, CallbackInfo ci) { // Load our custom textures at game start // //? if >= 1.21.5 {
private static void puzzle$initSplashscreen(TextureManager textureManager, CallbackInfo ci) {
//?} else {
/*private static void puzzle$initSplashscreen(Minecraft client, CallbackInfo ci) {
TextureManager textureManager = client.getTextureManager();
*///?}
if (PuzzleConfig.resourcepackSplashScreen) { if (PuzzleConfig.resourcepackSplashScreen) {
if (PuzzleSplashScreen.LOGO_TEXTURE.toFile().exists()) { if (PuzzleSplashScreen.LOGO_TEXTURE.toFile().exists()) {
textureManager.registerAndLoad(MOJANG_STUDIOS_LOGO_LOCATION, new PuzzleSplashScreen.DynamicLogoTexture()); textureManager./*? if >= 1.21.5 {*/ registerAndLoad /*?} else {*//*register*//*?}*/(MOJANG_STUDIOS_LOGO_LOCATION, new PuzzleSplashScreen.DynamicLogoTexture());
} }
if (PuzzleSplashScreen.BACKGROUND_TEXTURE.toFile().exists()) { if (PuzzleSplashScreen.BACKGROUND_TEXTURE.toFile().exists()) {
try { try {
InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE)); InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE));
textureManager.register(BACKGROUND, new DynamicTexture(() -> "splash_screen_background", NativeImage.read(input))); textureManager.register(BACKGROUND, new DynamicTexture(/*? if >= 1.21.5 {*/ () -> "splash_screen_background", /*?}*/ NativeImage.read(input)));
} catch (IOException ignored) {} } catch (IOException ignored) {}
} }
} }
@@ -76,13 +93,31 @@ public abstract class MixinSplashScreen extends Overlay {
context.blit(PuzzleSplashScreen.CUSTOM_LOGO_PIPELINE, 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 context.blit(pipeline, sprite, x, y, u, v, width, height, textureWidth, textureHeight, color);
} }
//?} else { //?} else if >= 1.21.5 {
/*@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;blit(Ljava/util/function/Function;Lnet/minecraft/resources/ResourceLocation;IIFFIIIIIII)V")) /*@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) { 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) if (PuzzleConfig.resourcepackSplashScreen)
context.blit(id -> PuzzleSplashScreen.CUSTOM_LOGO_LAYER, sprite, x, y, u, v, width, height, regionWidth, regionHeight, textureWidth, textureHeight, color); 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); else context.blit(renderType, sprite, x, y, u, v, width, height, textureWidth, textureHeight, color);
} }
*///?} else {
/*@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;blendFunc(II)V", shift = At.Shift.AFTER), remap = false)
private void puzzle$betterBlend(GuiGraphics context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (PuzzleConfig.resourcepackSplashScreen) {
if (PuzzleConfig.disableBlend) RenderSystem.disableBlend();
else if (PuzzleConfig.customBlendFunction.size() == 4) {
try {
RenderSystem.blendFuncSeparate(
GlStateManager.SourceFactor.valueOf(PuzzleConfig.customBlendFunction.get(0)),
GlStateManager.DestFactor.valueOf(PuzzleConfig.customBlendFunction.get(1)),
GlStateManager.SourceFactor.valueOf(PuzzleConfig.customBlendFunction.get(2)),
GlStateManager.DestFactor.valueOf(PuzzleConfig.customBlendFunction.get(3)));
} catch (Exception e) {
LOGGER.error("Incorrect blend function defined in color.properties: {}{}", PuzzleConfig.customBlendFunction, e.getMessage());
}
}
}
}
*///?} *///?}
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;guiWidth()I", ordinal = 2)) @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;guiWidth()I", ordinal = 2))
@@ -97,12 +132,19 @@ public abstract class MixinSplashScreen extends Overlay {
if (f >= 1.0F) s = 1.0F - Mth.clamp(f - 1.0F, 0.0F, 1.0F); 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 if (fadeIn) s = Mth.clamp(g, 0.0F, 1.0F);
else s = 1.0F; else s = 1.0F;
//? if >= 1.21.8 { //? if >= 1.21.8 {
context.blit(RenderPipelines.GUI_TEXTURED context.blit(RenderPipelines.GUI_TEXTURED, BACKGROUND, 0, 0, 0, 0, width, height, width, height, ARGB.white(s));
//?} else { //?} else if >= 1.21.5 {
/*context.blit(RenderType::guiTextured /*context.blit(RenderType::guiTextured, BACKGROUND, 0, 0, 0, 0, width, height, width, height, ARGB.white(s));
*///?} else {
/*RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s);
context.blit(BACKGROUND, 0, 0, 0, 0, width, height, width, height);
RenderSystem.disableBlend();
*///?} *///?}
, BACKGROUND, 0, 0, 0, 0, width, height, width, height, ARGB.white(s));
} }
} }

View File

@@ -1,5 +1,6 @@
package net.puzzlemc.splashscreen.mixin; package net.puzzlemc.splashscreen.mixin;
//? if > 1.21.1 {
import com.mojang.blaze3d.pipeline.RenderPipeline; import com.mojang.blaze3d.pipeline.RenderPipeline;
import net.minecraft.client.renderer.RenderPipelines; import net.minecraft.client.renderer.RenderPipelines;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@@ -12,3 +13,11 @@ public interface RenderPipelinesAccessor {
return null; return null;
} }
} }
//?} else {
/*import eu.midnightdust.core.MidnightLib;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(MidnightLib.class)
public interface RenderPipelinesAccessor {} // TODO: Properly disable this mixin when on 1.21.1 and lower
*///?}