1. Xizz3l

    Xizz3l New Member

    Hi, I am completely new to this. I am playing with the new Skyblock api.
    I am trying to decode the item_bytes from the auctions. I know it's a base 64 gzip nbt data.
    Is there any lib or code that I can use to decode it.

    I found a way to decode the base 64 but don't know what to do next.
  2. You can use the built in java classes (assuming you use at least java 8 i believe) java.util.Base64 (to decode from base64) and java.util.zip.GZIPInputStream

    Here's a code snippet that you can use to return the data unzipped, as a string:

    import java.io.*;
    import java.util.Base64;
    import java.util.zip.GZIPInputStream;
    public void jsonCode() throws IOException {
        String jsonFormatOutput = decompressGzip(decodeBase64String(inputString));
    public byte[] decodeBase64String(String string){
        return Base64.getDecoder().decode(string);
    public String decompressGzip(byte[] compressed) throws IOException {
        final int BUFFER_SIZE = 32;
        ByteArrayInputStream byteArrayStream = new ByteArrayInputStream(compressed);
        GZIPInputStream gzipStream = new GZIPInputStream(byteArrayStream, BUFFER_SIZE);
        StringBuilder string = new StringBuilder();
        byte[] data = new byte[BUFFER_SIZE];
        int bytesRead;
        while ((bytesRead = gzipStream.read(data)) != -1) {
            string.append(new String(data, 0, bytesRead));
        return string.toString();
    from there, on there's a lot of libraries you can use to parse the NBT data and manipulate however you see fit
  3. Xizz3l

    Xizz3l New Member


    Ty for the extremely quick response. I used the java example code from GitHub in combination with my api key to get some example string of an item_bytes:

    When I set this as inputString I get the following result:

    " i
    [email protected]
    tag ench HideFlags�
    display Lor§a§lUNCOMMOName§aEnchanted Cobblestone

    Did I something wrong? I copied the code and changed nothing. For example the count of the item would be interesting, but it doesn't show that information. After that I tested 2 more and got the same result.
  4. You did not do anything wrong, but the way i gave it to you was in string format. The actual file would be in NBT format, where stuff doesnt always translate to a string correctly. To properly read it, you would need some NBT library.

    I've looked into this for you, and using the link i previously sent, found this java library: https://github.com/MrYurihi/TBNBT

    It actually does all the gzip decoding for you already, so my previous code renders largely unnecessary when using this library.

    I've provided a small piece of example code with this library, as to how you would read the NBT data. Most of this would be for you figuring out what data is included, and finding the correct types/names etc. You can do this in the debugger with decent ease

    public void createNBTfromString() throws IOException {
        ByteArrayInputStream inputStream = new ByteArrayInputStream(decodeBase64String(inputString));
        NBTInputStream stream = new NBTInputStream(inputStream, true);
        NBTTagList tagList = stream.readTag().getAsTagCompound().get("i").getAsTagList();
        for(NBTTag t: tagList){
            NBTTagCompound compound = t.getAsTagCompound();
            short itemID = compound.get("id").getAsTagShort().getValue();
            byte count = compound.get("Count").getAsTagByte().getValue();
            NBTTagCompound details = compound.get("tag").getAsTagCompound();
            short damage = compound.get("Damage").getAsTagShort().getValue();
            //do whatever you want with these values
    The library i used does the gzip decoding for you, so the only thing you have to do is decode from base64 first.
  5. #5
  6. Xizz3l

    Xizz3l New Member

    Where can I find it or extract it from?
  7. Its part of the MC source code...
    You can import it when developing with forge/MCP.

Share This Page