BananaPuncher714 / NBTEditor

A single class NBT editor for items, skulls, mobs, and tile entities
MIT License
136 stars 30 forks source link

Durability #23

Open BrianGrug opened 2 years ago

BrianGrug commented 2 years ago

Hi, after adding an NBT tag, the durability of an item won't go down

BananaPuncher714 commented 2 years ago

Do you have an example in code?

BrianGrug commented 2 years ago

Sorry, I thought I added it

   itemEnchants.forEach(enchants -> {
        enchantLores.add(enchants.getEnchantLore() + " " + Utils.getRomanNumber(enchants.getLevel()));
    });

    item = new ItemBuilder(item).lore(enchantLores).build();

    player.getInventory().setItemInMainHand(NBTEditor.set(item, Serialization.serializeObject(itemEnchants), "customenchants"));`
BananaPuncher714 commented 9 months ago

What is the data that you are trying to serialize, and are you sure the item is not unbreakable? I performed a quick test with this code snippet and it does not seem to have affected regular durability usage:

    ItemStack sword = new ItemStack( Material.DIAMOND_SWORD );
    sword = NBTEditor.set( sword, "According to all known laws\n" + 
            "of aviation,\n" + 
            "\n" + 
            "there is no way a bee\n" + 
            "should be able to fly.\n" + 
            "\n" + 
            "Its wings are too small to get\n" + 
            "its fat little body off the ground.\n" + 
            "\n" + 
            "The bee, of course, flies anyway\n" + 
            "\n" + 
            "because bees don't care\n" + 
            "what humans think is impossible.\n" + 
            "\n" + 
            "Yellow, black. Yellow, black.\n" + 
            "Yellow, black. Yellow, black.\n" + 
            "\n" + 
            "  \n" + 
            "Ooh, black and yellow!\n" + 
            "Let's shake it up a little.\n" + 
            "\n" + 
            "  \n" + 
            "Barry! Breakfast is ready!\n" + 
            "\n" + 
            "Ooming!\n" + 
            "\n" + 
            "Hang on a second.\n" + 
            "\n" + 
            "Hello?", "customflavortext" );