Interface ServerWorld

    • Method Detail

      • 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

        java.nio.file.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 java.io.IOException
        Instructs the world to save all data.
        Returns:
        True if save was successful, or false if SerializationBehavior is SerializationBehavior.NONE
        Throws:
        java.io.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
      • raids

        java.util.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

        java.util.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