#Mod compatibility issue

5 messages · Page 1 of 1 (latest)

woeful token
#

I have a mod that changes colors of player nicks. It works on vanilla, It doesnt work on Lunar client.

Originally i did this:

@Mixin(EntityRenderer.class)
public class EntityRendererMixin {

    @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderer;renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V"))
    private void renderLabelIfPresent(Args args) {
        if (!ConfigManager.get().changeNickColor) return;
        Entity entity = args.get(0);
        if (!(entity instanceof AbstractClientPlayerEntity player)) {
            return;
        }
        var playerName = player.getName().getString();
        Formatting color = GlowUtils.getGlowColor(player);
        if (color == null) return;
        Text newText = Text.literal(playerName).formatted(color);

        args.set(1, newText);
    }
}

On vanilla it worked great. On lunar client it doesn't work. Simply nothing happens.

#

So i went with a diffrent approach.

@Mixin(PlayerEntityRenderer.class)
public abstract class PlayerEntityRendererMixin extends LivingEntityRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> {
    public PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntityModel<AbstractClientPlayerEntity> model, float shadowRadius) {
        super(ctx, model, shadowRadius);
    }

    @Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
    private void injectRenderLabel(AbstractClientPlayerEntity player, Text text,
                                   MatrixStack matrices, VertexConsumerProvider vertexConsumers,
                                   int yOffset, float tickDelta, CallbackInfo ci) {

        if (!ConfigManager.get().changeNickColor) return;

        var playerName = player.getName().getString();
        Formatting color = GlowUtils.getGlowColor(player);
        if (color == null) return;
        Text newText = Text.literal(playerName).formatted(color);

        matrices.push();
        
        super.renderLabelIfPresent(player, newText, matrices, vertexConsumers, yOffset, tickDelta);
        matrices.pop();

        ci.cancel();
    }
}

This again worked on vanilla, but on Lunar Client it made the nick entirely dissapear.

Tbf i didnt test it outside of IDE runClient task. So im not 100% its Lunar Client that is the culprit, But then again why would a built jar mod behave diffrently tothe one ran from the IDE.

So my question is, is there any realistic way i can achieve being compatible with lunar? I suspect lunar hooks and changes player's nicks themselves somewhere(they have builtin addons for that)

lucid spade
woeful token
finite trout