1

I am trying to activate an effect on a player when the player steps on a given block, in this case Skulk Catalysts. Rather than target the closest player to the command block executing the command, I have it targeting the player that touches the skulk sensor. The issue I'm getting with this command is that it infinitely repeats while the player is standing on the skulk catalyst. Is there any way to get this to trigger only once, until a new skulk catalyst is touched?

execute as @a at @s if block ~ ~1 ~ minecraft:sculk_catalyst run scoreboard players add @s Hearts 1

Currently the command blocks are set to repeat - the given command does not appear to work if they are set to chain or impulse, although if there is a solution that uses one or both of those two then I am happy to use that.

2 Answers 2

1

Use a chain command block before this one, that activates when there is no sculk sensor under the players feet.

This command should work for that command block:

execute as @a at @s unless block ~ ~1 ~ minecraft:sculk_catalyst

maybe you need to add a one tick delay, with a repeater for example.

1

you can use a chain command block, set to "conditional", with a dummy "toggle" scoreboard, and force it to only fire when said toggle score is a specific value;

  1. create the scoreboard;
    • scoreboard objectives add HeartsToggle dummy
  2. in your repeating command block, place a modified version of your command for the sculk sensor.
    • you'll need to specify the score. this can work various ways;
      • execute as @a[scores={HeartsToggle=0}] at @s... <- checks score while looking for players
      • ...at @s if score @s HeartsToggle matches 0 <- checks score after finding all players
  3. in a chain command block attached to the repeating (and facing the same way as it; this is important);
    • execute as @a at @s if block ~ ~1 ~ minecraft:sculk_catalyst run scoreboard players set @s HeartsToggle 1
      • you can do the same score checks as above here, too, if you want to prevent this one from constantly firing a la performance or simple optimization, but it's not crucial.

the score checks in step 2 will ensure that only those with HeartsToggle of 0 can fire the sculk sensor command block, which works even if HeartsToggle wasn't explicitly given to that player (because having no score is equivalent to having 0 as your score).

if you intend on letting your players step back on, you would need a similar setup that does the opposite (e.g. if they aren't on the block, set HeartsToggle to 0), otherwise they will never be able to fire that sculk command again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .