Mob don't attack if player has potion

Started by Noxvern on

Topic category: Help with MCreator software

Last seen on 18:39, 29. Jun 2024
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Mob don't attack if player has potion

Hello guys!
I want to create a mob that always attacks the player, except if it has the effect of a potion, I have tried a thousand times and I can't quite get it. If you can add screenshots or a detailed explanation of the procedures, I would be very grateful

Last seen on 02:25, 30. Jun 2024
Joined Feb 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
For this you'll want to…
Fri, 06/28/2024 - 02:58

For this you'll want to create a procedure under "on entity tick" INSTEAD of putting the attack target in the AI building zone. Create an if statement to first check if a player exists within its attack radius (this is important, since if you check if a nearby player has the effect and there is no player, it will crash!). Then within that if block, add another if block checking if the nearest player, within the same radius you set above, has the desired potion. Add a "not" to the the front, then inside, make it set the nearest player to its attack target. Alternatively, you can make that if statement into an if/else statement and have it clear its attack target if you want it to stop attacking the player if they consume the potion in front of the entity.