LeaPhant / skyblock-stats

A beautiful SkyBlock profile viewer 🌹
https://sky.lea.moe
MIT License
168 stars 33 forks source link

[Question] Clarification for getItems() method in lib.js #29

Closed PulseBeat02 closed 4 years ago

PulseBeat02 commented 4 years ago

Hi I am working on an API project for education uses and managed to get everything setup. However, I was having trouble trying to decode the items in the player’s inventory, so I referred to sky.lea.moe code to see how they handled the data. I preformed similar operations in Java, by first converting the Base64 String into a byte array, then decompressing that gzip archive. Although the decompression was successful, the output was a weird String with odd binary digits. (Black squares, symbols, etc). However, I noticed that there were still words in the output String such as enchantments, reforges, etc, and one important thing I noticed was a word that said “tag”, which means I am getting closer to NBT. I’m having trouble parsing the data, so could the developers educate me on how they managed to parse this NBT data?

P.S. I’m also wondering about how you managed to link the items to textures as shown here: https://github.com/LeaPhant/skyblock-stats/blob/1ed68f635dc6ef99aad1d435bdf0798467b7b1f9/src/lib.js#L135 I’m a student trying to learn about Base64, JSON, API calls, etc, so I figured that using the Hypixel Public API would be a good option.

Thanks, PulseBeat_02

builder-247 commented 4 years ago

A node library called prismarine-nbt is used for the parsing, you can look at it's source code for more clues.

P.S. I’m also wondering about how you managed to link the items to textures

Player heads have NBT data containing the texture URL. You can also look how we implement the parsing at slothpixel.

LeaPhant commented 4 years ago

I'm closing this, if you have further questions feel free to reopen. :)