Tutorial (Mobs only attack player if wearing or holding in hand particular item)

Started by woodcreatures on

Topic category: User side tutorials

Last seen on 06:05, 28. Mar 2024
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Tutorial (Mobs only attack player if wearing or holding in hand particular item)

Considering this has been asked plenty of times in the last week I will give a brief explanation on how to do this.

1) Create a global variable (map or world) / logic / starting value false

2) Create a procedure on player tick update: "IF" item in main hand or if get item from slot N° (it depends on what you need) then set global variable to true "ELSE" set global variable to false

3) Go into your mob AI and add the line attack player. Click on condition and apply same conditions for both fields (start and continue): RETURN global variable = true

In this way all mobs will start attacking you once item is equipped / at hand but if you remove item then they will stop attacking you

If you want for him to keep attacking you after the first attack even if item no longer in hand then just remove conditions to "continue" field.

This works for custom models only

Only solution I have for Vanilla mobs is instead adding another procedure: entity joins the world. "IF" entity = (vanilla mob) then despawn entity and spawn your custom mob which is identical to vanilla mob and also same name. At this point repeat points 1 to 3 applied to your mob

Hope this will help someone

Last seen on 17:56, 14. Nov 2021
Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
When I try to apply the…
Fri, 11/05/2021 - 20:10

When I try to apply the conditions, I don't see any conditions 

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Rareshero click the…
Fri, 11/05/2021 - 20:19

@Rareshero

click the Conditions button and make a new condition

AI

Last seen on 17:56, 14. Nov 2021
Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
When I open it all I see is…
Fri, 11/05/2021 - 20:25

When I open it all I see is no additional condition

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you have to create it. click…
Fri, 11/05/2021 - 20:34

you have to create it. click the + button

Last seen on 17:56, 14. Nov 2021
Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
What + button ?  
Fri, 11/05/2021 - 20:36

What + button ?

 

Last seen on 17:56, 14. Nov 2021
Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
https://ibb.co/Gk2S7CH -…
Fri, 11/05/2021 - 20:37

https://ibb.co/Gk2S7CH - This is what i see when i click on conditions 

 

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yeah make a new element…
Fri, 11/05/2021 - 20:52

yeah make a new element called procedure And make the procedure but make sure to use the conditions so it appears

Last seen on 17:56, 14. Nov 2021
Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you show me a photo ? I…
Fri, 11/05/2021 - 20:54

Can you show me a photo ? I've been searching for 1 hour and I can't think properly...

 

Last seen on 08:05, 12. Jan 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I know this is an older…
Sat, 07/16/2022 - 05:51

I know this is an older topic, but I am having issues with this setup. I am trying to make it so that if you are wearing a helmet, leggings, and boots, then the one entity will not attack you, which works fine, but when I take them off, the entity still acts as if I am wearing the armor. These images show the procedure I created, and the mob ai screen with the ai condition editor open

Last seen on 08:05, 12. Jan 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry, I did images wrong,…
Sat, 07/16/2022 - 05:54

Sorry, I did images wrong, first time using imgur lol
These images show the procedure I created, and the mob ai screen with the ai condition editor openThese images show the procedure I created, and the mob ai screen with the ai condition editor open

Last seen on 10:44, 18. May 2023
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hey lexuigi, i know that was…
Thu, 04/06/2023 - 11:57

hey lexuigi, i know that was a while ago but today i managed to figure it out

this is my aggressive mob, its meant to not attack when you wear a certain armor set.

the conditions are set to this:

 

i set up 2 procedures that look like this:

and they just check if the player is wearing the entire armor set and returns either a "false" or "true"

even though i only set one in the conditions both are most likely required, i havent tested removing the second one yet.

anyway, now it works for me.

(you dont wanna know how many hours of searching and testing it took to figure this out)

Last seen on 00:07, 25. Mar 2024
Joined Sep 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is useful, now I can…
Thu, 04/06/2023 - 21:49

This is useful, now I can create mobs that target you only if you have bad omen! (to make sure that make sure you don't cause a raid.)

Last seen on 10:36, 15. Oct 2023
Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I want to prank my friend…
Thu, 05/18/2023 - 08:45

I want to prank my friend and I'm just wondering if there is a way to only aggro a player with a specific NBT tag?