Jump to content

Recommended Posts

Posted

Good day everybody.

So i have my class AICChangesWrapper, that i have to patch at runtime, so it can access methods with modified descriptions.

But, it does not get patched. It does not even show up in logs, if i log all classes that are given to transformer.

 

No, it is not in transformer exclusions.

 

If you want to look at logs and classes, here's gist (Class i want to transform is AICChangesWrapper. From transformer all other transformation methods for other classes were removed, as they take 1500 lines): https://gist.github.com/elix-x/891ddb6528dc87ba479b0a56a7473797

 

What should i do to be able to transform my class?

 

Thanks for help!

If you have any questions - just ask!

Posted

Ok, what? Why are you transforming your own classes? :o

Because i can't apply coremod to my workspace to see applied changes.

 

Seriously, though. I apply changes to some vanilla fields' methods' descriptions (and handling all mod compatibility, hence why 1500 lines, although not all of them for it), and i have to access those fields and methods in alternat way. So i created a class that wraps all important changes to methods, providing all possible usage scenarios (so my head does not overheat trying to support every single possible usage scenario with ASM). But in order to invoke those changed methods without compiler errors, i have to add them in with ASM.

 

Why not reflection?

Well, i already tried relfection. But because method is called over 9000 times a tick, it was too slow.

So i need direct invocation without compiler errors.

Posted

Apart from the fact that you should not be changing vanilla methods' arguments, etc. (seriously, don't do it!):

If you must access things that "don't exist" you have two options: either use MethodHandles API (one thing they can do is fast reflection). If you have a MethodHandle in a static final field (both is important!) and call invokeExact on it it will behave exactly like a direct method call.

Alternatively: Make an interface that contains the changed method signatures and make vanilla class implement that interface via ASM. Then you can just cast the vanilla instance to your interface and call the methods.

The problem with interfaces is obfuscation.

And with MethodHandles API: method not found.

 

But it think i figured out why i can't transform my class: it's loaded before transformers are initialized.

Now that i managed to fix load order, i can transform my class.

Posted

Why are you doing this?!

 

Read:

What are you adding to the method signatures and why?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Don't make coremods, what you're doing and how you're doing it is extremely bad.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.