Interface SimpleWorld

All Superinterfaces:
Extent, IChunkCache<IChunkGet>, InputExtent, Keyed, OutputExtent, Trimable, World

public interface SimpleWorld extends World
An abstract implementation of World.
  • Method Details

    • useItem

      default boolean useItem(BlockVector3 position, BaseItem item, Direction face)
      Description copied from interface: World
      Use the given item on the block at the given location on the given side.
      Specified by:
      useItem in interface World
      item - The item
      face - The face
      Returns:
      Whether it succeeded
    • setBlock

      default <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException
      Description copied from interface: World
      Similar to OutputExtent.setBlock(BlockVector3, BlockStateHolder) but a notifyAndLight parameter indicates whether adjacent blocks should be notified that changes have been made and lighting operations should be executed.

      If it's not possible to skip lighting, or if it's not possible to avoid notifying adjacent blocks, then attempt to meet the specification as best as possible.

      On implementations where the world is not simulated, the notifyAndLight parameter has no effect either way.

      Specified by:
      setBlock in interface World
      Parameters:
      position - position of the block
      block - block to set
      notifyAndLight - true to to notify and light
      Returns:
      true if the block was successfully set (return value may not be accurate)
      Throws:
      WorldEditException
    • getFullBlock

      default BaseBlock getFullBlock(BlockVector3 position)
      Description copied from interface: InputExtent
      Get an immutable snapshot of the block at the given location.
      Specified by:
      getFullBlock in interface InputExtent
      Parameters:
      position - position of the block
      Returns:
      the block
    • setBlock

      <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 pt, B block) throws WorldEditException
      Description copied from interface: OutputExtent
      Change the block at the given location to the given block. The operation may not tie the given BlockStateHolder to the world, so future changes to the BlockStateHolder do not affect the world until this method is called again.

      The return value of this method indicates whether the change was probably successful. It may not be successful if, for example, the location is out of the bounds of the extent. It may be unsuccessful if the block passed is the same as the one in the world. However, the return value is only an estimation and it may be incorrect, but it could be used to count, for example, the approximate number of changes.

      Specified by:
      setBlock in interface OutputExtent
      Parameters:
      pt - position of the block
      block - block to set
      Returns:
      true if the block was successfully set (return value may not be accurate)
      Throws:
      WorldEditException - thrown on an error
    • getStoragePath

      @Nullable default Path getStoragePath()
      Description copied from interface: World
      Get the folder in which this world is stored. May return null if unknown or if this world is not serialized to disk.
      Specified by:
      getStoragePath in interface World
      Returns:
      world storage path
    • getMaxY

      default int getMaxY()
      Description copied from interface: World
      Get the maximum Y.
      Specified by:
      getMaxY in interface Extent
      Specified by:
      getMaxY in interface World
      Returns:
      the maximum Y
    • getMinY

      default int getMinY()
      Description copied from interface: World
      Get the minimum Y.
      Specified by:
      getMinY in interface Extent
      Specified by:
      getMinY in interface World
      Returns:
      the minimum Y
    • createLiquidMask

      default Mask createLiquidMask()
      Description copied from interface: World
      Create a mask that matches all liquids.

      Implementations should override this so that custom liquids are supported.

      Specified by:
      createLiquidMask in interface World
      Returns:
      a mask
    • dropItem

      default void dropItem(Vector3 pt, BaseItemStack item, int times)
      Description copied from interface: World
      Drop an item at the given position.
      Specified by:
      dropItem in interface World
      Parameters:
      pt - the position
      item - the item to drop
      times - the number of individual stacks to drop (number of item entities)
    • checkLoadedChunk

      default void checkLoadedChunk(BlockVector3 pt)
      Description copied from interface: World
      Load the chunk at the given position if it isn't loaded.
      Specified by:
      checkLoadedChunk in interface World
      Parameters:
      pt - the position
    • fixAfterFastMode

      default void fixAfterFastMode(Iterable<BlockVector2> chunks)
      Description copied from interface: World
      Fix the given chunks after fast mode was used.

      Fast mode makes calls to World.setBlock(BlockVector3, BlockStateHolder, boolean) with false for the notifyAndLight parameter, which may causes lighting errors to accumulate. Use of this method, if it is implemented by the underlying world, corrects those lighting errors and may trigger block change notifications.

      Specified by:
      fixAfterFastMode in interface World
      Parameters:
      chunks - a list of chunk coordinates to fix
    • fixLighting

      default void fixLighting(Iterable<BlockVector2> chunks)
      Description copied from interface: World
      Relight the given chunks if possible.
      Specified by:
      fixLighting in interface World
      Parameters:
      chunks - a list of chunk coordinates to fix
    • playEffect

      default boolean playEffect(BlockVector3 position, int type, int data)
    • queueBlockBreakEffect

      default boolean queueBlockBreakEffect(Platform server, BlockVector3 position, BlockType blockType, double priority)
      Description copied from interface: World
      Queue a block break effect.
      Specified by:
      queueBlockBreakEffect in interface World
      Parameters:
      server - the server
      position - the position
      blockType - the block type
      priority - the priority
      Returns:
      true if the effect was played
    • getMinimumPoint

      default BlockVector3 getMinimumPoint()
      Description copied from interface: Extent
      Get the minimum point in the extent.

      If the extent is unbounded, then a large (negative) value may be returned.

      Specified by:
      getMinimumPoint in interface Extent
      Returns:
      the minimum point
    • getMaximumPoint

      default BlockVector3 getMaximumPoint()
      Description copied from interface: Extent
      Get the maximum point in the extent.

      If the extent is unbounded, then a large (positive) value may be returned.

      Specified by:
      getMaximumPoint in interface Extent
      Returns:
      the maximum point
    • generateTree

      default boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException
      Description copied from interface: World
      Generate a tree at the given position.
      Specified by:
      generateTree in interface World
      Parameters:
      type - the tree type
      editSession - the EditSession
      position - the position
      Returns:
      true if generation was successful
      Throws:
      MaxChangedBlocksException - thrown if too many blocks were changed
    • simulateBlockMine

      default void simulateBlockMine(BlockVector3 position)
      Description copied from interface: World
      Simulate a block being mined at the given position.
      Specified by:
      simulateBlockMine in interface World
      Parameters:
      position - the position
    • getWeather

      default WeatherType getWeather()
      Description copied from interface: World
      Gets the weather type of the world.
      Specified by:
      getWeather in interface World
      Returns:
      The weather
    • getRemainingWeatherDuration

      default long getRemainingWeatherDuration()
      Description copied from interface: World
      Gets the remaining weather duration.
      Specified by:
      getRemainingWeatherDuration in interface World
      Returns:
      The weather duration
    • setWeather

      default void setWeather(WeatherType weatherType)
      Description copied from interface: World
      Sets the weather type of the world.
      Specified by:
      setWeather in interface World
      Parameters:
      weatherType - The weather type
    • setWeather

      default void setWeather(WeatherType weatherType, long duration)
      Description copied from interface: World
      Sets the weather type of the world.
      Specified by:
      setWeather in interface World
      Parameters:
      weatherType - The weather type
      duration - The duration of the weather