Jump to content

Binding Item to custom Model <Minecraft 1.19.2>


Sq3xd

Recommended Posts

I created an SOUL_JAR Item that has been registered for each mob like - mod:soul_jar_minecraft_cow etc.. but it all has different registry names, i have a model file name soul_jar.json

and i want to know how to bind each of those items to this class (When mod iterates through all of vanilla mobs and registering items for them).

 

I didn't found any info about it because all of info is outdated, and forge docs is complicated asf (i wish there would be more examples) i also used AI but it showing me only outdated info, but theres some code where i registering my item and trying to bind it to model ->
 

public static void register(IEventBus eventBus){
        ITEMS.register(eventBus);

        Set<ResourceLocation> entityKeyList = ForgeRegistries.ENTITY_TYPES.getKeys();

        for (ResourceLocation k : entityKeyList) {
            EntityType<?> entityType = ForgeRegistries.ENTITY_TYPES.getValue(k);
            if (!entityType.getCategory().equals(MobCategory.MISC)) {
                RegistryObject<Item> SOUL_JAR = ITEMS.register("soul_jar" + '_' + k.toString().replace(':', '_').replace('.', '_'), () ->
                        new JarItem(new Item.Properties().rarity(Rarity.RARE).tab(ModTabs.MAGICAL_OBSESSION_JARS), entityType));

                if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.CLIENT) {
                    ItemModelShaper itemModelShaper = Minecraft.getInstance().getItemRenderer().getItemModelShaper();
                    itemModelShaper.register(SOUL_JAR.get().asItem(), new ModelResourceLocation("item.soul_jar", "inventory"));
                }
            }
        }
    }

I also have more questions like how to iterate through all other mods mobs also, or render mob inside of a jar in inventory, but i will try to figure it out.

Link to comment
Share on other sites

1 hour ago, Sq3xd said:

I created an SOUL_JAR Item that has been registered for each mob like - mod:soul_jar_minecraft_cow etc.. but it all has different registry names, i have a model file name soul_jar.json

and i want to know how to bind each of those items to this class (When mod iterates through all of vanilla mobs and registering items for them).

 

I didn't found any info about it because all of info is outdated, and forge docs is complicated asf (i wish there would be more examples) i also used AI but it showing me only outdated info, but theres some code where i registering my item and trying to bind it to model ->
 

public static void register(IEventBus eventBus){
        ITEMS.register(eventBus);

        Set<ResourceLocation> entityKeyList = ForgeRegistries.ENTITY_TYPES.getKeys();

        for (ResourceLocation k : entityKeyList) {
            EntityType<?> entityType = ForgeRegistries.ENTITY_TYPES.getValue(k);
            if (!entityType.getCategory().equals(MobCategory.MISC)) {
                RegistryObject<Item> SOUL_JAR = ITEMS.register("soul_jar" + '_' + k.toString().replace(':', '_').replace('.', '_'), () ->
                        new JarItem(new Item.Properties().rarity(Rarity.RARE).tab(ModTabs.MAGICAL_OBSESSION_JARS), entityType));

                if (Thread.currentThread().getThreadGroup() == SidedThreadGroups.CLIENT) {
                    ItemModelShaper itemModelShaper = Minecraft.getInstance().getItemRenderer().getItemModelShaper();
                    itemModelShaper.register(SOUL_JAR.get().asItem(), new ModelResourceLocation("item.soul_jar", "inventory"));
                }
            }
        }
    }

I also have more questions like how to iterate through all other mods mobs also, or render mob inside of a jar in inventory, but i will try to figure it out.

I've got no solution for this particular way. But may I suggest? You can create one singular item and store the entity's data using NBT or Capability.

It will make things easier and cleaner.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.