I've been researching around for an answer to this and haven't found anything. I'm looking for a way that a player could jump onto a block and after a few seconds the block will break. Then after a few more seconds it will respawn again. Thanks for the help!
Summon an invisible, marker, nogravity armor stand on top of the block, give it a name like FalseBlock. Now use a scoreboard to determine when to break/replace the block:
To summon the armor stand, stand on the block and type this:
Now when a player stands on that block for exactly 2 seconds, the block will turn into air, exactly two seconds after that the air will be turned back to stone. This will work for every armor stand that you name FalseBlock.
Edit: Note that if two people are standing on the same block, the block will break twice as fast. Each person standing on it will make the timer increase that many times per tick.
Only problem is now you're running one extra command from the original version. The original command is more optimized, but if multiple players making it go faster is an issue, and it doesn't cause any noticeable lag, than this is an acceptable work around.
You probably want this to work similar to blocks that fall in Mario, right? So as soon as you touch the block a delay starts, then whether or not you are on the block it will break after the time is up? For this, we could do something like this:
Now when a player steps on a stone block an armor stand will be summoned there and in exactly 1 second the block will disappear, then in two more seconds the block will reappear and the armor stand will be removed.
This method is probably the best one, no need to setup armor stands first and it is more optimized. You can also change the block from stone to whatever you want.
I've been researching around for an answer to this and haven't found anything. I'm looking for a way that a player could jump onto a block and after a few seconds the block will break. Then after a few more seconds it will respawn again. Thanks for the help!
This sounds like something that would be completely possible with the use of command blocks and/or plugins, I'm just not sure how.
I set the block to cake after 16 ticks then after 16 more It would set the block to air.
Your Kitty Lord,
Zach
Summon an invisible, marker, nogravity armor stand on top of the block, give it a name like FalseBlock. Now use a scoreboard to determine when to break/replace the block:
To summon the armor stand, stand on the block and type this:
/summon ArmorStand ~ ~ ~ {NoGravity:1,Marker:1,Invisible:1,CustomName:"FalseBlock"}
Create two scoreboard objectives by typing this into chat:
/scoreboard objectives add timer dummy
/scoreboard objectives add reset dummy
Now connect these to a clock (the faster clock you use the more precise it will work, in my example it will assume you are using a 20t/s fill clock):
/execute @e[type=ArmorStand,name=FalseBlock] ~ ~ ~ execute @p ~ ~ ~
scoreboard players set @e[type=ArmorStand,name=FalseBlock,score_reset=0,rm=2,r=3,c=1] timer 0
/execute @a ~ ~ ~ scoreboard players add @e[type=ArmorStand,name=FalseBlock,r=1,score_reset=0] timer 1
/execute @e[type=ArmorStand,name=FalseBlock,score_timer_min=40] ~ ~ ~ setblock ~ ~-1 ~ minecraft:air
/scoreboard players add @e[type=ArmorStand,name=FalseBlock,score_timer_min=40] reset 1
/execute @e[type=ArmorStand,name=FalseBlock,score_timer_min=40,score_reset_min=40] ~ ~ ~ setblock ~ ~-1 ~ minecraft:stone
Now when a player stands on that block for exactly 2 seconds, the block will turn into air, exactly two seconds after that the air will be turned back to stone. This will work for every armor stand that you name FalseBlock.
Edit: Note that if two people are standing on the same block, the block will break twice as fast. Each person standing on it will make the timer increase that many times per tick.
Thanks! I'm assuming there is no fix for that last part other than only allowing one player at a time?
Sure, you could change line #2 from:
/execute @a ~ ~ ~ scoreboard players add @e[type=ArmorStand,name=FalseBlock,r=1,score_reset=0] timer 1
To this:
/execute @e[type=ArmorStand,name=FalseBlock,score_reset=0] ~ ~ ~ execute @p[r=1] ~ ~ ~ scoreboard players add @e[type=ArmorStand,name=FalseBlock,score_reset=0,c=1] timer 1
Only problem is now you're running one extra command from the original version. The original command is more optimized, but if multiple players making it go faster is an issue, and it doesn't cause any noticeable lag, than this is an acceptable work around.
Is there a way to do this with the detect command and still have a delay before it breaks the block beneath the player?
You probably want this to work similar to blocks that fall in Mario, right? So as soon as you touch the block a delay starts, then whether or not you are on the block it will break after the time is up? For this, we could do something like this:
/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:stone 0 summon ArmorStand ~ ~ ~ {Invisible:1,Marker:1,Invulnerable:1,NoGravity:1,CustomName:"FalseBlock"}
/scoreboard players add @e[type=ArmorStand,name=FalseBlock] timer 1
/execute @e[type=ArmorStand,name=FalseBlock,score_timer_min=20] ~ ~ ~ setblock ~ ~-1 ~ minecraft:air
/execute @e[type=ArmorStand,name=FalseBlock,score_timer_min=60] ~ ~ ~ setblock ~ ~-1 ~ minecraft:stone
/kill @e[type=ArmorStand,name=FalseBlock,score_timer_min=60]
Now when a player steps on a stone block an armor stand will be summoned there and in exactly 1 second the block will disappear, then in two more seconds the block will reappear and the armor stand will be removed.
This method is probably the best one, no need to setup armor stands first and it is more optimized. You can also change the block from stone to whatever you want.
*Mind Blown* I lost a few thousand brain cells but I should be able to figure this out. Thanks!