Skip to content

[Bug]: Components not serializing/deserializing correctly #2748

Open
@Jazzkuh

Description

@Jazzkuh

Affected Version

1.21.5 - d243be6

Describe the bug

Hi, does anyone know why ItemStack.fromItemNBT(tag) cuts a CompoundBinaryTag that has a lot of components like:

{count:1,components:{"minecraft:item_model":"food:fruit_banana","minecraft:lore":[{color:"white",italic:0b,text:"쀁"},{:""},{text:"Nutri Score: ",color:"gray",italic:0b,extra:[{color:"white",text:"퀁"}]},{color:"gray",italic:0b,text:""},{color:"dark_gray",italic:0b,text:"Categorie: Fruit"}],"minecraft:max_stack_size":5,"minecraft:food":{saturation:0.3f,nutrition:2},"minecraft:tooltip_display":{hidden_components:["minecraft:base_color","minecraft:dyed_color","minecraft:attribute_modifiers","minecraft:unbreakable","minecraft:enchantments"]},"minecraft:custom_name":{color:"#626262",italic:0b,text:"Banaan"},"minecraft:custom_data":{nutri_score:"A",item_key:"banana"},"minecraft:tooltip_style":"mineville:common"},id:"minecraft:apple"}

to an item like this:

ItemStackImpl[material=minecraft:apple, amount=1, components=DataComponentMapImpl[components={}]]

I am using this code to deserialize an item:

    public static ItemStack deserialize(String rawData) {
        try {
            CompoundBinaryTag tag = TAG_IO.asCompound(rawData);
            System.out.println(rawData);
            System.out.println(ItemStack.fromItemNBT(tag));
            return ItemStack.fromItemNBT(tag);
        } catch (IOException e) {
            throw new RuntimeException("Error while deserializing ItemStack", e);
        }
    }

Steps to reproduce the bug

No response

Code sample

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageIssues that are new and need triage

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions