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

Started by woodcreatures on Sun, 10/31/2021 - 17:20

Topic category: User side tutorials

Last seen on 18:08, 21. Jan 2022
Joined Mar 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Tutorial (Mobs only attack player if wearing or holding in hand particular item)
Sun, 10/31/2021 - 17:20

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:
  • Tracker tickets:
  • 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 05:29, 22. Jan 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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:
  • Tracker tickets:
  • 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 05:29, 22. Jan 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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:
  • Tracker tickets:
  • 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:
  • Tracker tickets:
  • 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 05:29, 22. Jan 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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:
  • Tracker tickets:
  • 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...