Interface ServerWorld

All Superinterfaces:
ArchetypeVolumeCreator, Audience, BiomeVolume, BiomeVolume.Modifiable<ServerWorld>, BiomeVolume.Streamable<ServerWorld>, BlockEntityVolume, BlockEntityVolume.Modifiable<ServerWorld>, BlockEntityVolume.Streamable<ServerWorld>, BlockVolume, BlockVolume.Modifiable<ServerWorld>, BlockVolume.Streamable<ServerWorld>, ChunkVolume, ContextSource, EntityVolume, EntityVolume.Modifiable<ServerWorld>, EntityVolume.Streamable<ServerWorld>, EnvironmentalVolume, ForwardingAudience, GenerationVolume, GenerationVolume.Mutable, HeightAwareVolume, Identifiable, InteractableVolume, LocationBaseDataHolder, LocationBaseDataHolder.Mutable, LocationCreator<ServerWorld,ServerLocation>, MutableGameVolume, MutableVolume, PhysicsAwareMutableBlockVolume<ServerWorld>, Pointered, PrimitiveGameVolume, RandomProvider, Region<ServerWorld>, RegistryHolder, ServerLocationCreator, UpdatableVolume, Viewer, Volume, WeatherUniverse, WeatherUniverse.Mutable, World<ServerWorld,ServerLocation>, WorldLike<ServerWorld>

  • Method Details

    • engine

      Server engine()
      Description copied from interface: WorldLike
      Gets the Engine that simulates this world.
      Specified by:
      engine in interface WorldLike<ServerWorld>
      Returns:
      The engine
    • properties

      ServerWorldProperties properties()
      Description copied from interface: World
      Gets the properties.
      Specified by:
      properties in interface World<ServerWorld,ServerLocation>
      Returns:
      The properties
    • generator

      ChunkGenerator generator()
    • asTemplate

      WorldTemplate asTemplate()
    • key

      Returns:
      The key
      See Also:
    • uniqueId

      default UUID uniqueId()
      Description copied from interface: Identifiable
      Gets the unique ID for this object.
      Specified by:
      uniqueId in interface Identifiable
      Returns:
      The unique id
      See Also:
    • chunkAtBlock

      default WorldChunk chunkAtBlock(Vector3i blockPosition)
      Description copied from interface: World
      Gets the loaded chunk at the given block coordinate position. This gets a guaranteed WorldChunk at the desired block position; however, the WorldChunk instance may be empty, and likewise, may not be generated, valid, pre-existing. It is important to check for these cases prior to attempting to modify the chunk.

      Note that this is still different from World.chunk(Vector3i) due to it being a relative block position which can vary depending on implementation and other mods installed.

      Specified by:
      chunkAtBlock in interface ChunkVolume
      Specified by:
      chunkAtBlock in interface World<ServerWorld,ServerLocation>
      Parameters:
      blockPosition - The block position to be transformed for relative chunk position
      Returns:
      The available chunk at that position
    • chunkAtBlock

      default WorldChunk chunkAtBlock(int bx, int by, int bz)
      Description copied from interface: World
      Gets the loaded chunk at the given chunk coordinate position. The position is the block position relative to the Chunk.chunkPosition(), and therefor is going to return a different chunk from ChunkVolume.chunk(Vector3i). This is more usable from ServerLocations or a Locatable that returns a position in relation to a WorldLike. This gets a guaranteed WorldChunk at the desired block position; however, the WorldChunk instance may be empty, and likewise, may not be generated, valid, pre-existing. It is important to check for these cases prior to attempting to modify the chunk.

      Note that this is still different from World.chunk(Vector3i) due to the relative block position dictated by Server.chunkLayout(), which can vary depending on implementation and other mods installed.

      Specified by:
      chunkAtBlock in interface ChunkVolume
      Specified by:
      chunkAtBlock in interface World<ServerWorld,ServerLocation>
      Parameters:
      bx - The block x coordinate
      by - The block y coordinate
      bz - The block z coordinate
      Returns:
      The available chunk at that position
    • createSnapshot

      default BlockSnapshot createSnapshot(Vector3i position)
      Gets a snapshot of this block at the current point in time.

      A snapshot is disconnected from the World that it was taken from so changes to the original block do not affect the snapshot.

      Parameters:
      position - The position of the block
      Returns:
      A snapshot
    • createSnapshot

      BlockSnapshot createSnapshot(int x, int y, int z)
      Gets a snapshot of this block at the current point in time.

      A snapshot is disconnected from the World that it was taken from so changes to the original block do not affect the snapshot.

      Parameters:
      x - The x position
      y - The y position
      z - The z position
      Returns:
      A snapshot
    • restoreSnapshot

      boolean restoreSnapshot(BlockSnapshot snapshot, boolean force, BlockChangeFlag flag)
      Restores the given BlockSnapshot using the saved block position stored within the snapshot.

      If forced, the state of the block will change its BlockType to match that of the snapshot then set the state. However, if force is set to false and the BlockTypes does not match, false will be returned. If notifyNeighbors is true, neighboring blocks will be notified of changes at the restored block location triggering physic updates.

      Parameters:
      snapshot - The snapshot
      force - If true, forces block state to be set even if the BlockType does not match the snapshot one.
      flag - The various change flags controlling some interactions
      Returns:
      True if the restore was successful, false otherwise
    • restoreSnapshot

      default boolean restoreSnapshot(Vector3i position, BlockSnapshot snapshot, boolean force, BlockChangeFlag flag)
      Restores the BlockSnapshot at the given position.

      If forced, the state of the block will change its BlockType to match that of the snapshot then set the state. However, if force is set to false and the block types do not match, false will be returned. If notifyNeighbors is true, neighboring blocks will be notified of changes at the restored block location triggering physics updates.

      Parameters:
      position - The position of the block
      snapshot - The snapshot
      force - If true, forces block state to be set even if the the block type does not match the snapshot one.
      flag - The various change flags controlling some interactions
      Returns:
      True if the restore was successful, false otherwise
    • restoreSnapshot

      boolean restoreSnapshot(int x, int y, int z, BlockSnapshot snapshot, boolean force, BlockChangeFlag flag)
      Restores the BlockSnapshot at the given position.

      If forced, the state of the block will change its BlockType to match that of the snapshot then set the state. However, if force is set to false and the BlockTypes does not match, false will be returned. If notifyNeighbors is true, neighboring blocks will be notified of changes at the restored block location triggering physic updates.

      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      snapshot - The snapshot
      force - If true, forces block state to be set even if the BlockType does not match the snapshot one.
      flag - The various change flags controlling some interactions
      Returns:
      true if the restore was successful, false otherwise
    • directory

      Path directory()
      Gets the Path pointing to the root of where the world's data is being stored.
      Returns:
      The path
    • save

      boolean save() throws IOException
      Instructs the world to save all data.
      Returns:
      True if save was successful, or false if SerializationBehavior is SerializationBehavior.NONE
      Throws:
      IOException - If the save failed
    • unloadChunk

      boolean unloadChunk(WorldChunk chunk)
      Unloads the given chunk from the world. Returns a boolean flag for whether the operation was successful.
      Parameters:
      chunk - The chunk to unload
      Returns:
      Whether the operation was successful
    • triggerExplosion

      void triggerExplosion(Explosion explosion)
      Causes an Explosion in a world.
      Parameters:
      explosion - The explosion to cause
    • players

      Description copied from interface: World
      Gets an unmodifiable collection of players currently in this world.
      Specified by:
      players in interface EntityVolume
      Specified by:
      players in interface World<ServerWorld,ServerLocation>
      Returns:
      The players
    • raids

      Collection<Raid> raids()
      Gets all Raids occuring in this ServerWorld.

      Please note by default, some WorldTypes such as WorldTypes.THE_NETHER will not contain any Raids because the game prevents Raids from starting in the nether.

      Returns:
      All the raids in this world.
    • raidAt

      Optional<Raid> raidAt(Vector3i blockPosition)
      Gets the Raid occurring at a position in the world.
      Parameters:
      blockPosition - The location of the Raid.
      Returns:
      The raid at that location, if present
    • chunkManager

      ChunkManager chunkManager()
      Gets the ChunkManager for this world.
      Returns:
      The chunk manager.