[SPIGOT-7993] CustomItemModel assignment using Component doesn't work. Created: 12/Jan/25  Updated: 13/Jan/25  Resolved: 13/Jan/25

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: daruma_256 Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: 1.21.4, bug

Attachments: File CustomModel-0.0.1-alpha.jar    
Version: This server is running CraftBukkit version 4419-Spigot-aa7842e-df01cf8 (MC: 1.21.4) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

※Translated by DeepL

Required information as noted in the How to Make a Bug Report.
1:Make sure that you are up to date. 

→Probably. Attached are the results using /version
2:Be concise in describing the issue. 
→The assignment of CustomItemModel to ItemStack using the new “Component” feature in 1.21.4 is not working and I believe that craftbukkit is responsible.
3:Test your issue in all applicable versions.
→This feature was added in 1.21.4.
4:For API bugs, include a minimal reproduction plugin. 
→Attach jar and github link

↓Here is what I would like to do using the command

/give @p minecraft:stick[minecraft:custom_model_data={strings:["test"]}] 

I believe the code using Spigot would look something like this.
(I believe the same problem would occur in the case of incorrect implementation.)

ItemStack itemStack = new ItemStack(Material.STICK);

ItemMeta itemMeta = itemStack.getItemMeta();

CustomModelDataComponent component = itemMeta.getCustomModelDataComponent();

ArrayList<String> list = new ArrayList<>();
list.add("test");

component.setStrings(list);

itemMeta.setCustomModelDataComponent(component);

itemStack.setItemMeta(itemMeta); 

However, if you run this and check with the data command, etc., you will see the following.

(Omit unnecessary parts)

Item: {components: {"minecraft:custom_model_data": {}}, count: 1, id: "minecraft:stick"},

 

note: What you get with the first command listed is as follows

Item: {components: {"minecraft:custom_model_data": {strings: ["test"]}}, count: 1, id: "minecraft:stick"},

 

 

I think the cause is that setString() etc. do not use input values in CraftCustomModelDataComponent.

Excerpts from this only where necessary

 

org.bukkit.craftbukkit.v1_21_R3.inventory.components.CraftCustomModelDataComponent

 

public final class CraftCustomModelDataComponent implements CustomModelDataComponent {

    private CustomModelData handle;

    @Override
    public void setFloats(List<Float> floats) {
        handle = new CustomModelData(new ArrayList<>(floats), handle.flags(), handle.strings(), handle.colors());
    }

    @Override
    public void setFlags(List<Boolean> flags) {
        handle = new CustomModelData(handle.floats(), new ArrayList<>(handle.flags()), handle.strings(), handle.colors());
    }

    @Override
    public void setStrings(List<String> strings) {
        handle = new CustomModelData(handle.floats(), handle.flags(), new ArrayList<>(handle.strings()), handle.colors());
    }

    @Override
    public void setColors(List<Color> colors) {
        handle = new CustomModelData(handle.floats(), handle.flags(), handle.strings(), new ArrayList<>(handle.colors()));
    }

 

In all .set***(), the input value is not used and the current value appears to be re-generated.

Thanks for reading this far. If there is any missing information, I will address it.



 Comments   
Comment by daruma_256 [ 13/Jan/25 ]

It now works correctly. Thanks.

Comment by md_5 [ 13/Jan/25 ]

Thanks for the helpful explanation. This should hopefully be fixed now.

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/03a8c14939b8c8fde101d02c98afeb2f02675b0e

Generated at Sat Dec 13 15:46:45 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.