If entity is near block

Started by mabolob on

Topic category: Help with modding (Java Edition)

Last seen on 20:24, 25. Jul 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If entity is near block

I have a radioactive block and I want it so if an entity is within a 3x3 distance of the block it gives them a poison effect. I couldn't find anyone else having answered this but I might have just missed it.

I know that there is a get nearest entity but I want every entity in the area. I might be stupid and there is a simple thing to do but i don't know.

Last seen on 10:18, 21. Sep 2024
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can try to put this in…
Tue, 07/16/2024 - 21:37

You can try to put this in the OnBlockTickUpdate procedure, but be careful because searching for entities in a large radius can cause various lag problems. I recommend that you reduce the tick update interval of your block in case you intend to add many such blocks to the world.

Last seen on 20:24, 25. Jul 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Only seen this now but…
Thu, 07/25/2024 - 18:35

Only seen this now but cheers I'll try it out

Last seen on 04:57, 12. Oct 2024
Joined Dec 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
To reduce the size of your…
Thu, 07/25/2024 - 19:19

To reduce the size of your procedure, since it is a fixed 3x3 size, remove the radius variable and just use the number 3 in your "for each entity..." function as the variable is unnecessary in this use. 

Last seen on 20:24, 25. Jul 2024
Joined May 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't put it as a block…
Thu, 07/25/2024 - 20:13

I can't put it as a block tick update trigger because it's "Missing dependencies". I think its something to do with the fact the procedure is naming entities but I'm not sure how to fix it.