#Mixin to block constructor not working after 1.21

54 messages · Page 1 of 1 (latest)

young yoke
#

I had this mixin for 1.20.1 which made torchflowers glow, and it worked fine. But now after updating to 1.21, it doesn't work anymore. It causes minecraft to crash.

@Mixin(value = Blocks.class)
public class TorchflowerGlow {
    @ModifyArg(
            method = "<clinit>",
            slice = @Slice(
                    from = @At(value = "CONSTANT", args = "stringValue=torchflower"),
                    to = @At(value = "CONSTANT", args = "stringValue=poppy")),
            at = @At(
                    value = "INVOKE",
                    target = "Lnet/minecraft/block/FlowerBlock;<init>" +
                            "(Lnet/minecraft/entity/effect/StatusEffect;ILnet/minecraft/block/AbstractBlock$Settings;)V"),
            index = 2)

    private static AbstractBlock.Settings changeLuminance(AbstractBlock.Settings addLum) {

        return addLum.luminance(state -> 15);
    }
}```
Now it gives me 'Cannot resolve target reference' for the target, and 'There are no possible signatures for this injector' for AbstractBlock.settings addLum
dusty stone
#

apply the mixin to block constructor

#

you can take the settings paramater inside the constructor and change it

young yoke
#

thats what im doing

dusty stone
# young yoke thats what im doing

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.TorchflowerBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(TorchflowerBlock.class)
public class BlockLightingExampleMixin {
    @Inject(at=@At("TAIL"),method = "<init>")
    private void initMixin(AbstractBlock.Settings settings, CallbackInfo ci) {
        settings.luminance(state -> 15); // 15 - Max light
    }
}
#

havent tested but it might wrok

dusty stone
# young yoke here's the log

Also, its harder to debug if you arent using any mappings in the log. Can you run it from the ide next time you get an error?

#

i know i can just look it up on the bot

#

but

#

actually nvm

#

im gonna look it up

young yoke
#

idk if this has anything to do with the mixin but its still crashing

dusty stone
#

well

#

i dont see your mod listed

#

on the error

#

maybe im just dumb

#

im gonna look at geckolib real quick

dusty stone
#

update all your dependancies to 1.21

#

its trying to access stuff that was made private in 1.21\

#

or protected

dusty stone
#

@young yoke did it work?

young yoke
#

no idea yet

dusty stone
#

????????

dusty stone
young yoke
#

yes

young yoke
dusty stone
#

hold on

#

im testing a fix rn

#

this lighting thing is dumb

#

omgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg

#

no fucking way

#

i was modifing the seeds the whole time 😭

#

omfg

#

i cant get the settings of the existing block cuz it wants me to inject into abstract block or something

dusty stone
#

if this doesnt work ima implode

#

testing....

dusty stone
#

sgtj9s8rhoijopirdjhrdoijy

#

😭

#

@young yoke ive tried everything i could think of, i dont know if its possible

#

i keep getting an error in registry when i try to reregister the block

young yoke
#

Well it is, it worked before

dusty stone
#

i cant change the light amount after its been registered

#

i dont know what to do anymore

calm hearth
#

@young yoke your target's signature is wrong

#

that FlowerBlock constructor takes a RegistryEntry<StatusEffect> now

#

it should be "Lnet/minecraft/block/FlowerBlock;<init>(Lnet/minecraft/registry/entry/RegistryEntry;FLnet/minecraft/block/AbstractBlock$Settings;)V"

dusty stone
#

Nooooooooooooooo way

#

Damn

young yoke
#

thanks, it works