Can someone help me with a block spawning and keeping track of a entity

Started by Jenssons on Sun, 12/04/2022 - 05:35

Topic category: Help with modding (Java Edition)

Last seen on 18:48, 4. Dec 2022
Joined Apr 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Can someone help me with a block spawning and keeping track of a entity
Sun, 12/04/2022 - 05:35

Hai i want a block when its placed to spawn a entity and then i want that block to keep that entity on top of it and if that entity dies spawn a new one to instantly replace it. is this possible to do? i imagine its something to do with the block keeping the entity's id in a local variable and then from there it can call from it to do checks if its still alive and on top of it, i do not know how to do that, would anyone be willing to help me. Maybe show me some code/layout thank you so much for reading 

Last seen on 22:46, 28. Jan 2023
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
You can make the entity stay…
Sun, 12/18/2022 - 17:16

You can make the entity stay put by storing its location on top of the block as NBT tags and then setting its location to that place every tick. If this is done, absolutely nothing can move that mob.
You could also program the mob to instantly die if it detects it is no longer standing on the correct block.
Now as for making more of the entity... Maybe a procedure that detects how many of the mobs are nearby and spawns one on top if the number is zero?