Day night cycle
This commit is contained in:
@@ -497,6 +497,8 @@ interface ServerWorld {
|
||||
drop_item(x: number, y: number, z: number, item: ItemStack): void; // pops out of the block, like drops
|
||||
is_loaded(x: number, z: number): boolean;
|
||||
readonly seed: string;
|
||||
readonly time: number; // world time, see below
|
||||
set_time(time: number): void; // synced to every player
|
||||
}
|
||||
|
||||
interface Player {
|
||||
@@ -533,6 +535,12 @@ interface ModStorage {
|
||||
}
|
||||
```
|
||||
|
||||
**World time** counts ticks since 06:00 of day 1 and never wraps around. A day (06:00 to 18:00) is 36000 ticks, 30
|
||||
minutes, and a night (18:00 to 06:00) is 12000 ticks, 10 minutes, so in game hours are shorter at night. Dusk is the
|
||||
first minute of the night and dawn the last, so it's bright all day. `common/time.ts` has `clock`, `format_clock`,
|
||||
`is_day` and `daylight` for turning it into something readable. Client scripts can read it as `ctx.world.time`, and
|
||||
players can use `/time`, `/time set <ticks|day|noon|sunset|night|midnight>` and `/time add <ticks>`.
|
||||
|
||||
The server loads chunks around every player (its simulation distance) and generates them itself with the same generator
|
||||
as the clients. Blocks in unloaded chunks can't be read or changed, and don't tick.
|
||||
|
||||
@@ -549,7 +557,7 @@ ctx.commands.register("heal", {
|
||||
```
|
||||
|
||||
Commands run on the server when a player types `/name` in chat. Two mods using the same name, or a mod using one of the
|
||||
engine's (`give` and `tps`), is a load error. `/copper_tools:heal` always works as the unambiguous form.
|
||||
engine's (`give`, `time` and `tps`), is a load error. `/copper_tools:heal` always works as the unambiguous form.
|
||||
|
||||
## Client scripts
|
||||
|
||||
|
||||
Reference in New Issue
Block a user