So here’s the problem. The new 1.21.4 custom model format supports names, instead of numerical ID’s. This is objectively better. MukiTanuki’s custom roleplay data cannot support this, as they use the scoreboard to temporarily store the custom model id, and that has to be an integer. Also, in my testing, it fails unless you format your resource pack a specific way as it is pulling in a float, not an int.
I think the better solution now would be to be able to rename an item with the model name, THEN trigger a function to replace the model with the name. So where can we store a string? The actual data storage, which is server-wide, however can hold strings. The problem? The documentation for pulling things out of storage is like non-coming up from my googling.
When you name an item, it is named ‘“Whatever”’ but the double-quotes count. For that reason, the following function (which starts at character 1 instead of 0, and ends 1 from the end due to the -1) stores the item name in a storage namespace:
data modify storage custom_roleplay_data:data model_name set string entity SelectedItem.components."minecraft:custom_name" 1 -1
The following actually gets the name out that was stored:
/
storage custom_roleplay_data: model_name
The issue is, I can’t get the string out. Here’s some things I’ve tried, and all result in basically “not a string”:
/item modify entity @s weapon.mainhand {"function":"minecraft:set_custom_model_data","strings":{"values":[{"type":"minecraft:storage","target":"custom_roleplay_data:data","path":"model_name"}], "mode": "replace_all"}}
/item modify entity @s weapon.mainhand {"function":"minecraft:set_custom_model_data","strings":{"values":[{"type":"minecraft:storage","target":{"target":"custom_roleplay_data:data","path":"model_name"}}], "mode": "replace_all"}}
/item modify entity @s weapon.mainhand {"function":"minecraft:set_custom_model_data","strings":{"values":[{"type":"minecraft:storage","target":{"target":"custom_roleplay_data:data"},"path":"model_name"}], "mode": "replace_all"}}
/item modify entity @s weapon.mainhand {"function":"minecraft:set_custom_model_data","strings":{"values":[{"type":"minecraft:storage","target":{"custom_roleplay_data:data":"model_name"}}], "mode": "replace_all"}}
I’m stuck, and would appreciate any ideas.
I’m not sure, I’m gonna play with it. For sure renaming the item and getting that name into the storage works, the question is then just how to get that string into the item command. I would see this as a supplement to the existing CRD function, so the old method (with the float stuff) still working, but if we’re remaking our resource packs anyway to support the float thing, MAN names would be better. As is, the /item command with the string directly works right now. I just need to extract the string from the storage.
I got a suggestion to use a function macro; I’m not familiar with how that works so I’m gonna research.
Oh yeah of course, that’s an option too. One that’ll solve the issue instantly, actually. I keep forgetting that you can put macros into literally anything.