functionlogEntitySpawnEvent( log: (message: string, status?: number) =>void, targetLocation: DimensionLocation ) { // register a new function that is called when a new entity is created. world.afterEvents.entitySpawn.subscribe((entityEvent: EntitySpawnAfterEvent) => { if (entityEvent && entityEvent.entity) { log(`New entity of type ${entityEvent.entity.typeId} created!`, 1); } else { log(`The entity event did not work as expected.`, -1); } });
Contains data related to an entity spawning within the world.
示例: logEntitySpawnEvent.ts