Mixin icon indicating copy to clipboard operation
Mixin copied to clipboard

[Question] Detect if a mixin patch was applied (any)

Open Speiger opened this issue 3 years ago • 3 comments

o/ this is more of a question, maybe a feature request if it makes sense but if not thats fine too.

Basically I have a problem where a mixin might be loaded and I need to alter my code if it is loaded. But I can not make a global modcheck since the code i am applying fixes a bug and how i fix the bug is dependent on if said mixin is loaded.

And sadly if my tooling gets it wrong this will result in a crash.

So is there a way if a mixin was applied to a specific class? Maybe some metadata who patched the class? (that would make the task easier)

Speiger avatar Jul 13 '22 16:07 Speiger

It depends on when you need to detect the presence of the mixin, before the classload or after. If it's after classload you can use Mixins::getMixinsForClass, if before then it gets a bit more complicated.

Mumfrey avatar Jul 14 '22 15:07 Mumfrey

Nah i just need to detect a class when a command is ran and that is done after the class has been loaded for sure (the world has to exist)

But thank you :)

Speiger avatar Jul 14 '22 17:07 Speiger

@Mumfrey ok i checked it out, and the example you have given me is actually inverse of what i asked for xD But Reflection should allow me to trace the cache and find it out myself.

Speiger avatar Jul 25 '22 19:07 Speiger