Help for targeting entities in a range

Started by Riccardo17 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help for targeting entities in a range

Hi, i'm kinda new to MCreator, and I need help to apply a slowness effect to all entities in a range of 10 blocks, when I right click with a custom item I made. How can I do it?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Depends on what kind of…
Sun, 03/12/2023 - 00:45

Depends on what kind of range you want- it's easier if you do it as a square since there's procedures built in for it. Basic idea is:

Take an 'Entity Iterator' procedure block from World Management: instead of executing procedures on a single entity, this will take all entities within a given range, and execute a procedure on them.

Now just do whatever procedure you want, but put it inside the entity iterator block, and replace 'target entity' with entity iterator.

To summarize: Make a procedure for your item's right click that triggers an 'entity iterator block,' inside of which you put a 'give potion effect' to 'entity iterator.' You might also want to add a cooldown to the item when you do this, or just have it check first that the entity iterator doesn't have the potion effect before applying it. (Otherwise, if you continuously click the item, it'll either reset the potion timer, or add more than the desired amount.)