cannot target mapped function in an inner class `net.minecraft.client.sound.SoundEngine$SourceSetImpl`
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)
{ ... }
Can you try the fully qualified name for this method?
net/minecraft/client/sound/SoundEngine$SourceSet.createSource()Lnet/minecraft/client/sound/Source;
does work. Its less cryptic, but still more convoluted than just specifying createSource. Reporting to figure out why this doesn't work
actually - only works in dev with runClient gradle action, not with default IDE client configuration
Humm, odd. I will take a look at this in more detail hopefully this evening.
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.