How do I make a mob friendly when I hold a specific item?

Started by OlekDude on

Topic category: Help with modding (Java Edition)

Last seen on 16:20, 23. Dec 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make a mob friendly when I hold a specific item?

So I want to make a custom minecraft mob friendly when an I am holding a specific item. Does anybody know how to do that?

Last seen on 06:13, 28. Aug 2023
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Not 100% sure if it works…
Wed, 06/08/2022 - 15:54

Not 100% sure if it works but if you put the block for "follow if holding (item)" or something along those lines and put it at the top of the priority list it might stop it attacking? would need testing since I am not sure just a guess

Last seen on 16:20, 23. Dec 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay I tried and in survival…
Wed, 06/08/2022 - 16:05

Okay I tried and in survival mode it doesn't attack if I am holding the item, but if I hold another item and then switch back to it the mob keeps attacking.

Last seen on 06:13, 28. Aug 2023
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I would assume that is just…
Wed, 06/08/2022 - 16:10

I would assume that is just because of how the game works. For example when you swap off wheat and swap back to it, the animals take a moment to register the held item again. Try giving yourself insane health/armor and see if after a while of swapping back to the item it stops attacking

Last seen on 06:13, 28. Aug 2023
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Another thing you could try…
Wed, 06/08/2022 - 16:14

Another thing you could try is making a second version of the mob. When you have the item in your hand despawn it and spawn the friendly version. When you have not got it in your hand despawn the friendly one and spawn the original maybe?

Last seen on 16:20, 23. Dec 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay I managed to find out…
Wed, 06/08/2022 - 16:28

Okay I managed to find out how to do it now.

Last seen on 06:13, 28. Aug 2023
Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How did you do it in the end…
Wed, 06/08/2022 - 16:31

How did you do it in the end? Just so anyone with the same/similar issue stumbles across this can find out

Last seen on 16:20, 23. Dec 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I gave myself amazing armour…
Wed, 06/08/2022 - 16:39

I gave myself amazing armour and it did eventually turn good again, so I nerfed the mob so it wouldn't be able to kill you as easily when it's switching.