Jump to content

Recommended Posts

Posted

Hello,

I am working on a couple mods; a block library and item library. I would like the block library to be able to reference the item library for loot tables and what not. Unfortunately, I have no idea how to do this. There is no tutorial(that I can find) and the documentation is not much help as I am new to modding and cannot quite make sense of it. I know you have to declare it as a dependency in the gradel to get it to paste it in the dev environment, as well as the .toml file, but I am uncertain as to how to go about this, much less the correct syntax. Here are the links to the mods on github:

Block Library: https://github.com/skiprocks999/Amulets-of-Infinity/tree/Block-Library

Item Library: https://github.com/skiprocks999/Amulets-of-Infinity/tree/Item-Library

 

Any and all help on how to do this will be appreciated.

 

Thanks in advance!

 

PS: I am new to modding, so if you could be as specific as possible and as clear as possible, I would really appreciate it!

 

Posted (edited)

So if I understand correctly, your question has two parts, 1) how to reference another library (block reference items) and 2) reference loot tables from another mod.

 

For the first part, I assume you correctly added it as a dependency to the mods.toml file so that it errors when it doesn't find the required mod. However, there still the problem of referencing the other mod in code and building it. There are a number of ways to do this and they all revolve around using the build.gradle file. After messing around with this myself for a while, I understand what a pain this could be and it took hours for me to figure out my setup, but I digress.

 

Once you define in your build.gradle where it can find your library and refresh the gradle it will automatically add it to the external references which will let you reference it in code. There are a number of ways to define it in a gradle and supposedly (according the the build.gradle) there is supposed to be a built in way by putting in in the "libs" folder, but I've had no success trying that method. The next best thing going down that path (the libs folder) is to add "compile fileTree(dir: './libs', include: '*.jar')" or "compile files("./libs/name-of-jar-here.jar")" in the dependencies section of the build.gradle. Though this wasn't sufficient for my needs, but I again digress.

 

For the second part, I'm not quite sure what you mean by referencing a loot table. If you mean referencing by reading the json file, then you'd need to use the resource manager and get the file as a stream using the resource location. If you mean overriding a loot table, then you'd need to create a loot table override, but I believe there should be tutorials about that already and a good reference here: https://minecraft.gamepedia.com/Loot_table#Data_packs

 

Don't worry about it too much if you don't quite understand what I'm saying. As I see it, it isn't technically modding but using an external tool (gradle). You say you are new to modding so I'd suggest trying to first learn and practice making mods that are independent.

Edited by ZDoctor
Posted

 

6 hours ago, ZDoctor said:

For the second part, I'm not quite sure what you mean by referencing a loot table.

 

To clarify, I meant that as an example of what I was trying to do.

 

I did try adding it as a dependency in the .toml file which I'm fairly certain I did correctly. The problem I ran into was in the gradel, which kept crashing the game on launch. As such I had to remove the lines from the toml and the gradel, as I needed to continue working on the mod. Here is what I used in my attempt:

 

.toml:

 [[dependencies.continfblocklib]]
    modId="continfitemlib"
    mandatory=true
    versionRange="any"
    ordering="NONE"
    side="BOTH"

(I really dont have a version for it yet, so I just have it listed as any for now)

 

I don't know what the correct gradel syntax is though. As I haven't published the item library as a mod yet, I don't know what to put for the path under the dependencies section in the gradel. I know I need to list it as compile, but that's about all I can figure out. The project for the item lib is in the same folder as the block lib, but they are separate project files. for example, would I do this:

 

compile 'filepath:modid'

 

If not, then what would be the correct way to do it?

Posted (edited)
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.continfblocklib]] #optional
    # the modid of the dependency
    modId="forge" #mandatory
    # Does this dependency have to exist - if not, ordering below must be specified
    mandatory=true #mandatory
    # The version range of the dependency
    versionRange="[31,)" #mandatory
    # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
    ordering="NONE"
    # Side this dependency is applied on - BOTH, CLIENT or SERVER
    side="BOTH"
# Here's another dependency
[[dependencies.continfblocklib]]
    modId="minecraft"
    mandatory=true
    versionRange="[1.15.2]"
    ordering="NONE"
    side="BOTH"
 
 [[dependencies.continfblocklib]]
    modId="continfitemlib"
    mandatory=true
    versionRange="any"
    ordering="AFTER"
    side="BOTH"

This is your code from you item-library mods.toml.

 

Now please explain to me why you have 3 "[[dependencies.continfblocklib]]" and not only that, each has a different modid with the other two being "forge" and "minecraft" not to mention they have versions. Also if it crashing then it's best to figure out why, because that means you usually did something wrong. Before you even touch the gradle (because technically you shouldn't really need to) you should first get your mods able to be run.

Edited by ZDoctor
Posted
3 hours ago, ZDoctor said:

Now please explain to me why you have 3 "[[dependencies.continfblocklib]]"

So that was there from the example .toml file. The tutorial I watched didn't delete them (or at least I don't remember them doing so), so I didn't either. If I don't need them, I can remove them.

 

As for the crashing, it only crashed when I tried to add the dependency line to the gradle (which I removed to continue developing the mod). I figured out how to add the item library reference manually to the external library references without the gradle, but there are problems with this long-term. If I update or modify the itemlib, then I have to build a new .jar for it, and then delete the old reference in the blocklib. Then I have to change the path reference to the new .jar in the blocklib. I know there is a line you can add to the gradle to have it update the reference automatically for you, but I cannot figure out what that line is. This is the initial question I had. I apologize if I didn't explain that very well.

 

If the way I am doing it now to add the itemlib as a reference is the only way to do it, then that's fine(I guess I answered my own question). If not, then what line would I add to the gradle to have it add the reference for me? I have looked at the examples it lists, but they aren't very helpful.

 

 

 

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.