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

I have items.json file where are storing data about different itemstack (name, metadata, amount, enchants and nbt)

 

All works nice, but nbt format is not correct:

example: items.json

"name": "groupofitems",
	"items": [{
		"item": "IC2:itemToolChainsaw",
		"metadata": 27,
		"amount": 1,
		"enchantments": {},
		"nbt": {
			"charge": 30000.0d
		}
	}]
//next groups and items....

and result is - {"charge":"30000.0d",} - this is wrong and not working, it have to be {charge:30000.0d}

 

How to solve this problem?

Edited by RealNight

  • Author
On 16.11.2017 at 0:42 AM, diesieben07 said:

Please show the source of NBTSerializer.

 

Edited by RealNight

  • Author
11 minutes ago, diesieben07 said:

And how do you serialize the JSON again? You must have an NBTSerializer then, too, right?

No,

new NBTDeserializer()

is the name of the class file where it adapts minecraft NBTBase file (it is option for gson building like a string)

example: nbt:{"charge":"30000.0d"} (that is without adapting) , with adapting - nbt: {"charge":"30000.0d",} (comma is added in the end)

 

After that i apply settings that i made for gson for taking data from file.json and place data in the ItemConfig class

 

Edited by RealNight

  • Author
On 16.11.2017 at 1:06 AM, diesieben07 said:

No. NBTDeserializer is a json deserializer. It takes in JSON and produces an NBTBase instance. 

 

maybe you meant NBTDeserializer that implements json deserializer<ObjectName> (in our case NBTBase). In this class it turn to string everything that is found under nbt:{ }

Edited by RealNight

  • Author
1 minute ago, diesieben07 said:

Everything you are talking about until now is about taking JSON and turning it into java objects (NBTBase).

But your issue (as I understand it, please correct me if I am wrong) lies with the opposite direction, going from the Java objects (NBTBase, etc.) to JSON.

Sorry, however i am really stupid...

return (json != null) ? JsonToNBT.func_150315_a(json.toString().replaceAll("\"", "")) : null; and it works, wasted so many time   :S and yours...

 

 

  • Author
4 minutes ago, diesieben07 said:

No, this is terrible and will break.

Your JSON should not contain these quotes.

I read that it is rule of form of json & gson

Edited by RealNight

  • Author
12 minutes ago, diesieben07 said:

What? Please, for once, clarify what you are actually talking about.

You keep saying things get replaced. Where exactly? When?

if we do in json file - charge: 30000.0d instead of "charge": "30000.0d" it means that we are trying to ask json library to generate invalid json. In gson part corrects this mistake and add quotes.

 

About a replaceall func: that is not the final version, i know that string can contain tree of nbt, so i need to check and figure all of them. Now, for 1 lvl tree of nbt it is more than enough.

Edited by RealNight

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.