Jump to content

Recommended Posts

Posted

Through a lot of determination and code sleuthing, I've managed to get a grasp on setting up a core mod and using it to employ class transformers.

 

Just as a preliminary test, I made a transformer that would add

|| var8 == Block.arbitraryBlock.blockId

to BlockFarmland in its isCropsNearby method to expand what it considered a crop.

 

The transformer works well enough, but it got me thinking about the best ways to go about transforming classes. It seems like injecting code at arbitrary points would be fragile in that slight modification to the class by other transformers would mess up the bytecode "heuristics" I used to do it. Furthermore, just adding code to an arbitrary location in the class seems not much better than actually editing the class.

 

So, my question is: What kind of programming practices do you consider to be effective or proper when dealing with arbitrary code insertion? I've seen patterns where you just insert a redirect at the beginning of the method and go from there, and I've also seen stuff on the internet about the proxy class design pattern (though I don't understand it too well right now). Is there another pattern that would be effective?

 

I'm looking for advice/opinions on this mostly, how the modders on these boards do/would do it, rather than some concrete answer.

 

P.S. After learning some ASM and going through a LOT of the code, I started to realize just how complex and powerful Forge is, so bravo cpw and LexManos, this project is definitely an achievement.

 

EDIT: I just found out that the latest build of Forge actually has a new interface related to what I was sort of accomplishing here, but my question still stands!

Posted

In general you want to minimize your footprint so as to not step on other mods trying to do the same thing.  Pick a good point, like a call and cancel hook at the start or something, rather than just mass editing the code.

Posted

Thanks for the advice, Overmind! I had kind of given up on this topic. I leaning in the direction of what you said.

 

I was mostly worried about screwing up the variable indexes and possibly labels further on in a method's bytecode if I inserted sufficiently complex logic. I think that if other people are smart though, they will use simple heuristics like I did to get around that problem.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Is there a fix for this issue? I have tried reinstalling OpenAL.dll, switching Java versions, and even muting my game when it launched, but all of these attempts have resulted in my game crashing nonetheless. I have been dealing with this issue for approximately a week straight. I have not changed any sound settings, so I am very confused. Full Code: https://gnomebot.dev/paste/mclogs/beEBzpm "4/16/2025 12:16:30 AM 1000 Error Faulting application name: javaw.exe, version: **.**.**.**, time stamp: 23 0xd75c3041 24 Faulting module name: OpenAL.dll, version: **.**.**.**, time stamp: 0x647635a125 Exception code: 0xc0000409 26 Fault offset: 0x00000000000a2b05 27 Faulting process id: 0x10A0 28 Faulting application start time: 0x1DBAE81D04A6F2F 29 Faulting application path: C:\Users\********\curseforge\minecraft\Install\java30 \java-runtime-delta\bin\javaw.exe 31 Faulting module path: C:\Users\********\curseforge\minecraft\Install\natives\n32 eoforge-21.1.148\OpenAL.dll 33 Report Id: 28552180-f359-40cc-adeb-08dada7e99d8 34 Faulting package full name: 35 Faulting package-relative application ID:" Any sort of insight would be greatly appreciated, it's giving me a headache.
    • I'm new to this, if that wasn't obvious. My friend and I are trying to make a modpack for 1.19.2. I've made a modpack previously with 0 issues before and many of the same mods. However, I can't seem to find the issue when trying to load up his new modpack.   Any help would be greatly appreciated.
    • Im trying to make a customized modpack for just myself using the atm9 modpack as a base. It was working till recently, when curseforge force updated all the mods in the pack. Currently every time I get to the main menu I try and create a world in single player and it just says saving world. then generates a crash report.    Crash Report: https://pastebin.com/xXESPfJs   Latest Log Part 1: https://pastebin.com/Cb2VpUyr  Part 2: https://pastebin.com/9SWVn4Dx
    • Okay, for him the config file looked like this: flywheel-client.toml: #Select the backend to use. Set to "DEFAULT" to let Flywheel decide. backend = "DEFAULT" #Enable or disable instance update limiting with distance. limitUpdates = true #The number of worker threads to use. Set to -1 to let Flywheel decide. Set to 0 to disable parallelism. Requires a game restart to take effect. #Range: -1 ~ 12 workerThreads = -1 #Config options for Flywheel's built-in backends. [flw_backends]     #How smooth Flywheel's shader-based lighting should be. May have a large performance impact.     #Allowed Values: FLAT, TRI_LINEAR, SMOOTH, SMOOTH_INNER_FACE_CORRECTED     lightSmoothness = "SMOOTH" There was no "INSTANCING", so we changed "DEFAULT" to "OFF", but this didn't help. Changing it to "INSTANCING" didn't work as well.
  • Topics

×
×
  • Create New...

Important Information

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