Files
Documentation/content/world/universe-and-worlds.en.md
2026-01-20 20:33:59 +01:00

2.3 KiB

title, type, weight
title type weight
Universe & Worlds docs 1

Universe

The Universe is a singleton managing all worlds:

import com.hypixel.hytale.server.core.universe.Universe;
import com.hypixel.hytale.server.core.universe.world.World;
import java.util.Map;

Universe universe = Universe.get();

// Get specific world
World world = universe.getWorld("default");

// Get all worlds
Map<String, World> worlds = universe.getWorlds();

// Check if world exists (hasWorld doesn't exist - use null check)
if (universe.getWorld("creative") != null) {
    // World exists
}

World

Each world contains chunks, entities, and players:

import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import java.util.Collection;
import java.util.List;

World world = Universe.get().getWorld("default");

// Get world name
String name = world.getName();

// Get all players (returns List<Player>)
List<Player> players = world.getPlayers();

// Get player refs
Collection<PlayerRef> playerRefs = world.getPlayerRefs();

{{< callout type="warning" >}} Note: world.getEntities() does not exist on World. Entities are managed through the EntityStore component system. {{< /callout >}}

World Operations

import com.hypixel.hytale.server.core.asset.type.blocktype.config.BlockType;
import com.hypixel.hytale.math.vector.Vector3i;

// Get block at position
BlockType blockType = world.getBlockType(x, y, z);
BlockType blockType = world.getBlockType(new Vector3i(x, y, z));

// Set block (takes String block type key, not BlockType)
world.setBlock(x, y, z, "stone");

// If you have a BlockType, use getId()
if (blockType != null) {
    world.setBlock(x, y, z, blockType.getId());
}

{{< callout type="info" >}} Note: world.getSpawnPoint() does not exist directly on World. Spawn configuration is accessed via world.getWorldConfig().getSpawnProvider(). {{< /callout >}}

World from Player Events

import com.hypixel.hytale.server.core.event.events.player.PlayerConnectEvent;
import java.util.logging.Level;

getEventRegistry().register(PlayerConnectEvent.class, event -> {
    PlayerRef playerRef = event.getPlayerRef();
    World world = event.getWorld();  // Can be null!

    if (world != null) {
        getLogger().at(Level.INFO).log("Player joined world: " + world.getName());
    }
});