BedrioxDOCUMENTATION
PLUGIN DEVELOPMENT

Entities

Entity objects are immutable observations. Live mutation uses a controller tied to the exact loaded entity generation, preventing a stale plugin reference from changing a different entity that later reused an identity.

Observe and control

Use the typed entity hierarchy to inspect identity, position, category, health, equipment, or mob state. Controllers can request transforms, rotation, velocity, name tags, visibility, scale, gravity, fire, health, equipment, AI, targeting, and despawn behavior where that entity type supports them.

Spawn a registered entity

PHP
use Bedriox\Api\Entity\CustomEntityType;
use Bedriox\Api\Player\Player;
use Bedriox\Api\World\Position;

private function spawnGuideFor(Player $player): void
{
    $type = new CustomEntityType('myplugin:arena_guide');
    $position = new Position(
        x: $player->position->x + 2.0,
        y: $player->position->y,
        z: $player->position->z,
        yaw: 0.0,
        pitch: 0.0,
        world: $player->position->world,
    );

    $this->context()->entities()->spawn($type, $position);
}

The caller supplies $player, normally from a command or event. $type identifies the custom definition registered during onEnable(), while $position is a complete position in the player's currently loaded world.

Register a CustomMobDefinition during plugin enable. Keep tick callbacks short; schedule external work and apply its result later through a freshly resolved controller. Use entity lifecycle events instead of bypassing normal authority.