Closed quat1024 closed 3 weeks ago
This is already tracked I believe, but regardless LocalCapture + INVOKE_ASSIGN would be a very brittle choice here. Consider instead @ModifyVariable
and @At("STORE")
, or even better https://github.com/LlamaLad7/MixinExtras/wiki/ModifyExpressionValue if you have MixinExtras available.
Ahhh i forgot modifyvariable can also include the method parameters x) was confusing it with ModifyArg
Here's an assignment from
net.minecraft.world.entity.ai.sensing.TemptingSensor#doTick
(1.20.1 forge 47.1.3):The instruction stream for this assignment ends like this:
I wanted to inject into
doTick
after the.collect
call and pick up theList<Player>
, so I used anINVOKE_ASSIGN
injection with local capture. (This felt more appropriate than a modifyvariable, since I also needed to pick up a few method params.)However, the local variable table didn't include
list
. The injector actually ended up targeting theCHECKCAST
instruction before the local was assigned.It looks like the AfterInvoke injector wants to advance over the
INVOKE
& over any_STORE
instructions immediately following it, but theCHECKCAST
got in the way. https://github.com/SpongePowered/Mixin/blob/155314e6e91465dad727e621a569906a410cd6f4/src/main/java/org/spongepowered/asm/mixin/injection/points/AfterInvoke.java#L84-L87In this case it's workaroundable with
shift = At.Shift.BY, by = 2
or targeting a later part of the method.