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

MappingProvider.getFieldMapping passes an invalid field discriptor to MappingProvider when using @Accessor #419

Closed
modmuss50 opened this issue Jun 21, 2020 · 3 comments

Comments

@modmuss50
Copy link
Contributor

MappingProvider.getFieldMapping passes an invalid field discriptor to MappingProvider when using @Accessor

MappingProvider.getFieldMapping in some cases is passing an invalid MappingField.desc of

Lnet/minecraft/client/particle/ParticleManager$SimpleSpriteProvider;sprites:()Ljava/util/List;

The expected field desc should be:

Lnet/minecraft/client/particle/ParticleManager$SimpleSpriteProvider;sprites:Ljava/util/List;

Note the removal of the ()

A Possible Cause

After a bit of digging I believe this is happening here:

AnnotatedMixinElementHandlerAccessor.java#L297

It appears to be passing the accessor's method desc including the paramters, I believe it should just be the methods return value. My guess is this went untoiced with MCP as it does not handle the concept of field descriptors.

An Example

Note: All minecraft names are in yarn names

We can came across this issue with the following mixin.

The accessor is an innner interface to a parent mixin if that helps. I have tried with . and / package seperators to no avail, as well as removing the accessor target as its not needed here.

	@Mixin(targets = "net/minecraft/client/particle/ParticleManager$SimpleSpriteProvider")
	interface SimpleSpriteProviderAccessor {
		@Accessor("sprites")
		List<Sprite> getSprites();
	}

The target class (ParticleManager.SimpleSpriteProvider) looks something similar to this:

   @Environment(EnvType.CLIENT)
   class SimpleSpriteProvider implements SpriteProvider {
      private List<Sprite> sprites;

      public void setSprites(List<Sprite> sprites) {
         this.sprites = ImmutableList.copyOf(sprites);
      }
   }

Conclusion

fabric-mixin-compile-extensions could also strip the paremeters from the MappingField before looking up the obfuscated name.

Please dont hesisate to ask for more info if there is something I have missed. I am also in the sponge discord if thats easier.

@modmuss50
Copy link
Contributor Author

I have applied a workaround succesfully here: MixinMappingProviderTiny.java.

Its just a simple change that removes any method params that turned up in the field desc

@Johni0702
Copy link

Same issue as the Invalid field descriptor section of #390 I believe.

@modmuss50
Copy link
Contributor Author

Yes, you are correct.

That would have saved me a lot of time lol 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants