Jump to content

[1.7.10] Commenting on the JSON (for Configuration)


Recommended Posts

Posted

How can I add Comments on the JSON file for specific property?

 

I tried to do it using Gson, but I realized that It uses JsonWriter, which cannot print single sentence for commenting.

& I don't want to add new property for the comment.

 

Actually I have already solved this issue with refletion.. I got the Writer field from the JsonWriter which is private.

Is there any better way which I doesn't know? For I doesn't like using Reflection in this way..

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Comments aren't possible in JSON.  The guy who designed it deliberately removed them to avoid folks misusing them for metadata.  The best you can do is descriptive property names I  think..

 

-TGG

Posted

Gson already suppports some comments(like /*, */, //) and ignore them while reading, so I thought writing comments would also be available.

 

So, is there no other way with Gson or anything?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Yes. I want to use it for my unified config system. (for Stellarium)

Since I'd use it not only for text configuration but also for packets & data saving, I prefer JSON forms.

And I just want to add some comments for text config.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

JSON has nothing to do with packets, and to save data either use a normal config file or save it to NBT.

Yes, I know. But NBT is really bad for configuration, and I saw someone using JSON format to send object using packet.

It seems to be portable enough. (Of course I'd write the JSON in bytestream for sending packets)

 

and I said something wrong, the reason that I selected JSON is for the configuration.

Since my configuration have to be dynamic and hierarchical, I cannot use Forge Configuration.

 

Actually I tried to make my own config type, but I realized that it is hard work and It

And then I found that JSON is well suited for my objective.

 

and about hocon, is it accepted as a default library for Minecraft? If not, I think it would be difficult to use it..

Then I'd end up using my current way.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Send me a pm so that I can give you my custom database program as well add how to use it. I am not ready to release the code to the public yet though I will let you use it for this mod.

No. I think it will be much more complicated to use it.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

If you want nested categories you can use "." to specify them when using the Forge Configuration class.

 

Categories:

String category1 = "topCategory.subCategory1";
String category2  "topCategory.subCategory2";

 

What the Forge config file might look like:

{
"topCategory": {
    "subCategory1": {
        # your options
    },
    "subCategory2": {
        " more options
    }
}
}

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Posted

Again, what is wrong with the forge Configuration class?

What I mean by "dynamic", is that I have to find every existing category, and read information from each.

AFAIK Forge Configuration can be hierarchical, but not dynamic.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Maybe I am only remembering the old version of the Forge Configuration..

Anyway it is not hierarchical (only it can be shown as "hierarchical" using dots)

and it cannot be written on bytestream. (+without comments)

 

So it would take much more effort to change my system to use it.

I'd rather end up using reflection to JsonWriter.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

No, it is actually not 'config'.

In fact, It is partially encoded basic information on planets.

 

On File Configuration part, it is encoded to be more readable.

On Bytestream part (for packet), it is encoded to be compressed.

 

+ It has to be sent by packet, since it will modify the world regardless of client configuration.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Can't you just include a readme file with the explanation on how to write the JSON that is what most people do, sounds to me your over complicating your life here. :P

I require Java, both the coffee and the code :)

Posted

Can't you just include a readme file with the explanation on how to write the JSON that is what most people do, sounds to me your over complicating your life here. :P

No, It would be a LOT harder to read. Then even I would not know what property means what, for it is very complicated config.

I'd need both readme file and comments, and they might not be enough!

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Can't you just include a readme file with the explanation on how to write the JSON that is what most people do, sounds to me your over complicating your life here. :P

No, It would be a LOT harder to read. Then even I would not know what property means what, for it is very complicated config.

I'd need both readme file and comments, and they might not be enough!

 

Use an XMLSerializer then, XML supports comments <!-- -->

I require Java, both the coffee and the code :)

Posted

Does it support bytestream output, too?

 

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Does it support bytestream output, too?

 

Yes you can technically transform anything to bytes, just deserialize it the way you serialized it, the only thing at stake is efficiency.

 

Now the only downside is that I'm not sure XML Serializers support comments when serializing, you'd have to test it out and if not find a LIB that does serialize comments too.

I require Java, both the coffee and the code :)

Posted

And the "Efficiency" is important. + Making XML bytestream writer would just double the effort.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Again: Why do you want to send a config via packets? That seems very strange. It is simple though: Just write whatever config file you chose into a String, like you would when writing to disk. Then send that string.

As I said, it is partially encoded basic information on planets, which can be sent from the Server.

Since server specifies the form of world on client, it has to be sent using packet.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Because I want to make the "configurable" system able to be changed either by GUI or Text.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Since it is deeply related with the world, it has to be sent by packet like world info.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I would just encode the data as a byte stream and send it, the configuration would just be that encoded data. Why would you need to send the config comments with your configuration? Will the clients be able to edit the config? In that case I would provide a nice gui for that.

I require Java, both the coffee and the code :)

Posted

What I meant was: How is the configuration format related to how you send it with a packet?

Because Forge Configuration always contains the comment, so i cant send it using a packet.

And any non built-in config platforms are really not preferable. (I don't want to import any external library)

 

To Belpois: It does not contains comment on packet. Please read the whole thread...

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

"Because Forge Configuration always contains the comment"

- Wrong, it doesn't (unless I misunderstood)

"i cant send it using a packet"

- You can send everything using packets, you are just looking for easy way.

 

Proper way of doing it would be:

1. Config loads

2. Sets some virtual data, example: (doesn't need that if)

if (conf.containsKey("Generics")) MyVirtualStorageClass.setGenerics(conf.get("Generics").getStringList());

3. And at this point you don't give a damn about config no more - everything is virtual.

4. In your packet you simply MyVirtualStorageClass.getGenerics  (which will return some String array) and write all strings to buffer.

5. On receiver side you read it and put in client-side vitrual storage class or actually anny other kind of storage (file cache).

 

I don't see why you want to send whole config so badly, it'd bebetter to send key info when you login on server and then on client use that info to e.g change sky behaviour (color and shit).

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

Posted

Load all categories and send all of them as string? That doesn't make sense..

and Configuration#containsKey(String) or Configuration#get(String) doesn't seem to exist in forge 1.7.10.

 

Plus there was no method for getting Config String from Configuration class. (As it just uses the File class..)

 

I'd just use my current way with Json.

 

 

I think I got every help that I needed. There was no easier way with Json.

So I want to lock this thread.. how I can lock this thread? Or I cannot?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I want to create block with entity, that will have height of 3 or more(configurable) and I tried to change first VoxelShape by increasing collision box on height I want and for changing block height on visual side i tried to configure BlockModelBuilder:  base.element() .from(0, 0, 0) .to(16f, 48f, 16f) .face(Direction.UP).texture("#top").end() .face(Direction.DOWN).texture("#bottom").end() .face(Direction.NORTH).texture("#side").end() .face(Direction.SOUTH).texture("#side").end() .face(Direction.WEST).texture("#side").end() .face(Direction.EAST).texture("#side").end() .end(); but, getting crash with next error: Position y out of range, must be within [-16, 32]. Found: %d [48.0]; Looks like game wont to block height modified by more than 32. Is there any way to fix that problem?
    • As long as the packets you are sending aren't lost, there's nothing wrong with what you're currently doing. Although, this sounds like something that would benefit from you making your own datapack registry instead of trying to arbitrarily sync static maps. Check out `DataPackRegistryEvent.NewRegistry`.
    • Hey all, I've been working a lot with datapacks lately, and I'm wondering what the most efficient way to get said data from server to client is.  I'm currently using packets, but given that a lot of the data I'm storing involves maps along the lines of Map<ResourceLocation, CustomDataType>, it can easily start to get messy if I need to transmit a lot of that data all at once. Recently I started looking into the ReloadableServerResources class, which is where Minecraft stores its built-ins.  I see you can access it via the server from the server's resources.managers, and it seems like this can be done even from the client to appropriately retrieve data from the server, unless I'm misunderstanding.  However, from what I can tell, this only works via built-in methods such as getRecipeManager() or getLootTables(), etc.  These are all SimpleJsonResourceReloadListeners, just like my datapack entries are, so it seems like it could be possible for me to access my datapack entries similarly?  But I don't see anywhere in ReloadableServerResources that stores loaded modded entries, so either I'm looking in the wrong place or it doesn't seem to be a thing. Are packets really the best way of doing this, or am I missing a method that would let me use ReloadableServerResources or something similar?
    • Hi, everyone! I'm new to minecraft modding stuff and want ask you some questions. 1. I checked forge references and saw there com.mojang and net.minecraft (not net.minecraftforge) and as I understand it's original game packages with all minecraft logic inside including renderers and so on, right? 2. Does it mean that forge has a limited set of instruments which doesn't cover all the aspects of the game? If make my question more specific then does forge provide such instruments that allow me totally change minecraft itself, like base mechanics and etc.? Or I have to use "original game packages" to implement such things? 3. I actively learning basic concepts with forge documentation and tutorials. So in my plans make different inventory system like in diabloids. Is that possible with forge? 4. It is last question related to the second one. So how deeply I can change minecraft with forge? I guess all my questions above because of that I haven't globally understanding what forge is and how it works inside and how it works with minecraft. It would be great if you provide some links or topics about it or explain it by yourself but I guess it's to big to be explained in that post at once. Anyway, thank you all for any help!
    • Im trying add to block a hole in center, just a usual block and in center of it on up side, there is should be a hole. I tried to add it via BlockModelBuilder, but its not working. Problem is that it only can change block size outside. I tried it to do with VoxelShape and its working, but its has been on server side and looks like its just changed collision shape, but for client, there is a texture covering this hole. I tried to use: base.renderType("cutout"); and removed some pixels from texture. I thought its should work, but game optimization makes block inside looks transparent. So, only custom model?
  • Topics

×
×
  • Create New...

Important Information

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