Add support for Minecraft 26.1

- Since Dynmap has not yet been updated to be compatible with Minecraft 26.1, the compatibility Mixins for Dynmap are currently not enabled for this version.
This commit is contained in:
CPTProgrammer
2026-04-18 06:17:23 +08:00
parent edaf3115bb
commit 43e582fbe6
4 changed files with 48 additions and 4 deletions
@@ -34,6 +34,10 @@ import static cn.revaria.chatplus.util.TextStyleFormatter.applyStyle;
"org.dynmap.fabric_1_21_9_10.DynmapPlugin$ChatHandler",
"org.dynmap.fabric_1_21_11.DynmapPlugin$ChatHandler",
}
#elif MC_VER <= MC_26_1
// TODO: Since Dynmap has not yet been updated to be compatible with Minecraft 26.1,
// the compatibility Mixins for Dynmap are currently not enabled for this version.
{}
#endif
)
public abstract class DynmapMixin {
@@ -1,6 +1,11 @@
package cn.revaria.chatplus.mixin.compat;
#if MC_VER <= MC_1_21
import eu.pb4.placeholders.api.PlaceholderContext;
#else
import eu.pb4.placeholders.api.ServerPlaceholderContext;
#endif
import eu.pb4.styledchat.StyledChatUtils;
import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Mixin;
@@ -14,8 +19,19 @@ import static cn.revaria.chatplus.util.TextStyleFormatter.applyStyle;
@Pseudo
@Mixin(StyledChatUtils.class)
public abstract class StyledChatMixin {
@Inject(method = "formatFor(Leu/pb4/placeholders/api/PlaceholderContext;Ljava/lang/String;)Lnet/minecraft/network/chat/Component;", at = @At("RETURN"), cancellable = true)
private static void modifyText(PlaceholderContext context, String input, CallbackInfoReturnable<Component> cir) {
cir.setReturnValue(applyStyle(cir.getReturnValue(), context.player()));
@Inject(method =
#if MC_VER <= MC_1_21
"formatFor(Leu/pb4/placeholders/api/PlaceholderContext;Ljava/lang/String;)Lnet/minecraft/network/chat/Component;"
#else
"formatFor(Leu/pb4/placeholders/api/ServerPlaceholderContext;Ljava/lang/String;)Lnet/minecraft/network/chat/Component;"
#endif,
at = @At("RETURN"),
cancellable = true
)
private static void modifyText(
#if MC_VER <= MC_1_21 PlaceholderContext #else ServerPlaceholderContext #endif context,
String input, CallbackInfoReturnable<Component> cir
) {
cir.setReturnValue(applyStyle(cir.getReturnValue(), context.#if MC_VER <= MC_1_21 player() #else serverPlayer() #endif));
}
}