Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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/

Posted

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.

Posted

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

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

×
×
  • Create New...

Important Information

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