Jump to content

[1.16.5] Make Mod Data Editable with Datapack (adding new data type)?


Recommended Posts

Posted (edited)

Hey all,

I'm attempting to figure out how to make some functions of my mod editable via datapacks, in much the same way as recipes, advancements, etc. can be edited.  I'd love to see examples of how others have done this, since I'm struggling to figure out how it's even set up in the first place.  I know Origins makes use of custom datapacks to edit powers, but it runs on Fabric, not Forge, so not as helpful for figuring out how to do it on Forge specifically.

I also need to make sure that datapacks are able to append their data to each existing entry instead of just overwriting it.

If anyone has or knows of examples of this I'd love to see them, I'm having a hard time actually tracking anything down to look at since I end up just getting results for actual datapacks, oops.

Thank you for your time, and have a great day!

 

EDIT: Just to specify, I'm talking about adding new types of data, not just using existing ones.  I know how to add stuff like item tags, recipes, etc.  I want to add a new type of data that can be edited through a datapack in the same sort of way-- like what Origins does to allow for the adding of new powers and such.  I just don't know how to do that in Forge.  Sorry for the initial confusion.

Edited by JayZX535
Clarifying
Posted

Your mod is a data pack. Your data files go in src/main/resources/data/<modID>

https://github.com/Draco18s/ReasonableRealism/tree/1.14.4/src/main/resources/data

Any datapack can place overrides in the same modID directory and Forge will override as expected.

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

Yes, I've worked with the existing types of data such as tags, recipes, etc. before.  What I'm having difficulty with is trying to create a new type of data.  Like what Origins has done to allow the adding/modifying of alternative origins and powers, a feature that is added by the mod itself and not part of Vanilla minecraft like tags, recipes, advancements, etc.  That's where I'm having trouble.

  • JayZX535 changed the title to [1.16.5] Make Mod Data Editable with Datapack (adding new data type)?
Posted

Well, I got it almost figured out.  For some reason it seems to only be loading on the client?  Which is odd, because my research is indicating that the AddReloadListenerEvent is supposed to be serverside?  I'm registering it as the following.  Fairly stumped...

@EventBusSubscriber(modid = Mod.MODID, bus = EventBusSubscriber.Bus.FORGE)
public class ReloadListener {
    @SubscribeEvent
	public static void addReloadListenerEvent(AddReloadListenerEvent event) {
		event.addListener(Mod.getDataThing());
		Mod.getLogger().info("ReloadListener registered.");
	}
}

The only thread that log seems to get called on is the render one.  Running it on a server never outputs that log at all.  I can correctly output the data I'm getting from the json into the logs on the client side, but the server doesn't seem to have access to it.  Is extending JsonReloadListener supposed to be able to work with serverside resources?

Posted

Ohhhh hmmm, that may be what's causing the problem.  I'm trying to use this info in the BiomeLoadingEvent, but it looks like the first time it runs, the data hasn't been updated.  If I reload worlds the data applies properly, but the first time it runs the data hasn't been set yet, so it ignores it and carries on as usual.  I'm guessing that means I have to check and see if the data needs updating at the start of that event, and then make sure I have it update data if it does?  Unless this event just runs before the data is even accessible, in which case what I'm trying to do might just not be possible.  Either that, or I need to reload the biomes themselves once the data is updated, but I'm guessing the prior option may be the better one.

 

How could I go about reloading the resources if I detect they haven't been generated for the BiomeLoadingEvent?  Or is that not going to be a safe thing to do?

Posted

Here it is.

https://github.com/JayZX535/mcbiomespawner

(this is set up to clear all entity spawns in the savanna and replace them with wolves and cats.  whenever it detects a spawn has been modified, it will clear all existing spawns to ensure easy visibility.)

What it's doing that has me stumped is when you first create a world, the spawns aren't modified.  When you quit to menu and reload it, the spawns aren't modified.  But when you relaunch the game entirely and then load the world, then the new spawns take effect.

I'm still new to the way 1.16 works and I haven't worked too much with data until now, so maybe there's something I'm misunderstanding...

Posted (edited)

Argh.  Not used to github, hopefully this version works...

https://github.com/JayZX535/mcbiomespawner

 

Also, it definitely seems to me that the issue is that the datapack loads after the event runs.  I ran a dedicated server and looked at the logs, and I can see my debug statements from the BiomeLoadingEvent running before the ones that get the information from the datapack.  I'm just not certain how to solve that problem, unfortunately...

Edited by JayZX535
Adding info
Posted (edited)

Dang, still didn't upload right.  Sorry :/

Eesh, that's unfortunate.  I'll have to poke around with it some more, but it may just not be doable.  Is there a way to manually trigger the reload event?  The one idea in my head currently is to have a boolean to see if the files have been updated, and if not, manually trigger the reload the first time it tries to run the biome event.  But that sounds like it could be a bit dodgy so I'm not sure if that'd work...

Thank you for your help nonetheless.

Edited by JayZX535

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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