Script API - v1.20.30
    Preparing search index...

    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.

    Index

    Properties

    Properties

    propertyRegistry: PropertyRegistry

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

    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));
    });