Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6986

Applying CustomModelData is different based on the item being applied to

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Minor Minor
    • None
    • None
    • Java 17

      Windows 11

    • [16:43:33] [Server thread/INFO]: This server is running CraftBukkit version 3470-Spigot-ffceeae-1092219 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT)
    • Yes

      When using CraftItemStack.asBukkitCopy(), the output seems to differ based on the item and how it's utilized in-game.

       

      For example:

      If I have some SHEARS and I want to apply CustomModelData to it using NMS, since the SHEARS already have attributes, it will already have an NBTTag, so applying the CustomModelData will work just fine.

      Shears:

      Line 1: The NBT tag for the item

      Line2: The result of it after running CraftItemStack.asBukkitCopy() on it.

      [16:28:51] [Craft Scheduler Thread - 3/INFO]: Tag: {Count:1b,CustomModelData:5,Damage:0,id:"minecraft:shears",tag:{Count:1b,CustomModelData:5,Damage:0,id:"minecraft:shears"}}
      
      [16:28:51] [Craft Scheduler Thread - 3/INFO]: ItemStack{SHEARS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, custom-model-data=5, internal=H4sIAAAAAAAA/4XKQQqAIBAF0G9ihJs6T1vddoghJxNSQcf7B12gt34WWDClgC2nwmejS/Z+M7WuYFwdRZSFFop/S2N1o0vNRw38eBICYDRmT5ki4/MCOqqRKG4AAAA=}} 

      Stick:

      Line 1: The NBT tag for the item

      Line2: The result of it after running CraftItemStack.asBukkitCopy() on it.

      [16:28:51] [Craft Scheduler Thread - 3/INFO]: Tag: {Count:1b,CustomModelData:5,id:"minecraft:stick"}
      
      [16:28:51] [Craft Scheduler Thread - 3/INFO]: ItemStack{STICK x 1} 

      As you can see here, the shears worked fine applying the extra NBT information to it because it already existed. When it comes to the stick, because that stick did not already have an NBT tag on it, when you create a new tag and apply it to the ItemStack and then run CraftItemStack.asBukkitCopy() on the item, it doesn't apply the standalone tag that was applied to it to add the CustomModelData.

       

      Stick with display name:

      Line 1: The NBT tag for the item

      Line2: The result of it after running CraftItemStack.asBukkitCopy() on it.

      [16:38:07] [Craft Scheduler Thread - 10/INFO]: Tag: {Count:1b,CustomModelData:5,display:{Name:'{"extra":[{"text":"test"}],"text":""}'},id:"minecraft:stick",tag:{Count:1b,CustomModelData:5,display:{Name:'{"extra":[{"text":"test"}],"text":""}'},id:"minecraft:stick"}}
      
      [16:38:07] [Craft Scheduler Thread - 10/INFO]: ItemStack{STICK x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"text":"test"}],"text":""}, custom-model-data=5, internal=H4sIAAAAAAAA/+NiYOBgYMpMYeDPzcxLTS5KTCuxKi7JTM5mZGB1zi/NK2HkYmAuSUwnoIiZgd+5tLgkP9c3PyU1xyWxJJGBgYGVi4E9JbO4ICexkoOBxS8xN5VBtVoptaKkKFHJKrpaqQTIVLICUsUlSrWxOjC+Ui1QLwDxx3sOmAAAAA==}} 

      You can see here that the CustomModelData did properly apply because there was also a display-name component applied to it.

       

      Summary:

      • An item that doesn't have existing attributes is not applying a standalone CustomModelData NBT tag to the item
      • An item that already has existing attributes can apply CustomModelData to it without problems and doesn't require another tag to apply with it (such as display-name)

            Unassigned Unassigned
            Glare Glare M.
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: