Class AbstractWorld

java.lang.Object
com.sk89q.worldedit.world.AbstractWorld
All Implemented Interfaces:
Extent, InputExtent, OutputExtent, Keyed, World
Direct Known Subclasses:
NullWorld

public abstract class AbstractWorld extends Object implements World
An abstract implementation of World.
  • Constructor Details

    • AbstractWorld

      public AbstractWorld()
  • Method Details

    • useItem

      public 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

      public final <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

      public 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
    • getMinY

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

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

      public 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

      public 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

      public 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

      public 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
    • sendBiomeUpdates

      public void sendBiomeUpdates(Iterable<BlockVector2> chunks)
      Description copied from interface: World
      Sends biome updates for the given chunks.

      This doesn't modify biomes at all, it just sends the current state of the biomes in the world to all of the nearby players, updating the visual representation of the biomes on their clients.

      Specified by:
      sendBiomeUpdates in interface World
      Parameters:
      chunks - a list of chunk coordinates to send biome updates for
    • fixLighting

      public 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

      public boolean playEffect(Vector3 position, int type, int data)
      Description copied from interface: World
      Play the given effect.
      Specified by:
      playEffect in interface World
      Parameters:
      position - the position
      type - the effect type
      data - the effect data
      Returns:
      true if the effect was played
    • queueBlockBreakEffect

      public 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

      public 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

      public 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
    • commit

      @Nullable public Operation commit()
      Description copied from interface: OutputExtent
      Return an Operation that should be called to tie up loose ends (such as to commit changes in a buffer).
      Specified by:
      commit in interface OutputExtent
      Returns:
      an operation or null if there is none to execute
    • getWeather

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

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

      public 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

      public 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