Mixin icon indicating copy to clipboard operation
Mixin copied to clipboard

cannot target mapped function in an inner class `net.minecraft.client.sound.SoundEngine$SourceSetImpl`

Open gnembon opened this issue 5 years ago • 5 comments

the following redirection works only in dev:

@Mixin(targets="net.minecraft.client.sound.SoundEngine$SourceSetImpl")
public class SoundEngineInt_cleanLogsMixin
{
    @Redirect(method = "createSource", at = @At( remap = false,
            value="INVOKE",
            target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V"
    ))
    private void doWarnOrNotWarn(Logger logger, String message, Object p0)
    { ... }

when built, the target cannot be found (prod)

Mixin apply failed carpet.mixins.json:SoundEngineInt_cleanLogsMixin -> net.minecraft.class_4225$class_4226: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException Critical injection failure: @Redirect annotation on doWarnOrNotWarn could not find any targets matching 'createSource' in net.minecraft.class_4225$class_4226.

Using obfuscated names seems to be targetting just fine

@Mixin(targets="net.minecraft.client.sound.SoundEngine$SourceSetImpl")
public class SoundEngineInt_cleanLogsMixin
{
    // createSource
    @Redirect(method = "method_19666", remap = false, at = @At(remap = false,
            value="INVOKE",
            target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V"
    ))
    private void doWarnOrNotWarn(Logger logger, String message, Object p0)
    { ... }

gnembon avatar Sep 01 '20 11:09 gnembon

Can you try the fully qualified name for this method?

net/minecraft/client/sound/SoundEngine$SourceSet.createSource()Lnet/minecraft/client/sound/Source;

modmuss50 avatar Sep 01 '20 12:09 modmuss50

does work. Its less cryptic, but still more convoluted than just specifying createSource. Reporting to figure out why this doesn't work

gnembon avatar Sep 04 '20 02:09 gnembon

actually - only works in dev with runClient gradle action, not with default IDE client configuration

gnembon avatar Sep 04 '20 03:09 gnembon

Humm, odd. I will take a look at this in more detail hopefully this evening.

modmuss50 avatar Sep 04 '20 07:09 modmuss50

After playing around with this, it seems mixin is just very picky about how this redirect should be defined:

@Redirect(method = "createSource()Lnet/minecraft/client/sound/Source;", at = @At(remap = false,
			value="INVOKE",
			target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V"
	))
	private void doWarnOrNotWarn(Logger logger, String message, Object p0) {
		
	}

Appears to work in both places.

modmuss50 avatar Sep 07 '20 19:09 modmuss50