Procedure to when an entity get spawned every entity in an x radius get teleported to it

Started by danielminu on

Topic category: Help with modding (Java Edition)

Last seen on 15:55, 15. Dec 2023
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Procedure to when an entity get spawned every entity in an x radius get teleported to it

I need an procedure to when I make the custom entity of my mod spawns every entity that's not the player get teleported to it, can anyone help with this?

Last seen on 20:08, 17. Apr 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Under the 'on initial entity…
Sun, 03/26/2023 - 18:21
  • Under the 'on initial entity spawn' trigger, create a procedure.
  • In said procedure, place an 'for each entity as entity iterator' block. This will allow the procedure to target all entities in a radius, instead of only the entity causing the trigger.
  • Then, simply have a block that sets the location of the ENTITY ITERATOR to the TARGET ENTITY. The distinction between the two is important; the target entity is the one triggering the procedure; the entity iterator is each entity within the radius. 
  • Keep in mind this will target literally everything, including items, projectiles, and the like; so you'll probably want to at least specify that this should only affect living entities and players, for example. 
Last seen on 15:55, 15. Dec 2023
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ok bro, thx, I'll try making…
Mon, 03/27/2023 - 00:02

ok bro, thx, I'll try making it, if I can't do it can I dm you (on discord or smthg) ?

Last seen on 03:54, 17. Apr 2024
Joined Mar 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can actually do it much…
Mon, 03/27/2023 - 13:53

You can actually do it much easier by just executing a command as the spawned entity. "/tp @e[distance=..5] @s"

You can change the "5" to the distance you need. If you don't want players to get teleported use the unless statement or add "type=" to the requirements.