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

Part 1) I want to add an armor material that piglins won't attack. I've traced a single line of code... if only I could modify! In IForgeItem#makesPiglinsNeutral, the input is checked that it is of gold material. How do I add my custom Armor material to this? Do I need reflection, or does forge allow an easier way to achieve/override this?

This method is called by IForgeItemStack#makesPiglinsNeutral, which is called by entity.monster.piglin.PiglinTasks#isWearingGold, called by PiglinMobSensor#doTick to update MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD

Part 2) I want to extend this behavior to piglin brutes. This likely requires an exponentially more difficult workaround. Any insight to this, and generally overriding vanilla mob features that aren't represented in Forge events?

  • Author
6 hours ago, diesieben07 said:

You override this method in your item class.

The IForgeItem method ends up being called in the following snippet by makesPiglingsNeutral:

public static boolean isWearingGold(LivingEntity p_234460_0_) {
      for(ItemStack itemstack : p_234460_0_.getArmorSlots()) {
         Item item = itemstack.getItem();
         if (itemstack.makesPiglinsNeutral(p_234460_0_)) {
            return true;
         }
      }

      return false;
   }

And the default IForgeItemStack method is:

default boolean makesPiglinsNeutral(LivingEntity wearer)
    {
        return getStack().getItem().makesPiglinsNeutral(getStack(), wearer);
    }

Will getItem().makesPiglingsNeutral return my overridden method? Or the default, since getItem() will return type Item rather than my ModdedArmorItem class?

Just now, izofar said:

Will getItem().makesPiglingsNeutral return my overridden method? Or the default, since getItem() will return type Item rather than my ModdedArmorItem class?

yes, if the ItemStack consists of your item

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.