Jump to content

[SOLVED] ItemModelProperties override not working when iterating


Recommended Posts

Posted (edited)

I have this piece of code that gets called with DefferedWorkQue.runLater and it works without issue

        ItemModelsProperties.func_239418_a_(ModItems.FLINTLOCK_MUSKET.get(), new ResourceLocation(MatchlockGuns.modID, "is_loading"),
                (stack, world, entity) -> {

                    if(stack.getTag().getBoolean("is_loading"))
                    {
                        return 1f;
                    }
                    return 0f;
                }
        );

 

However, I want this property to apply to all of my items of a certain type, but when I try to iterate on this, it doesn't seem to work anymore and does nothing, no errors.

        ModItems.ITEMS.getEntries().forEach(
                (itemRegister) -> {
                    if(itemRegister.get() instanceof GunItem)
                        ItemModelsProperties.func_239418_a_(itemRegister.get(), new ResourceLocation(MatchlockGuns.modID, "is_loading"),
                                (stack, world, entity) -> {

                                    if(stack.getTag().getBoolean("is_loading"))
                                    {
                                        return 1f;
                                    }
                                    return 0f;
                                }
                        );
                }
        );

I've also tried some other forms of iteration, but none of them seem to work. What is the issue here? And is there any way to add a model property to all items of a certain type without having to manually add it for each of them?

 

Another thing I've tried is to call the runLater function for each item inside the Item class constructor, but this again does nothing

Edited by Korall
Posted (edited)
1 hour ago, poopoodice said:

Can you provide a repo?

Nevermind. I figured it out. I just referenced the wrong class in iteration. Needed to be instanceof NewGunItem and not GunItem. Sorry, I'm just kind of tired haha

 

 

Edited by Korall

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.