The base class for entities on the server.
Server-side entities are deliberately more limited than their client counterparts, and that isn't an omission in this library — it reflects what FXServer actually exposes. The server owns positions, models, network IDs and state bags; the client that owns an entity owns its health, visual state, tasks and physics. Anything missing here has no server native behind it.
The practical consequence: change what the server can change directly, and push the rest to the owning client with an event.
var vehicle = Vehicle.create("adder", spawnPoint, 90.0);
vehicle.state.set("owner", player.identifier("license"));
Unlike client handles, server entity handles are stable for as long as the
entity exists, but they still mean nothing to a client — send netId.
Static methods
staticfromHandle(handle:Int):Entity
Wraps a handle in the most specific class available, or returns null
if the entity doesn't exist.
Constructor
Variables
read onlyhealth:Int
Current health. Read-only on the server — health is simulated by the owning client, so setting it means sending that client an event.
read onlynetId:Int
The network ID — the entity reference to send to clients — or 0 if the entity has none yet.
Guarded, because the underlying native raises rather than returning a sentinel:
script error in native ...: Tried to access invalid entity: 131333
An entity the server just created is orphaned until a client comes into scope for it: it has a handle, but no network ID and no owner. A stale handle behaves the same way. Both cases read as 0 here instead of taking down the handler that asked.
The existence check alone is not sufficient — the native has been
reported to raise even when DoesEntityExist says otherwise — so the
call itself is also caught.
read onlyowner:Int
The server ID of the client that currently owns this entity, or -1 when nobody does.
Ownership decides which client simulates the entity, and therefore who must be told to change its health, tasks or physics.
routingBucket:Int
The routing bucket this entity lives in.
Buckets are the server's instancing mechanism: entities and players in different buckets can't see or interact with each other at all. Bucket 0 is the default world.
Methods
delete():Void
Deletes the entity. Unlike on the client this always works — the server is authoritative and doesn't need to negotiate ownership first.
waitUntilNetworked(timeoutMs:Int = 5000):Bool
Blocks until the entity is registered on the server and has a network
ID, returning whether it got one before timeoutMs elapsed.
Server-created entities do not exist immediately — they stay orphaned
until a client is in scope. Anything that needs the network ID (sending
it to a client, writing a state bag) has to wait for this first, which
is what the create helpers do for you.
Returns false if no client ever comes into scope, or if the model was not valid for the entity type.