Skip to content

API reference / @jsprismarine/entities / PropertyValues

Class: PropertyValues ​

Defined in: entities/src/properties.ts:185

The live property values of one entity.

The store is keyed by property name, which is also how the engine persists them, so renaming a property discards the saved value.

Constructors ​

Constructor ​

new PropertyValues(definitions, resolveDefault?): PropertyValues

Defined in: entities/src/properties.ts:192

Parameters ​

definitions ​

ReadonlyMap<string, PropertyDefinition>

The entity type's declared properties, by name.

resolveDefault? ​

(definition, source) => PropertyValue | undefined

Evaluates a Molang default; returns undefined to fall back to the type's zero value.

Returns ​

PropertyValues

Methods ​

definition() ​

definition(name): PropertyDefinition | undefined

Defined in: entities/src/properties.ts:211

The declared property, or undefined when the entity type has none under the name.

Parameters ​

name ​

string

Returns ​

PropertyDefinition | undefined


get() ​

get(name): PropertyValue | undefined

Defined in: entities/src/properties.ts:216

The current value, or undefined when the entity type declares no such property.

Parameters ​

name ​

string

Returns ​

PropertyValue | undefined


has() ​

has(name): boolean

Defined in: entities/src/properties.ts:206

Whether the entity type declares the property.

Parameters ​

name ​

string

Returns ​

boolean


names() ​

names(): readonly string[]

Defined in: entities/src/properties.ts:221

Every declared property name, in declaration order.

Returns ​

readonly string[]


set() ​

set(name, value): PropertyValue | undefined

Defined in: entities/src/properties.ts:231

Writes a property, clamping an int or float into its range.

Parameters ​

name ​

string

value ​

PropertyValue

Returns ​

PropertyValue | undefined

The stored value, or undefined when the property is undeclared or the value has no place in its domain; neither writes anything.