Jump to content

Recommended Posts

Posted

I am currently making a new mod, while at the same time need to maintain another mod. Thing is, the both mods share ALOT of code, rather then maintaining the command code base in two seperate mods, I thought it would be best to put them in a mod library, kinda like what OpenBlocks does with OpenLib, LLibrary, and various core mods. (granted, I am not using ASM at this time)

 

How exactly does someone make one, I am not even sure on the first step to how to do it.

Posted

What I did was just have separate packages in my workspace (mod.draco18s.library, mod.draco18s.mod1, mod.draco18s.mod2...) and use the build.gradle file to set up separate build tasks that would put the compiled code into separate jar files.

 

A few other folks will have other suggestions, but this is the one that worked for me.

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

You can build a library, in this case its recommended you shade the library into the final jar to make it easiest on the end user to install it.

Trying to split a project into multiple jars would just be annoying to setup. And annoying for the end user.

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

Posted

What works for me (though there are drawbacks) is creating a separate package for shared code. One drawback is that I must avoid static fields that would work perfectly well to support one mod but fail miserably as soon as two or more mods collide. In other words, when you lift some of your existing code to a higher level of abstraction, you may need to fix some of its single-instance assumptions.

 

Another drawback is that when more than one of my mods is installed, the classes in the shared package will be loaded from only one of them. This creates a synchronization hazard for users who download my mods at different times.

 

If those mods are out of sync (built on different versions of the shared package), then some really weird run-time errors can crop up, so whenever anything changes in the shared package, I must remember to rebuild all of my mods and increment an intermediate version number.

 

I now keep one level of my dot-versioning in sync across all of my mods to denote which version of the shared package is in them (thus I can easily see a mismatch in any crash report with multiple mods loaded). When running my mods, I (and my friends) must make sure that they're all from the same generation.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted
I now keep one level of my dot-versioning in sync across all of my mods to denote which version of the shared package is in them (thus I can easily see a mismatch in any crash report with multiple mods loaded). When running my mods, I (and my friends) must make sure that they're all from the same generation.

 

Exactly what I (tried) to do.  Ended up realizing I'd done it in a way that didn't do what I'd been trying to accomplish.  Ended up with a scenario where I had to increment the number that was the "Library" version number despite the library not having actually changed.

 

The 1.10 version numbers will fix that.  The major-est number will be explicit the Library version, rather than just a major revision.

 

Trying to split a project into multiple jars would just be annoying to setup. And annoying for the end user.

 

Except that the reason I'm doing it is because my users explicitly requested it.  They wanted a single feature I had in a mod as its own mod, without all the other things the main mod did.

 

I did split it off as a standalone feature, but the two mods were effective "mutually exclusive" with each other (although checks were made to insure that singleton static references behaved nicely).  So in the 1.10 rebuild, they're properly separate, and the main mod instead depends on the single-feature mod.

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

Or, you could just add a config option to disable the features they dont wont.

But this isn't what you asked, you asked to make a LIBRARY a library is not end user facing content, that is a mod.

Say you wrote a utility that made interacting with a text file easier for you. That's great, use it in all the mods you want. But to the end user your mod should still just be one file.

Having to download 5 different 'libraries' to install one mod is really annoying.

 

This is where shading/fatjaring comes in. You can build that library internally. You could develop with those 5 libraries and when you build you jar have gradle pack them all together and change their package to 'my.special.mods.libraries.{original package}' and those classes would exist and work and you wouldn't have to worry about two mods having two different versions of the library because each mod would have its own copy and use its own copy.

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

Posted

I've never had anyone complain, but I recognize your point as valid.

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

Then you haven't been paying attention, 1/2 the tech support issues that aren't mc version mismatches are missing library/dep issues.

Not to mention the cluster that is IRC/Forums.

There is no reason for a modder to make it hard on the end user. It's super simple to do.

https://github.com/johnrengelman/shadow

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

Posted

but I recognize your point as valid.

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.

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

    • https://forums.minecraftforge.net/topic/157393-1201-forge-rocket-flame-particle-trail-moves-up-and-crashes-into-the-rocket-during-flight/#comment-584134
    • https://mclo.gs/bjf9fqs The link is the logs from modrinth  
    • "I want to understand how complex mods with ASM transformation and coremods work, such as Xray or AntiXray. Why do they break when you simply rename packages? What features of their architecture make refactoring difficult? And what techniques are used to protect these mods? I am interested in technical aspects in order to better understand the bytecode and Forge loader system."
    • I can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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