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

My mod requires localization based on JSON files. I am going to go about this by having a subfolder under assets/myMod which contains more subfolders named after the languages (IE: en_US), which the contains a load of different json files. The JSON files are loaded whenever the language is changed and stored somewhere, allowing for localization whilst giving me more power to customize the content of what I am loading.

  • Author

Why do you need these JSON files? Why can you not use the normal language system?

 

Its for a sort of book, and the information that it contains is quite complex, with text where some lines can have their own font, it can display images, crafting and furnace recipes in the middle of pages and some lines, paragraphs, images, etc can be disabled/enabled by some arbitrary conditions.

 

This is what a typical file could contain:

 

 

 

{

"title": "This is the title of the page",

"tooltip": "This is viewed when hovering over the title in the selection menu",

"content": [

{

"type": "text",

"text": "This is a text fragment."

},

{

"type": "text",

"text": "This renders in the Standard Galactic Alphabet font.",

"font": "sga"

},

{

"type": "itemname",

"item": "minecraft:pickaxe",

"meta": 0

},

{

"type": "item",

"item": "minecraft:pickaxe",

"meta": 0,

"nbt": {

"display": {

"name": "name"

}

}

},

{

"type": "crafting_table",

"item": "minecraft:pickaxe"

},

{

"type": "furnace",

"name": "minecraft:iron_ingot"

},

{

"type": "image",

"location": "minecraft:textures/environment/end_sky"

}

]

}

 

 

Why not have the content JSON be locale-independent and use translation keys for the text?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

Why not have the content JSON be locale-independent and use translation keys for the text?

 

Because I had not thought of that, of course!

Is there an event which fires when Resource Packs are reloaded for reloading custom content?

 

It's not an event, but you can implement

IResourceManagerReloadListener

and register it by calling

IReloadableResourceManager#registerReloadListener

on the return value of

Minecraft#getResourceManager

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

The

Minecraft#mcResourceManager

field returned by

Minecraft#getResourceManager

is of type

IReloadableResourceManager

, so it's safe to assume that the method will always return an

IReloadableResourceManager

. Forge itself makes this assumption in

ModelLoaderRegistry#registerLoader

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Nitpicky, but this isn't an assumption. The method cannot ever return something else, that's what a return type means.

 

The method's return type is

IResourceManager

, not

IReloadableResourceManager

. It could theoretically return a completely different

IResourceManager

implementation (though it doesn't in practice).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.