Make Piglin passive when wearing armor

Started by Drexel20 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make Piglin passive when wearing armor

I'm a new modder, and I'm making a mod that includes a new type of golden armor, and I want to make it so that when the player wears the armor, piglins become passive, I don't know how, I don't know if that's possible, please help

Joined Jun 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry for my bad English
Mon, 06/21/2021 - 11:51

Sorry for my bad English

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Gonna bump this question, it…
Tue, 07/06/2021 - 07:02

Gonna bump this question, it seems like a pretty core feature to make mobs peaceful with armor on, so a Procedure using the new functionality would be appreciated.

I know it's not proper…
Tue, 07/06/2021 - 07:31

I know it's not proper solution, but you can use command giving effect to a certain radius while wearing the armour, and make procedure adding all entities under that effect to specific scoreboard team (and removing them when effect ends). Scoreboard teams make all entities within it being peaceful to themselves (including even creepers not exploding), so it's useful workaround for all not-coded changes of behaviours.

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
use command giving effect to…
Tue, 07/06/2021 - 07:43

use command giving effect to a certain radius while wearing the armour, and make procedure adding all entities under that effect to specific scoreboard team

Very nice and simple workaround!

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do you make that effect…
Tue, 07/06/2021 - 08:08

How do you make that effect only target Piglins? I have made it so currently EVERYTHING within the radius gets set to the same team as the wearer with
 

on the scoreboard of [Event/target entity]

(I'm new to MCreator but not new to coding)

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I figured it out eventually,…
Tue, 07/06/2021 - 12:06

I figured it out eventually, but sadly I must confirm this workaround doesn't actually work. I thought I just messed up the Procedures my gear, but as it turns out being on the same teams as Piglins without gold on DOESN'T stop them from attacking you IN 1.16.5

In 1.17, being on the same team as Piglins and Brutes DOES stop them from attacking you, but NOT any version before.

Tested in Vanilla 1.16.5 by just manually adding Piglins and myself to a team through commands to make sure.

Oh, that's interesting. I…
Tue, 07/06/2021 - 15:26

Oh, that's interesting. I will try to test that myself I guess (was thinking about golden chainmail armour, so I have a reason for similar feature), but if it is as you say, then it's weird, considering there was no official bugs/fixes on that part, as far as I remember.

At least we know how to deal with that for 1.17, though ^^

Joined Jul 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Actually there was an…
Tue, 07/06/2021 - 18:09

Actually there was an official bug listing which did get (partially) fixed in 1.17 https://bugs.mojang.com/browse/MC-172304

That's how I knew I wasn't crazy after my testing lol

Your workaround would have been perfect, and it works great for something like a "Necromancer Chestplate" that would make Zombies or whatever passive, but it doesn't work for Piglins of all things.

I guess we need an MCreator update that natively supports the function MC uses to pacify Piglins with Gold, considering how useful that feature is; otherwise it's just raw code only.

Oh, so I wasn't aware of…
Tue, 07/06/2021 - 19:37

Oh, so I wasn't aware of that, thanks for the link. To be honest, when 1.16 was released, I rather watched HermitCraft than used MCreator, haha.

And yeah, I plan to use that scoreboard solution for several similar features, considering I'm working on magic mod now and this can come in handy ^^ but I will try to find other (non-code-related) solutions for Piglins anyway, since we all three need that. So if I find anything, I will let us know here.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Agreed- as far as I can tell…
Sun, 07/03/2022 - 23:25

Agreed- as far as I can tell, there's no good workaround for this. Usually I'd expect to find a tag or something that could just be modified, but it seems like this is just hard-coded.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
...Looked into it a bit more…
Mon, 07/04/2022 - 01:17

...Looked into it a bit more. It is possible to make an item neutralize piglins using Forge, (goodness knows there's plenty of mods that do just that.) However, since there's no tag for it, I'd assume you'd have to use some sort of custom code element. Specifically, this is the section of code I found that I assume neutralizes piglins, for the 'Gilded Netherite' mod:

public class GildedArmorItem extends ArmorItem
{
    public GildedArmorItem(ArmorMaterial material, EquipmentSlot slot, Properties properties)
    {
        super(material, slot, properties);
    }

    @Override
    public boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer)
    {
        return true;
    }

    @Override
    public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents, TooltipFlag pIsAdvanced)
    {
        for (int i = 1; i <= 3; i++)
            pTooltipComponents.add(new TranslatableComponent("item.gildedarmor.generic.upgrading_note" + i).withStyle(ChatFormatting.GRAY));
    }
}
Footer
© 2022 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Docs
C

On a (possibly easier) note, I also found an API that adds some Piglin tags, though I'm not sure if it supports Forge or not. (Wasn't entirely clear in the description.)

Piglib - Mods - Minecraft - CurseForge

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
...I'm betting if you lock…
Wed, 07/13/2022 - 11:09

...I'm betting if you lock the code for each item and input the 'makesPiglinsNeutral' property, it might just work. Haven't tested it though.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
OH MY GOSH I FIGURED IT OUT…
Sun, 07/31/2022 - 16:57

OH MY GOSH I FIGURED IT OUT. It took, like, an hour, but I came up with a method that works:

 

  • Make the mod element however you like, then lock the code.
  • Add the following to the big section at the top where it imports all of the variables and stuff:
    • import net.minecraft.world.item.ItemStack;
      
  • Add the following section of code to the second series of 'Overrides' at the bottom of the page, after the part where it references the texture file:
    • @Override
              public boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer)
              {
                  return true;
              }

...And that should do it! Any armor made in this fashion will neutralizes piglins when worn, with the same properties as regular gold armor.