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

So, I would be doing this?

File json = new File("/assets/MyFile.json");

 

And, that's what I was thinking. I meant as an interface other mods can implement into their items if they so choose. Then, when running through the entire ItemRegistry (which I believe contains every block and item from every mod loaded?) if said item implements my IWeightedItem, add the weight. If it doesn't, add the item to the json, and give it a weight of 0.0F. I am also guessing I would have to run the json creator in post, so all mod items are loaded, and I don't miss any. :P

No. File must be located in config directory with other configs.

So

config/MyFile.json

. And better would be grabbing

modConfigurationDir()

from pre init.

  • Author

Hm, alright. I'm not really sure why considering it doesn't correspond with configs though (as in, I am not using the Minecraft config manager). One last question, is it safe to create the json in post? Or, will that cause problems?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

  • Author

Alright, I tried this to test it:

File jsonFile = new File("/assets/utils/WeightLimit.json");
	JsonReader reader = new JsonReader(jsonFile);

 

And, it says "jsonFile is undefined, change type to Reader?" which I am not seeming to understand. I know it can't take File, but is it suppose to?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Not to be rude, but have you considered actually learning how to use JSON? Any basic tutorial will give you proper introduction and rest can be easily found in docs or receive better help on StackOverflow. I am not saying anything bad but really - learn and understand is much better than "do this, do that". Might even come in handy if you'd ever expand outside MC.

 

Please look into docs. As to current problem, you might want to use factory methods or actual Reader.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Not rude at all, I completely understand where you're coming from. Could you point me to some docs or tutorials? The ones I found seemed to be outdated, I mean, they never even mentioned a JsonReader.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

So it expects a Reader, but you have a File. Maybe there exist something like

FileReader

(hint: it does...)? Try looking a bit better in the future.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Hm, alright. I'm not really sure why considering it doesn't correspond with configs though (as in, I am not using the Minecraft config manager).

 

The config folder is a Forge thing not a vanilla thing. And just because you're using json not .config doesn't mean it isn't a config file. Add to that the fact that the /assets directory doesn't exist when you distribute your mod.

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.

Also, just to note,

.json

extension is not compulsory for gson to read. Internal structure is important.

But using

.json

extension just makes users not that confused.

 

As to code that i posted, it was pseudo code, to help you figure basics and how to encode maps (it's not always needed to use type tokens with gson).

 

Also, as everybody said, now that you know what to use, learn how to use it.

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.