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 @s SelectedItem.components."minecraft:custom_name" 1 -1

The following actually gets the name out that was stored:

/data get storage custom_roleplay_data: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.

  • @PlagiatusM
    link
    English
    1
    edit-2
    9 days ago

    Have you tried using misode’s generator? It helps me when I’m stuck with some syntax (link is to what I think might be the solution to your problem Edit: nvm it was still set to 1.21.1, can’t seem to recreate that in 1.21.4. it seems to only accept hard coded values).


    I had a similar situation when updating a map with lots of custom model data based models to the latest version. It also used nbt modifications (though through the data command, not an item modifier) to set different custom model data values.

    Before you change everything to strings, consider this: the integers from before still work with some basic changes to the RP and the item commands, because you can just keep the numbers but pretend they’re floats now.

    In commands custom_model_data=7 becomes custom_model_data={floats: [7]} and in the RP

        "overrides": [
            {"predicate": {"custom_model_data":1}, "model": "tr:item/lobby/logo"}
    

    becomes

            "entries": [
                {
                    "model": {
                        "type": "minecraft:model",
                        "model": "tr:item/lobby/logo"
                    },
                    "threshold": 1
                },
    

    (It’s in a different file+folder now, too, just fyi, that’s something I was stuck on for a while).

    As for the actual item command I’d need to try that out since I’m on my phone and usually use item modifier files instead of the inline option.

    But here too, misode’s generator to the rescue (Edit: updated link for 1.21.4 version, this seems to be possible): https://misode.github.io/item-modifier/?share=bdoOctMsPQ

    • surfrock66OP
      link
      English
      19 days ago

      Interesting; ultimately, I DO want to support strings instead of floats because I think it’s a better user experience even if you have to rework the pack (/trigger custommodelname easter_egg vs. /trigger customroleplaydata 123) but when I used misode and set it to string over float, I can’t seem to get it to invoke storage the same way it invokes it in float.

      To that end though, I tried to reference the string with a version of the command modified in the way the structure presents there, but again, “not a string”:

      /item modify entity @s weapon.mainhand {"function":"minecraft:set_custom_model_data","strings":{"values":[{"type":"minecraft:storage","storage":"custom_roleplay_data:data","path":"model_name"}], "mode": "replace_all"}}

      • @PlagiatusM
        link
        English
        1
        edit-2
        9 days ago

        /trigger custommodelname easter_egg

        except triggers only take numbers, not strings, unfortunately. So you’ll have to find a different way to input the strings, but I guess you’re already doing it through the custom names. I agree though, it would be the better user experience if you got it to work.

        I just checked, seems that you can’t set item_model through a storage either, so it’s probably a mc limitation that only numbers can be taken from the storage in item modifiers.

        Another alternative would be to modify the item data directly, but for that it needs to be outside of the players inventory.

        • surfrock66OP
          link
          English
          17 days ago

          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.

          • @PlagiatusM
            link
            English
            26 days ago

            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.