Class WorldInitializeAfterEventBeta

Contains information and methods that can be used at the initialization of the scripting environment for a World. Also, use the supplied propertyRegistry object to register any dynamic properties, within the scope of the World Initialize execution.

Hierarchy

  • WorldInitializeAfterEvent

Constructors

Properties

Constructors

Properties

propertyRegistry: PropertyRegistry

Remarks

Contains methods for scripts to initialize and register dynamic properties they may wish to use within a world.

Example

propertyRegistration.js

import { DynamicPropertiesDefinition, EntityTypes, world } from '@minecraft/server';
import { MinecraftEntityTypes } from '@minecraft/vanilla-data';

world.afterEvents.worldInitialize.subscribe(e => {
let def = new DynamicPropertiesDefinition();

def.defineNumber('rpgStrength');
def.defineString('rpgRole', 16);
def.defineBoolean('rpgIsHero');

e.propertyRegistry.registerEntityTypeDynamicProperties(def, EntityTypes.get(MinecraftEntityTypes.Skeleton));
});