Class NullWorld

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

public class NullWorld extends AbstractWorld
A null implementation of World that drops all changes and returns dummy data.
  • Constructor Details

    • NullWorld

      protected NullWorld()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: World
      Get the name of the world.
      Returns:
      a name for the world
    • getId

      public String getId()
      Description copied from interface: Keyed
      The id of this object in the registry. Must be unique, and lowercase. Certain registries (e.g Namespaced ones) may have additional restrictions.
      Returns:
      an id
    • setBlock

      public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, SideEffectSet sideEffects) throws WorldEditException
      Description copied from interface: World
      Similar to OutputExtent.setBlock(BlockVector3, BlockStateHolder) but a sideEffects parameter indicates which side effects should be applied to the block. This includes block updates, lighting, and others. See SideEffect for a full list.

      Not all implementations support all side effects. Use Platform.getSupportedSideEffects() for a list of supported side effects. Non-supported side effects will be ignored.

      Parameters:
      position - position of the block
      block - block to set
      sideEffects - which side effects to perform
      Returns:
      true if the block was successfully set (return value may not be accurate)
      Throws:
      WorldEditException
    • applySideEffects

      public Set<SideEffect> applySideEffects(BlockVector3 position, BlockState previousType, SideEffectSet sideEffectSet) throws WorldEditException
      Description copied from interface: World
      Applies a set of side effects on the given block.
      Parameters:
      position - position of the block
      previousType - the type of the previous block that was there
      sideEffectSet - which side effects to perform
      Returns:
      a set of side effects that were applied
      Throws:
      WorldEditException
    • getBlockLightLevel

      public int getBlockLightLevel(BlockVector3 position)
      Description copied from interface: World
      Get the light level at the given block.
      Parameters:
      position - the position
      Returns:
      the light level (0-15)
    • clearContainerBlockContents

      public boolean clearContainerBlockContents(BlockVector3 position)
      Description copied from interface: World
      Clear a chest's contents.
      Parameters:
      position - the position
      Returns:
      true if the container was cleared
    • fullySupports3DBiomes

      public boolean fullySupports3DBiomes()
      Description copied from interface: OutputExtent
      Check if this extent fully supports 3D biomes.

      If false, the extent only visually reads biomes from y = 0. The biomes will still be set in 3D, but the client will only see the one at y = 0. It is up to the caller to determine if they want to set that biome instead, or simply warn the actor.

      Returns:
      if the extent fully supports 3D biomes
    • getBiome

      public BiomeType getBiome(BlockVector3 position)
      Description copied from interface: InputExtent
      Get the biome at the given location.

      If there is no biome available, then the ocean biome should be returned.

      As implementation varies per Minecraft version, this may not exactly get this positions biome. On versions prior to 1.15, this will get the entire column. On later versions it will get the 4x4x4 cube's biome.

      Parameters:
      position - the (x, y, z) location to check the biome at
      Returns:
      the biome at the location
    • setBiome

      public boolean setBiome(BlockVector3 position, BiomeType biome)
      Description copied from interface: OutputExtent
      Set the biome.

      As implementation varies per Minecraft version, this may set more than this position's biome. On versions prior to 1.15, this will set the entire column. On later versions it will set the 4x4x4 cube.

      Parameters:
      position - the (x, y, z) location to set the biome at
      biome - the biome to set to
      Returns:
      true if the biome was successfully set (return value may not be accurate)
    • dropItem

      public void dropItem(Vector3 position, BaseItemStack item)
      Description copied from interface: World
      Drop one stack of the item at the given position.
      Parameters:
      position - the position
      item - the item to drop
      See Also:
    • simulateBlockMine

      public void simulateBlockMine(BlockVector3 position)
      Description copied from interface: World
      Simulate a block being mined at the given position.
      Parameters:
      position - the position
    • regenerate

      public boolean regenerate(Region region, Extent extent, RegenOptions options)
      Description copied from interface: World
      Regenerate an area.
      Parameters:
      region - the region
      extent - the Extent
      options - the regeneration options
      Returns:
      true if regeneration was successful
    • generateTree

      public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException
      Description copied from interface: World
      Generate a tree at the given position.
      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
    • getWeather

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

      public long getRemainingWeatherDuration()
      Description copied from interface: World
      Gets the remaining weather duration.
      Specified by:
      getRemainingWeatherDuration in interface World
      Overrides:
      getRemainingWeatherDuration in class AbstractWorld
      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
      Overrides:
      setWeather in class AbstractWorld
      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
      Overrides:
      setWeather in class AbstractWorld
      Parameters:
      weatherType - The weather type
      duration - The duration of the weather
    • getSpawnPosition

      public BlockVector3 getSpawnPosition()
      Description copied from interface: World
      Gets the spawn position of this world.
      Returns:
      The spawn position
    • getBlock

      public BlockState getBlock(BlockVector3 position)
      Description copied from interface: InputExtent
      Get a snapshot of the block at the given location.

      If the given position is out of the bounds of the extent, then the behavior is undefined (an air block could be returned). However, null should not be returned.

      The returned block is immutable and is a snapshot of the block at the time of call. It has no position attached to it, so it could be reused in Patterns and so on.

      Parameters:
      position - position of the block
      Returns:
      the block
    • getFullBlock

      public BaseBlock getFullBlock(BlockVector3 position)
      Description copied from interface: InputExtent
      Get a immutable snapshot of the block at the given location.
      Parameters:
      position - position of the block
      Returns:
      the block
    • getEntities

      public List<Entity> getEntities(Region region)
      Description copied from interface: Extent
      Get a list of all entities within the given region.

      If the extent is not wholly loaded (i.e. a world being simulated in the game will not have every chunk loaded), then this list may not be incomplete.

      Parameters:
      region - the region in which entities must be contained
      Returns:
      a list of entities
    • getEntities

      public List<Entity> getEntities()
      Description copied from interface: Extent
      Get a list of all entities.

      If the extent is not wholly loaded (i.e. a world being simulated in the game will not have every chunk loaded), then this list may not be incomplete.

      Returns:
      a list of entities
    • createEntity

      @Nullable public Entity createEntity(Location location, BaseEntity entity)
      Description copied from interface: Extent
      Create an entity at the given location.
      Parameters:
      location - the location
      entity - the entity
      Returns:
      a reference to the created entity, or null if the entity could not be created
    • getInstance

      public static NullWorld getInstance()
      Return an instance of this null world.
      Returns:
      a null world