Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to store a constant integer in a json file under "resources/data/modid", so that it could be manipulated by datapacks. how do I achieve that?

What do you mean by manipulated by datapacks?

 

To answer your question directly: To include any file in your mod, just put it in your src/main/resources

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Why wouldn't you do this with a config option?

Datapacks are normally used to load registries and then let users override the individual entries.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

40 minutes ago, warjort said:

Why wouldn't you do this with a config option?

Datapacks are normally used to load registries and then let users override the individual entries.

A config file is only editable for the user (it's hard to edit the config file of a Mod from another), if a other Mod want to override a value a Datapack would be the best option

And in general Datapacks are underrated, I think they have a lot of potential because of Mojnag's Codecs

1 hour ago, MaiTheLord said:

I want to store a constant integer in a json file under "resources/data/modid", so that it could be manipulated by datapacks. how do I achieve that?

unfortunately i'm not familiar with this json Datapack stuff,
but as far as i know did you need a SimpleJsonResourceReloadListener which you need to register in AddReloadListenerEvent

Edited by Luis_ST

I am just wondering if all the extra effort is appropriate?

 

To do it, you need a PreparableReloadListener implementation. Then you register it using an AddReloadListenerEvent.

 

The listener works in 2 stages

prepare - which is run in parallel with other listeners

apply - where the listeners are done one-by-one but only if all other listeners don't error in the prepare - this is where you modify your state

You can only look at data loaded by other listeners in the apply, and then only if it runs before yours

 

If you look at the vanilla ones, you can find some helpers that do common tasks - these will remove some of the complications.

I don't think you will find one that does exactly what you are doing?

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

I'll try using a config for now. I am not sure if it should be a common or a server config. the value affects entity spawning.

if your value is server side and should be synced to the client you need use a server config (server and client value need to match),

if the server value must not match with the client value you can use a common config

It depends where you need to access the config and who should control it. Usually common is used, even if the client never references it.

https://forge.gemwire.uk/wiki/Configs

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

As it affects entity spawning, I am not sure the user would want the same value in all of their worlds. should I use a server config then?

Could be? If this is the case, it would be another reason not to use datapacks. Only the worldgen is stored per world using the datapack values when you create it.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Quote

As it affects entity spawning, I am not sure the user would want the same value in all of their worlds.

Another option would be a game rule. These are stored per world.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

gamerules sound better actually. I have no idea how to register one though, and I don't really find anything on google regarding that

I have never done this either, but it looks pretty simple.

Look at net.minecraft.world.level.GameRules which has vanilla examples.

You just register() to set the default game rule, which will give you a GameRule.Key

Then use Level.getGameRules().getRule(Key) at runtime.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Or there are helper methods on GamesRules that lets you do getBoolean(Key) instead of getRule(Key).get().

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

vanilla gamerules use GameRules.IntegerValue.create(int value) which is package-private, I'll need to use reflection / AT
 

Edited by MaiTheLord

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.