World System
The World class is the central access point for world data. Each world runs on its own thread and manages chunks, entities, time, and player tracking.
World dimensions:
- Chunks are 32×32 blocks horizontally
- World height is 320 blocks (Y=0 to Y=319)
- Chunks are divided into 10 vertical sections (each 32×32×32 blocks)
See also: Creating Worlds for creating, loading, and removing worlds | World Events for lifecycle events | Threading for world thread details
Getting a World Reference
Section titled “Getting a World Reference”Package: com.hypixel.hytale.server.core.universe.world
// get all worldsMap<String, World> worlds = Universe.get().getWorlds();
// get default worldWorld defaultWorld = Universe.get().getDefaultWorld();
// get specific world by nameWorld lobby = Universe.get().getWorld("lobby");Key Properties
Section titled “Key Properties”| Method | Return Type | Description |
|---|---|---|
getName() | String | World’s unique identifier |
isAlive() | boolean | Whether the world is still running |
getTick() | long | Current tick number |
getPlayerCount() | int | Number of players in the world |
getPlayerRefs() | Collection<PlayerRef> | All players in the world |
getSavePath() | Path | Filesystem path for world data |
World State
Section titled “World State”// pause/resume world tickingworld.setPaused(true);boolean isPaused = world.isPaused();
// control chunk ticking (entities still tick)world.setTicking(false);boolean isTicking = world.isTicking();
// set tick rate (default 30)world.setTps(20);
// time dilation (0.01 to 4.0)World.setTimeDilation(2.0f, componentAccessor);The componentAccessor parameter is a ComponentAccessor - either a Store (in commands/events) or CommandBuffer (in ECS systems).
Thread Safety
Section titled “Thread Safety”World operations must run on the world thread. Use execute() for cross-thread calls:
// schedule on world threadworld.execute(() -> { // safe to modify world state here WorldChunk chunk = world.getChunk(ChunkUtil.indexChunkFromBlock(x, z)); chunk.setBlock(x, y, z, "hytale:stone", 0);});
// check if already on world threadif (world.isInThread()) { // direct access is safe}Stores
Section titled “Stores”// access chunk store (blocks, sections, chunk data)ChunkStore chunkStore = world.getChunkStore();
// access entity store (entities, players)EntityStore entityStore = world.getEntityStore();Both store objects exist immediately, but their internal ECS stores are null until the world starts. Wait for StartWorldEvent before accessing store contents, the chunk loader, or entities. See World initialization order.
Entities
Section titled “Entities”For full entity documentation, see Entity API.
Spawning Entities
Section titled “Spawning Entities”// create entity holderHolder<EntityStore> holder = EntityStore.REGISTRY.newHolder();// ... add components ...
// add to worldworld.getEntityStore().getStore().addEntity(holder, AddReason.SPAWN);Finding Entities
Section titled “Finding Entities”// get entity by UUIDRef<EntityStore> ref = world.getEntityRef(uuid);
// iterate all entities with a component type// ComponentType implements Query, so pass it directlyStore<EntityStore> store = world.getEntityStore().getStore();store.forEachChunk(Player.getComponentType(), (archetypeChunk, commandBuffer) -> { for (int i = 0; i < archetypeChunk.size(); i++) { Player player = archetypeChunk.getComponent(i, Player.getComponentType()); // process player }});
// for complex queries, use Query combinatorsQuery<EntityStore> query = Query.and(Player.getComponentType(), Health.getComponentType());store.forEachChunk(query, (archetypeChunk, commandBuffer) -> { ... });Players
Section titled “Players”// get all player referencesCollection<PlayerRef> players = world.getPlayerRefs();
// add player to worldCompletableFuture<PlayerRef> future = world.addPlayer(playerRef);
// add with specific transformworld.addPlayer(playerRef, transform, clearWorld, fadeInOut);
// drain all players to another worldworld.drainPlayersTo(targetWorld);Utilities
Section titled “Utilities”Messaging
Section titled “Messaging”// broadcast to all players in worldworld.sendMessage(Message.raw("Hello world!"));world.sendMessage(Message.translation("mymod.messages.welcome"));World Configuration
Section titled “World Configuration”WorldConfig config = world.getWorldConfig();See World Configuration for all settings — gameplay toggles (PvP, fall damage, NPC spawning), ticking, time, saving, client effects, and the two-layer config system with GameplayConfig.
Lighting
Section titled “Lighting”ChunkLightingManager lighting = world.getChunkLighting();
// invalidate light at blocklighting.invalidateLightAtBlock(chunk, x, y, z, blockType, oldHeight, newHeight);World Map
Section titled “World Map”WorldMapManager mapManager = world.getWorldMapManager();
// add marker providermapManager.addMarkerProvider("mymarkers", myProvider);