-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PET NBT's have extra backslash #13
Comments
Could you post the base64 that created that output? |
I'm not able to reproduce this with Nedit 2.1.1 and the following base64 string:
Code: String inventoryBase64 = "..."; // The base64 from above.
NBTCompound inventory = NBTReader.readBase64(inventoryBase64);
NBTCompound petSlot = inventory.getList("i").getCompound(8);
NBTCompound petTags = petSlot.getCompound("tag");
System.out.println(petTags);
String petInfo = petTags.getString("ExtraAttributes.petInfo", "{}");
System.out.println(petInfo); Output:
The |
I found the problem. I am using: Gson gson = new Gson();
gson.toJson(NBTReader.readBase64(inventoryBase64).getList("i")); GSON version: 2.8.9 |
System.out.println(result.getCompound("tag.ExtraAttributes").get("petInfo"));
System.out.println(result.getCompound("tag.ExtraAttributes").get("petInfo").getClass());
System.out.println(result.getCompound("tag.ExtraAttributes").get("petInfo.exp")); Output:
I cant access to exp. petInfo is not Compound. |
Let's break down what the NBT you're working with actually looks like: i (List) │ └── . (Compound) │ └── tag (Compound) │ └── ExtraAttributes (Compound) │ └── petInfo (String) Notice that Be careful not to confuse NBT with JSON. In text form NBT looks very similar to JSON, but has a few key differences that make it incompatible, including...
|
Yes you are right and thanks but petInfo is more suitable to be compound. I guess in this situation need to get petInfo's with RegEx. I will report this situation to Hypixel. Do you have any advice? |
As much as I agree, I'm afraid it's out of my control. All the library does is interpret what you put into it, strictly following the NBT format. If the NBT you give it says
I don't think that has anything to do with RegEx. My library handles the NBT side of things, and you'll need a separate library to handle that JSON string. RegEx shouldn't be needed at any point unless you're doing something else with it that you haven't mentioned here.
Using JSON in Like I said in my last message, there's a lot of key differences between stringified NBT and JSON which make them incompatible. In your screenshot for example, there's |
PET NBT's have problem. They have extra backslash.
The text was updated successfully, but these errors were encountered: