Jump to content

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


JayZX535

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

    • On the web there are a lot of custom player totem resource-packs available. But they all require a copy of the player-skin-texture renamed as the totem-texture. This requires reinstalling the pack every time, when you change your player-skin. So i think about making a mod to reproduce how player-head-blocks get their texture. How can i do this while using a a custom json item-model, that i created in blockbench, that a player-skin fits on? I taught about having both arm sizes in the model and find a way to detect the model width (3-pix-arms or 4-pix-arms), that the given player uses to hide or shor each arms on the model.   Best regards Maxi
    • There is an issue with backpacked and framework Try other builds of these mods
    • so i don't really know how to fix this if some one know more about this pleas help thanks here's the log side note it doesn't give me a crash report for this.   [21Apr2024 15:46:52.647] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 [21Apr2024 15:46:55.474] [main/INFO] [gg.essential.loader.stage1.EssentialLoaderBase/]: Starting Essential Loader (stage2) version 1.6.0 (8fe36b19522693d84f4de27ad4accf3f) [stable] [21Apr2024 15:46:55.526] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/Massimo/curseforge/minecraft/Install/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2397!/ Service=ModLauncher Env=CLIENT [21Apr2024 15:46:57.087] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Massimo\curseforge\minecraft\Install\libraries\net\minecraftforge\fmlcore\1.19.2-43.3.5\fmlcore-1.19.2-43.3.5.jar is missing mods.toml file [21Apr2024 15:46:57.091] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Massimo\curseforge\minecraft\Install\libraries\net\minecraftforge\javafmllanguage\1.19.2-43.3.5\javafmllanguage-1.19.2-43.3.5.jar is missing mods.toml file [21Apr2024 15:46:57.095] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Massimo\curseforge\minecraft\Install\libraries\net\minecraftforge\lowcodelanguage\1.19.2-43.3.5\lowcodelanguage-1.19.2-43.3.5.jar is missing mods.toml file [21Apr2024 15:46:57.099] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\Massimo\curseforge\minecraft\Install\libraries\net\minecraftforge\mclanguage\1.19.2-43.3.5\mclanguage-1.19.2-43.3.5.jar is missing mods.toml file [21Apr2024 15:46:57.310] [main/WARN] [net.minecraftforge.jarjar.selection.JarSelector/]: Attempted to select two dependency jars from JarJar which have the same identification: Mod File:  and Mod File: . Using Mod File: [21Apr2024 15:46:57.312] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: Found 12 dependencies adding them to mods collection [21Apr2024 15:46:57.398] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Found Kotlin-containing mod Jar[union:/C:/Users/Massimo/curseforge/minecraft/Instances/Five%20Nights%20at%20Freddy's/essential/libraries/forge_1.19.2/kotlin-for-forge-3.6.0-slim.jar%23394!/], checking whether we need to upgrade it.. [21Apr2024 15:46:57.400] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Found outdated Kotlin core libs 0.0.0 (we ship 1.9.10) [21Apr2024 15:46:57.400] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Found outdated Kotlin Coroutines libs 0.0.0 (we ship 1.7.3) [21Apr2024 15:46:57.400] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Found outdated Kotlin Serialization libs 0.0.0 (we ship 1.6.0) [21Apr2024 15:46:57.401] [main/INFO] [gg.essential.loader.stage2.util.KFFMerger/]: Generating jar with updated Kotlin at C:\Users\Massimo\AppData\Local\Temp\kff-updated-kotlin-10778581722359704112-3.6.0-slim.jar  
  • Topics

×
×
  • Create New...

Important Information

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