Interface NMSWorld
- All Superinterfaces:
NMSObject
This interface provides a version-independent abstraction for working with Minecraft's internal world representation. It bridges the gap between Bukkit's high-level world API and the underlying NMS world implementation, enabling direct access to advanced world operations and internal state.
The wrapper provides access to chunk management, world boundaries, block operations, and entity spawning while maintaining compatibility across different Minecraft versions. It serves as the primary entry point for world-level NMS operations.
Example usage:
// Get NMS world wrapper
NMSWorld nmsWorld = worldProvider.wrap(bukkitWorld);
// Access chunk operations
NMSChunkProvider chunkProvider = nmsWorld.getChunkProvider();
NMSChunk chunk = chunkProvider.wrap(bukkitChunk);
// Perform world operations
nmsWorld.refreshBlockAt(player, x, y, z);
Entity entity = nmsWorld.spawnEntity(location, Zombie.class, SpawnReason.CUSTOM);
-
Method Summary
Modifier and TypeMethodDescription@NotNull AbstractBlockUtil
Retrieves the block utility for this world.@NotNull World
Retrieves the Bukkit world representation of this NMS world.@NotNull NMSChunkProvider
Retrieves the chunk provider for this world.int
Retrieves the maximum height (Y coordinate) for this world.int
Retrieves the minimum height (Y coordinate) for this world.void
refreshBlockAt
(@NotNull Player player, int x, int y, int z) Forces a block refresh for a specific player at the given coordinates.<T extends Entity>
TspawnEntity
(@NotNull Location loc, @NotNull Class<T> clazz, CreatureSpawnEvent.SpawnReason reason) Spawns an entity at the specified location with the given spawn reason.
-
Method Details
-
getBukkitWorld
Retrieves the Bukkit world representation of this NMS world.This method provides access to the Bukkit API representation of the same world, allowing for integration with Bukkit-based code and plugins that expect Bukkit world objects.
- Returns:
- the Bukkit
World
representation
-
getChunkProvider
Retrieves the chunk provider for this world.The chunk provider manages all chunk operations within this world, including loading, saving, and wrapping chunks for NMS access. It serves as the factory for creating
NMSChunk
wrappers from Bukkit chunks.- Returns:
- the
NMSChunkProvider
for this world
-
getMinHeight
int getMinHeight()Retrieves the minimum height (Y coordinate) for this world.This value represents the lowest Y coordinate where blocks can exist in the world. In older versions, this was typically 0, but newer versions support negative Y coordinates and extended world height.
This value is essential for chunk section calculations and ensuring operations remain within valid world boundaries.
- Returns:
- the minimum Y coordinate for this world
-
getMaxHeight
int getMaxHeight()Retrieves the maximum height (Y coordinate) for this world.This value represents the highest Y coordinate where blocks can exist in the world. The maximum height varies between Minecraft versions and world types, with newer versions supporting extended heights.
This value is essential for chunk section calculations and ensuring operations remain within valid world boundaries.
- Returns:
- the maximum Y coordinate for this world
-
refreshBlockAt
Forces a block refresh for a specific player at the given coordinates.This method sends a block update packet to the specified player, ensuring they see the current state of the block at the given coordinates. This is particularly useful after making direct block modifications through NMS that might not trigger automatic client updates.
The refresh only affects the specified player's view and does not modify the actual block state or notify other players.
- Parameters:
player
- thePlayer
to send the block update tox
- the X coordinate of the block to refreshy
- the Y coordinate of the block to refreshz
- the Z coordinate of the block to refresh
-
spawnEntity
@NotNull <T extends Entity> T spawnEntity(@NotNull @NotNull Location loc, @NotNull @NotNull Class<T> clazz, @NotNull CreatureSpawnEvent.SpawnReason reason) Spawns an entity at the specified location with the given spawn reason.This method provides direct access to NMS entity spawning, allowing for more control over the spawning process than the standard Bukkit API. The spawn reason affects various game mechanics and plugin event handling.
The entity is spawned using NMS methods, which may bypass some Bukkit event systems or provide different behavior compared to standard Bukkit spawning methods.
- Type Parameters:
T
- the type of entity to spawn- Parameters:
loc
- theLocation
where the entity should be spawnedclazz
- theClass
representing the entity type to spawnreason
- theCreatureSpawnEvent.SpawnReason
for this spawn event- Returns:
- the newly spawned entity instance
-
getBlockUtil
Retrieves the block utility for this world.The block utility provides high-performance block manipulation methods that are optimized for bulk operations and direct NMS access. This is an internal API method used by other components of the NMS abstraction layer.
Note: This method is intended for internal use by other NMS wrapper components and should generally not be accessed directly by external code.
- Returns:
- the
AbstractBlockUtil
for this world
-