Jump to content

[1.7.10] Own class can't be transformed with ASM?


Elix_x

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Here is a tutorial from this same forum that I tried and kinda made work. Take into account that you will have to manage the offset (like rotation, and the offset relative to things like the main hand, offhand etc) by yourself and that can get very troublesome at times.  
    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
  • Topics

×
×
  • Create New...

Important Information

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