Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gnembon opened this issue Sep 1, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@gnembon
Copy link

gnembon commented Sep 1, 2020

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)
    { ... }
@modmuss50
Copy link
Member

Can you try the fully qualified name for this method?

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

@gnembon
Copy link
Author

gnembon commented Sep 4, 2020

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

@gnembon
Copy link
Author

gnembon commented Sep 4, 2020

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

@modmuss50
Copy link
Member

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

@modmuss50 modmuss50 added the bug Something isn't working label Sep 4, 2020
@modmuss50 modmuss50 self-assigned this Sep 4, 2020
@modmuss50
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants