How can I make an entity not spawn/despawn in a specific radius of a specific block?

Started by PAIIIIIIN on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I make an entity not spawn/despawn in a specific radius of a specific block?

So basically I have a custom entity and a custom block. What I want is the following...

if the block is placed, the entity cannot spawn in a 10 block radius of the block. And if there already is an entity placing the block will despawn it (same radius).

I previously used a procedure that worked, but it would crash the game.

 

I would really appreciate if someone could help me accomplish this without making the game crash. THANK YOU!