Started by
LavalTB
on
Topic category: Troubleshooting, bugs, and solutions
I want to make a block that gives players regen if they’re 1 block away from the block. I tried a lot of things but they all failed. Plz help
Topic category: Troubleshooting, bugs, and solutions
I want to make a block that gives players regen if they’re 1 block away from the block. I tried a lot of things but they all failed. Plz help
You'll need to go into the advanced settings for your block, and make sure it's set to tick every 1 tick. Then, make a procedure that uses the block's 'on update tick trigger.'
In that procedure, you will need an entity iterator bracket. This targets any entity in the provided radius. In your case, you want a radius of three, and you want it to be centered at the position x+0.5, y+0.5, z+0.5 (the center of the block.) If you instead want them to be touching the block, you can make the radius something like 1.2; or if you want this to only work from a specific side, you could make the radius 1, and offset it slightly in the corresponding direction.
In the entity iterator, use an if bracket to check if the entity iterator, (NOT the event/target entity), is a subtype of 'player.' (Otherwise this will give regen to everything.) Inside the if bracket, use the potion function to add your desired amount and level of regen to the entity iterator.
Entity iterators are really helpful for targeting multiple things, or for cases like this where 'nearest entity' wouldn't be the best option.