Open LambdAurora opened 3 years ago
To conclude, mixin is way too aggressive in its checks globally which impedes its capacities.
It's not "too aggressive", this is by design, so it's exactly as aggressive as it was intended to be. Changes are coming in 0.9 which address this and other issues which affect manipulation of interfaces and default methods.
It's not "too aggressive", this is by design, so it's exactly as aggressive as it was intended to be.
I don't reject the fact that it's by design, I badly worded that part, but my point is some checks can end up more frustrating than it should for a mixin user. At least I'm happy to see that work is being done to improve manipulation of interfaces.
I've been trying to inject code into the lambda in this file, which is quite similar to the Oxidizable
registry mentioned above.
My Mixin code is below.
@Mixin(value = Mossable.class, remap = false)
public interface MossableMixin {
@Inject(
method = "lambda$static$0",
at = @At(
value = "INVOKE",
target="com/ordana/immersive_weathering/IWPlatformStuff.addExtraMossyBlocks (Lcom/google/common/collect/ImmutableBiMap$Builder;)V"
), locals = LocalCapture.CAPTURE_FAILSOFT, remap = false
)
private static void lambda$static$0(
CallbackInfoReturnable<BiMap<Block, Block>> cir,
ImmutableBiMap.Builder<Block, Block> builder
) {
WeatheringHelper.addOptional(builder, "twigs:cobblestone_bricks", "twigs:mossy_cobblestone_bricks");
}
}
On running this code, I get the following error adjustments.mixins.json:MossableMixin: Interface mixin contains a non-public method! Found lambda$static$0(Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfoReturnable;Lcom/google/common/collect/ImmutableBiMap$Builder;)V in adjustments.mixins.json:MossableMixin
.
The mixin version I'm using is 0.8.7 on Forge 1.20.1. My compatibility level is Java 17.
Someone on the Discord mentioned that this might be a bug, so I decided to put this here.
Mixin and interfaces is a long story of friendship.
Let's take it from the start and talk about the
Oxidizable
interface in Minecraft 1.17, all names here are from the yarn mappings.All oxidation level increases are done with a supplier of a bimap of blocks, and the level decreases one is simply the inversion of the first.
It looks like that
For any mods which wants to add blocks in this map will find a wall, a big one.
Let's take a look at Java 8 first and the issues:
final
and the JVM won't like that at all.public static
injector (required by interfaces in Java 8)any other injection-like will fail due to the same issues.
With the recent upgrade to Java 16 we now have access to private methods in interfaces, and I guessed I could finally ditch the ugly raw-asm transformation, but yet it's still impossible due to the fact that mixin yells
tesla_coil.mixins.json:OxidizableMixin: Interface mixin contains a non-public method! Found onBuildLevelIncreasesMap(Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfoReturnable;)V in tesla_coil.mixins.json:OxidizableMixin
So, I cannot use a class mixin, I cannot use a public static injector, nor a private static injector.
(note: even though Java 16 is not yet officially supported, the issue still exist if using Java 11 as the private methods in interfaces are in Java since Java 9)
To conclude, mixin is way too aggressive in its checks globally which impedes its capacities.