Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author
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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.