Depending on what you’re doing, you could also use reflection to access the field - you can then Mixin to the inner class, add an interface to it and expose the methods you need that way (you can mixin using the Mixin annotation like so) .
Note that this has been requested on the Mixin github, with reflection as the stop-gap answer:
opened 05:42PM - 08 Sep 18 UTC
feature
core
An issue I'm currently having with mixins is shadowing a field whose type is pac… kage private. The field is in SoundManager, and that is the class that I'm mixing into. The type of this field that I'm talking about is `SoundManager.SoundSystemStarterThread`. This package-private class extends SoundSystem, and that is the class that has all the functionality I want to use in it.
Ideally, I would be able to shadow this field by specifying the super type, `SoundSystem`, like so:
```java
@Mixin(SoundManager.class)
public class MixinSoundManager {
@Shadow
private SoundSystem sndSystem;
}
```
If it would be possible to check if the type specified in the shadow field is a super type of the mixin class's field at run-time, and allow it if so, that would be optimal. However, if not, another possible solution is to add a `signature` property to the `@Shadow` annotation that will specify the actual signature of the field so Mixins can correctly find the field. These might not even be the best solutions, so I'm welcome to feedback or other ideas :)
I am not sure if this functionality is possible, but it would be very useful. Access Transformers are not an option in the environment I'm targeting, and reflection is definitely not the optimal solution, so I'm hoping that this is possible.
and a similar (though not the same) problem has been asked about on the forums
Hi all,
I have the following mixin -
@Mixin(ContainerBeacon.class)
public abstract class MixinContainerBeacon extends Container {
@Shadow
@Final
private Slot beaconSlot;
@Inject(method = "onContainerClosed", at = @At("HEAD"))
public void onOnContainerClosed(EntityPlayer player, CallbackInfo ci) {
if (player instanceof EntityPlayerMP) {
if (beaconSlot.getStack().getCount() > 1) {
EnchantmentCracker.dropItemCheck();
}
}
}
}
However, the beaconSlot field is actually decla…
We don’t have much on what you’re trying to do so can’t really advise further (though not sure if I could anyway), but there are ways around it if you try hard enough!