Posted July 11, 20214 yr 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?
July 11, 20214 yr 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?
July 11, 20214 yr 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.