#[SOLVED] Mod doesn't work after building a jar

1 messages · Page 1 of 1 (latest)

chilly moon
#

Running the mod through intelliJ works perfectly fine. Using the exported jar initially opening the game gives me a resourcepack loading error and attempting to open a world causes a crash throwing the error: java.lang.NullPointerException: Cannot invoke "net.minecraft.class_5944.method_34583(String, Object)" because "$$17" is null
I am using the fabric template mod as a base with split client and server code.

#

This is for 1.20.1

rain karma
#

wich jar are you using?

chilly moon
#

The shortest named non dev jar

rain karma
#

could you send the full log?

chilly moon
#

Yep

thorn vale
#

Caused by: org.spongepowered.asm.mixin.injection.throwables.InjectionError: Critical injection failure: Variable modifier method modGlowCol(ILnet/minecraft/class_2338;Lnet/minecraft/class_8242;)I in dyebrary.client.mixins.json:SignRendererMixin from mod dyebrary failed injection check, (0/1) succeeded. Scanned 0 target(s). Using refmap client-dyebrary-refmap.json

chilly moon
#

what I'm trying to understand is why this works in my IDE but not as an independant jar

rain karma
#

send the source of the mixin method

chilly moon
#
public class SignRendererMixin {
    @ModifyVariable(method = "getColor", at = @At("STORE"), ordinal = 0)
    private static int modCol(int i, SignText sign){
        return ((ISignText)sign).dye_brary$getTextColour();
    }

    //hate to use "name" here, but I straight up don't think I can do without it
    @ModifyVariable(method = "renderText", at = @At("STORE"), name = "k")
    private static int modGlowCol(int k, BlockPos pos, SignText sign){
        return ((ISignText)sign).dye_brary$getTextColour();
    }
}```
rain karma
#

send the entire renderText source method in a paste

chilly moon
#
        BlockPos pos, SignText signText, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int lineHeight, int lineWidth, boolean front
    ) {
        matrices.push();
        this.setTextAngles(matrices, front, this.getTextOffset());
        int i = getColor(signText);
        int j = 4 * lineHeight / 2;
        OrderedText[] orderedTexts = signText.getOrderedMessages(MinecraftClient.getInstance().shouldFilterText(), text -> {
            List<OrderedText> list = this.textRenderer.wrapLines(text, lineWidth);
            return list.isEmpty() ? OrderedText.EMPTY : (OrderedText)list.get(0);
        });
        int k;
        boolean bl;
        int l;
        if (signText.isGlowing()) {
            k = signText.getColor().getSignColor();
            bl = shouldRender(pos, k);
            l = 15728880;
        } else {
            k = i;
            bl = false;
            l = light;
        }

        for (int m = 0; m < 4; m++) {
            OrderedText orderedText = orderedTexts[m];
            float f = -this.textRenderer.getWidth(orderedText) / 2;
            if (bl) {
                this.textRenderer.drawWithOutline(orderedText, f, m * lineHeight - j, k, i, matrices.peek().getPositionMatrix(), vertexConsumers, l);
            } else {
                this.textRenderer
                    .draw(
                        orderedText,
                        f,
                        (float)(m * lineHeight - j),
                        k,
                        false,
                        matrices.peek().getPositionMatrix(),
                        vertexConsumers,
                        TextRenderer.TextLayerType.POLYGON_OFFSET,
                        0,
                        l
                    );
            }
        }

        matrices.pop();
    }```
rain karma
#

use @WrapOperation (or @Redirect for hard fails) to wrap getSignColor() on invocation

chilly moon
#

any tips for avoiding this in the future?

rain karma
chilly moon
#

ha yeah makes sense

rain karma
#

iirc, names only exist in dev. For instance, you cannot use @Local(name="") because it'll work in dev, but crash when used by a player

chilly moon
#

good to know, thanks

#

Mod doesn't work after building a jar [SOLVED]