Jump to content

Recommended Posts

Posted

I'm a semi competent java developer and I find forge extremely interesting as it allows compatibility between many mods and handles a lot of seemingly difficult problems associated with compatibility between code written by different people for different things. From what I gather it uses hooks? to handle requests to things that are base game? I've looked at the github and specifically the patches and a lot of the function names are not really human readable nor good names haha. are the patches auto generated? how are they made? what are hooks and how do they work? How does forge handle mod loading and potential code overlaps? What is the structure of forge? Where would be a good place for me to start reading in the github to get a basic understanding of how it runs and works?

 

Thanks!

Posted

In basic words:

Game is launched, forge injects its changes to vanilla code (using ASM). Those changes add new methods that are called by vanilla source, special case - events that are called when something happens. When event happens all mods that subscribe to it can know of it and act. They can also cancel it and/or change outcome. Note that events also can have priority, so its not like full compatibility is always possible.

 

All those questions are pretty broad, and I am not the person who works with internals to descripe exact processes.

Anyway - when you setup your workspace - all events are in forge's events packages (client+common).

 

As to question about "code overlaps" - it doesn't really work like that. As said - events can be tracked by every mod which can than respond to them, code won't overlap since its totally separate thing. What can overlap is when you are writing CORE Mod. Core mod is a mod that uses ASM (like Forge itself) to modify code at runtime (startup). Because of that Core Modding is extremely incompatible and can lead to errors - thus it is discouraged to do so (unless absolutely needed, in which case you are most certainly writing something VERY specific, which Forge can't handle for you using events).

1.7.10 is no longer supported by forge, you are on your own.

Posted

I made it so that vanilla torches explode, using events. That was fun.

DRAGONMANG: "I'm Dragonmang, m8. Here me roar."

HERO: "Oh no... not. Dragonmang."

DRAGONMANG: "Roar, m8."

HERO: "Ahhh......"

And so the brave knight and Dragonmang fought on the mountaintop for many moons....

Posted

Yeah, the patches are generated using "magic" (no, they are not written by hand, obviously). THey are injected on startup using ASM.

 

Hook = "extra" methods and events. On top of that there is obviously a lot of other things (like model api/loaders, registry, ore dictionary, shit ton of useful things you won't find in vanilla).

And by "extra" I mean - Forge adds quite some methods that are called on the way of vanilla calls which allows modders more access to what is happening (those methods are mainly for mod-made code, e.g: You have better access to how your e.g: ItemWand works or methods that ask you what should be returend is very specific situation of using your Item).

1.7.10 is no longer supported by forge, you are on your own.

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



×
×
  • Create New...

Important Information

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