Using only MC command blocks (I am using 1.9) how can I create a short timer?
It needs to be command block-only because I am trying to make a 1-block command; I want to make it night time and give the player a night-vision effect for ten seconds, but after the ten seconds I want to revert it back to day-time. I haven't yet figured out how to achieve this final part, of setting it back to day after ten seconds.
So far I have got the command:
summon FallingSand ~ ~1 ~ {
Block: command_block,
Time: 1,
TileEntityData: {
Command: /time set 18000
},
Passengers: [
{
id: FallingSand,
Block: chain_command_block,
Time: 1,
TileEntityData: {
Command: /effect @a 16 10 1 true
},
Passengers: [
{
id: FallingSand,
Block: redstone_block,
Time: 1
}
]
}
]
}
Sorry for the hierarchical mess, but basically, the above code spawns this structure:
Which does exactly what I want it to do: the top command block, just underneath the redstone, gives night vision for 10 seconds, and the bottom command block sets the time to midnight (18000
.)
How can I add a bit to this setup to make it wait roughly ten seconds before setting the time back to day?
Best Answer
You can make a scoreboard:
Create a entity which counts for you:
Make it it invisible and a marker if you want:
Then a repeating command block which increases this scoreboard every tick (20 ticks = 1 second):
Put your commands into an execute:
Change the 200 to whatever seconds you want * 20:
Sorry, I first understood your question wrong, just remove the reset.