javagradleminecraftminecraft-forge

NeoForge: Mod's item models are not found


I have a mod for NeoForge version 21.4.38-beta which has some items:

public static final class _Items {

        private _Items() {
            throw new AssertionError();
        }

        private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems("utilz");

        /// The "*target stick*" item.
        /// @see TargetStickItem
        public static final DeferredItem<TargetStickItem> TARGET_STICK = ITEMS.registerItem("target_stick", TargetStickItem::new,
                new Item.Properties().rarity(Rarity.EPIC).stacksTo(1));

        /// The "*target-clear stick*" item.
        /// @see TargetClearStickItem
        public static final DeferredItem<TargetClearStickItem> TARGET_CLEAR_STICK = ITEMS.registerItem("target_clear_stick",
                TargetClearStickItem::new, new Item.Properties().rarity(Rarity.EPIC).stacksTo(1));

        static void register(IEventBus bus) {
            ITEMS.register(bus);
        }
    }

These items have the following models (in <project_root>/src/main/resources):

.
└── assets
    └── utilz
        └── models
            └── item
                ├── target_clear_stick.json
                └── target_stick.json

but for some reason Minecraft detects neither of them. Console logs this:

[17:32:51] [Render thread/WARN] [minecraft/ModelManager]: No model loaded for default item ID utilz:target_stick of utilz:target_stick
[17:32:51] [Render thread/WARN] [minecraft/ModelManager]: No model loaded for default item ID utilz:target_clear_stick of utilz:target_clear_stick

Do you have any idea why this happens? I'm totally certain that I named the files correctly and put them in the needed location, I just don't understand what's wrong ):

I've already tried registering the models when the event net.neoforged.neoforge.client.event.ModelEvent.RegisterAdditional is fired, but nothing has changed, still 'missing-texture' model is used for both items


Solution

  • OK I already found the solution.

    Since NeoForge 21.4.x items' models are searched in directory /assets/<mod_id>/items. So, I had to create two files in this directory for my two items respectively like this:

    .
    └── assets
        └── utilz
            └── items
                ├── target_clear_stick.json
                └── target_stick.json
    

    and reference the actual models from them.

    target_stick.json:

    {
      "model": {
        "type": "minecraft:model",
        "model": "utilz:item/target_stick"
      }
    }
    

    target_clear_stick.json:

    {
      "model": {
        "type": "minecraft:model",
        "model": "utilz:item/target_clear_stick"
      }
    }