Worlds and blocks
Use Server::getWorldManager() to work with loaded worlds. A World handle
identifies both the logical world and its current load generation.
Read and change a block
use Bedriox\Api\Player\Player;
use Bedriox\Api\World\BlockPosition;
private function placeLobbyBlock(Player $player): void
{
$world = $player->position->world;
$blockPosition = new BlockPosition(10, 64, 10);
$current = $world->getBlock($blockPosition);
if ($current->identifier === 'minecraft:air') {
$world->setBlock($blockPosition, 'minecraft:stone');
}
}
The caller supplies a connected $player. $world comes from that player's
current position, $blockPosition is the integer target coordinate, and
$current is the immutable block snapshot returned by Bedriox.
Use canonical minecraft:* identifiers. Bedriox owns internal and network
runtime IDs; plugins should never store or manufacture them.
Position carries precise coordinates in one world. BlockPosition carries
integer block coordinates. World handles can read or request weather changes
and spawn typed particles for all eligible viewers or a bounded player list.
Retained handles do not keep worlds loaded. After delayed or asynchronous work,
resolve the world again and confirm isSameLoad() before applying a result.
