π World and blocks API¶
Time, weather, game rules, and every block of the world.
The world¶
The time of day¶
Rust: World::get().time()
Go: levilamina.Time()
Zig: levilamina.slot("get_time")
- Return value: the time of day in game ticks: 24000 to a day, 0 sunrise, 6000 noon, 18000 midnight
- Return type: Rust
Result<i64>, Go(int64, error) - Slot:
get_time -
Example:
- Rust
Rust - Go
Go
Setting the time¶
Rust: World::get().set_time(t)
Go: levilamina.SetTime(t)
Zig: levilamina.slot("set_time")
- Parameters:
- t : integer
game ticks
- t : integer
- Return value: nothing on success
- Return type: Rust
Result<()>, Goerror, Zigbool - Slot:
set_time -
Example:
- Rust
Rust - Go
Go - Zig
Setting the weather¶
Rust: World::get().set_weather(weather)
Go: levilamina.SetWeather(weather)
Zig: levilamina.slot("set_weather")
- Parameters:
- weather : Rust
Weather, Go and Zig an integer
clear, rain, thunder (0, 1, 2)
- weather : Rust
- Return value: nothing on success
- Return type: Rust
Result<()>, Goerror - Slot:
set_weather -
Example:
- Rust
Rust - Go
Go
Game rules¶
Rust: World::get().game_rule(name)
Go: levilamina.GameRule(name)
Zig: levilamina.slot("game_rule_get")
Writing: Rust set_game_rule(name, value), Go SetGameRule(name, value), slot game_rule_set. A value goes in as text, read according to the rule's type.
- Parameters:
- name : string
the rule name, as/gameruletakes it
- name : string
- Return value: the rule's value
- Return type: Rust
Result<GameRuleValue>, Go(string, error) - Slot:
game_rule_get,game_rule_set -
Example:
- Rust
Rust - Go
Blocks¶
A block is named by its dimension and position: Rust Block::at(dim, x, y, z), Go levilamina.Block(dim, x, y, z), Zig levilamina.BlockAt.at(dim, x, y, z). block stands for it below.
Reading a block¶
Rust: block.read()
Go: block.Info()
Zig: block.typeName(allocator)
- Return value: the block's type name, such as
minecraft:oak_log, and its block state - Return type: Rust
Result<BlockInfo>, Go(BlockInfo, error), Ziglevilamina.Error![]u8- Before the level has loaded, a read returns an error.
- Slot:
get_block -
Example:
- Rust
Rust - Go
Go - Zig
Placing a block¶
Rust: block.set(spec)
Go: block.Set(spec)
Zig: levilamina.slot("set_block")
- Parameters:
- spec : string
the block, as/setblocktakes it, block states included, such asminecraft:oak_log["pillar_axis"="x"]
- spec : string
- Return value: nothing on success
- Return type: Rust
Result<()>, Goerror, Zigbool - Slot:
set_block -
Example:
- Rust
Rust - Go
Go - Zig
Block states¶
Rust: block.state(name)
Go: block.State(name)
Zig: levilamina.slot("block_get_state")
Writing: Rust set_state(name, value), Go SetState(name, value), slot block_set_state.
- Parameters:
- name : string
the state name, such as a log'spillar_axis
- name : string
- Return value: the state's value
- Return type: Rust
Result<String>, Go(string, error) - Slot:
block_get_state,block_set_state -
Example:
- Rust
Rust - Go
A waterlogged block is two blocks
A slab or fence standing in water is the slab with water layered on top. A read gives the main block; the water is in the extra block layer.