Jump to content

[1.9] Language-determined JSON


Notunknown

Recommended Posts

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.

Link to comment
Share on other sites

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"

}

]

}

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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



×
×
  • Create New...

Important Information

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