Class NullExtent

All Implemented Interfaces:
IBatchProcessor, Extent, InputExtent, OutputExtent, Serializable

public class NullExtent extends FaweRegionExtent implements IBatchProcessor
See Also:
  • Constructor Details

    • NullExtent

      public NullExtent(Extent extent, com.sk89q.worldedit.util.formatting.text.Component failReason)
      Create a new instance.
      Parameters:
      extent - the extent
    • NullExtent

      public NullExtent(Extent extent, FaweException exception)
    • NullExtent

      public NullExtent()
  • Method Details

    • 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
      Overrides:
      getMinimumPoint in class AbstractDelegateExtent
      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
      Overrides:
      getMaximumPoint in class AbstractDelegateExtent
      Returns:
      the maximum point
    • 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.

      Specified by:
      getEntities in interface Extent
      Overrides:
      getEntities in class AbstractDelegateExtent
      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.

      Specified by:
      getEntities in interface Extent
      Overrides:
      getEntities in class AbstractDelegateExtent
      Returns:
      a list of entities
    • createEntity

      @Nullable public Entity createEntity(Location arg0, BaseEntity arg1)
      Description copied from interface: Extent
      Create an entity at the given location.
      Specified by:
      createEntity in interface Extent
      Overrides:
      createEntity in class FaweRegionExtent
      Parameters:
      arg0 - the location
      arg1 - the entity
      Returns:
      a reference to the created entity, or null if the entity could not be created
    • 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.

      Specified by:
      getBlock in interface InputExtent
      Overrides:
      getBlock in class FaweRegionExtent
      Parameters:
      position - position of the block
      Returns:
      the block
    • getBlock

      public BlockState getBlock(int x, int y, int z)
      Specified by:
      getBlock in interface InputExtent
      Overrides:
      getBlock in class AbstractDelegateExtent
    • getFullBlock

      public 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
      Overrides:
      getFullBlock in class FaweRegionExtent
      Parameters:
      position - position of the block
      Returns:
      the block
    • getFullBlock

      public BaseBlock getFullBlock(int x, int y, int z)
      Specified by:
      getFullBlock in interface InputExtent
      Overrides:
      getFullBlock in class AbstractDelegateExtent
    • 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.

      Specified by:
      getBiome in interface InputExtent
      Overrides:
      getBiome in class FaweRegionExtent
      Parameters:
      position - the (x, y, z) location to check the biome at
      Returns:
      the biome at the location
      See Also:
    • getBiomeType

      public BiomeType getBiomeType(int x, int y, int z)
      Specified by:
      getBiomeType in interface InputExtent
      Overrides:
      getBiomeType in class FaweRegionExtent
    • setBlock

      public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, 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
      Overrides:
      setBlock in class AbstractDelegateExtent
      Parameters:
      position - 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
    • setBlock

      public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException
      Specified by:
      setBlock in interface OutputExtent
      Overrides:
      setBlock in class FaweRegionExtent
      Throws:
      WorldEditException
    • setExtent

      public ResettableExtent setExtent(Extent extent)
      Overrides:
      setExtent in class ResettableExtent
    • setTile

      public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException
      Specified by:
      setTile in interface OutputExtent
      Overrides:
      setTile in class AbstractDelegateExtent
      Throws:
      WorldEditException
    • 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.

      Specified by:
      setBiome in interface OutputExtent
      Overrides:
      setBiome in class AbstractDelegateExtent
      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)
    • setBiome

      public boolean setBiome(int x, int y, int z, BiomeType biome)
      Specified by:
      setBiome in interface OutputExtent
      Overrides:
      setBiome in class FaweRegionExtent
    • isQueueEnabled

      public boolean isQueueEnabled()
      Specified by:
      isQueueEnabled in interface Extent
      Overrides:
      isQueueEnabled in class AbstractDelegateExtent
    • enableQueue

      public void enableQueue()
      Specified by:
      enableQueue in interface Extent
      Overrides:
      enableQueue in class AbstractDelegateExtent
    • disableQueue

      public void disableQueue()
      Specified by:
      disableQueue in interface Extent
      Overrides:
      disableQueue in class AbstractDelegateExtent
    • isWorld

      public boolean isWorld()
      Specified by:
      isWorld in interface Extent
    • regenerateChunk

      public boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed)
      Specified by:
      regenerateChunk in interface Extent
    • getHighestTerrainBlock

      public int getHighestTerrainBlock(int x, int z, int minY, int maxY)
      Description copied from interface: Extent
      Returns the highest solid 'terrain' block.
      Specified by:
      getHighestTerrainBlock in interface Extent
      Parameters:
      x - the X coordinate
      z - the Z coordinate
      minY - minimal height
      maxY - maximal height
      Returns:
      height of highest block found or 'minY'
    • getHighestTerrainBlock

      public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter)
      Description copied from interface: Extent
      Returns the highest solid 'terrain' block.
      Specified by:
      getHighestTerrainBlock in interface Extent
      Parameters:
      x - the X coordinate
      z - the Z coordinate
      minY - minimal height
      maxY - maximal height
      filter - a mask of blocks to consider, or null to consider any solid (movement-blocking) block
      Returns:
      height of highest block found or 'minY'
    • contains

      public boolean contains(int x, int z)
      Specified by:
      contains in class FaweRegionExtent
    • contains

      public boolean contains(int x, int y, int z)
      Description copied from interface: Extent
      Returns true if the extent contains the given position
      Specified by:
      contains in interface Extent
      Specified by:
      contains in class FaweRegionExtent
      Parameters:
      x - position x
      y - position y
      z - position z
      Returns:
      if position is contained
    • getRegions

      public Collection<Region> getRegions()
      Specified by:
      getRegions in class FaweRegionExtent
    • 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 Extent
      Specified by:
      commit in interface OutputExtent
      Overrides:
      commit in class AbstractDelegateExtent
      Returns:
      an operation or null if there is none to execute
    • cancel

      public boolean cancel()
      Specified by:
      cancel in interface Extent
      Overrides:
      cancel in class AbstractDelegateExtent
    • getMaxY

      public int getMaxY()
      Specified by:
      getMaxY in interface Extent
      Overrides:
      getMaxY in class AbstractDelegateExtent
    • getMinY

      public int getMinY()
      Specified by:
      getMinY in interface Extent
      Overrides:
      getMinY in class AbstractDelegateExtent
    • lazyCopy

      public BlockArrayClipboard lazyCopy(Region region)
      Description copied from interface: Extent
      Lazily copy a region
      Specified by:
      lazyCopy in interface Extent
      Returns:
    • countBlocks

      public int countBlocks(Region region, Set<BaseBlock> searchBlocks)
      Description copied from interface: Extent
      Count the number of blocks of a list of types in a region.
      Specified by:
      countBlocks in interface Extent
      Parameters:
      region - the region
      searchBlocks - the list of blocks to search
      Returns:
      the number of blocks that matched the block
    • countBlocks

      public int countBlocks(Region region, Mask searchMask)
      Description copied from interface: Extent
      Count the number of blocks of a list of types in a region.
      Specified by:
      countBlocks in interface Extent
      Parameters:
      region - the region
      searchMask - mask to match
      Returns:
      the number of blocks that matched the mask
    • setBlocks

      public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException
      Description copied from interface: Extent
      Sets all the blocks inside a region to a given block type.
      Specified by:
      setBlocks in interface Extent
      Parameters:
      region - the region
      block - the block
      Returns:
      number of blocks affected
      Throws:
      MaxChangedBlocksException - thrown if too many blocks are changed
    • setBlocks

      public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException
      Description copied from interface: Extent
      Sets all the blocks inside a region to a given pattern.
      Specified by:
      setBlocks in interface Extent
      Parameters:
      region - the region
      pattern - the pattern that provides the replacement block
      Returns:
      number of blocks affected
      Throws:
      MaxChangedBlocksException - thrown if too many blocks are changed
    • replaceBlocks

      public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException
      Description copied from interface: Extent
      Replaces all the blocks matching a given filter, within a given region, to a block returned by a given pattern.
      Specified by:
      replaceBlocks in interface Extent
      Parameters:
      region - the region to replace the blocks within
      filter - a list of block types to match, or null to use ExistingBlockMask
      replacement - the replacement block
      Returns:
      number of blocks affected
      Throws:
      MaxChangedBlocksException - thrown if too many blocks are changed
    • replaceBlocks

      public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException
      Description copied from interface: Extent
      Replaces all the blocks matching a given filter, within a given region, to a block returned by a given pattern.
      Specified by:
      replaceBlocks in interface Extent
      Parameters:
      region - the region to replace the blocks within
      filter - a list of block types to match, or null to use ExistingBlockMask
      pattern - the pattern that provides the new blocks
      Returns:
      number of blocks affected
      Throws:
      MaxChangedBlocksException - thrown if too many blocks are changed
    • replaceBlocks

      public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException
      Description copied from interface: Extent
      Replaces all the blocks matching a given mask, within a given region, to a block returned by a given pattern.
      Specified by:
      replaceBlocks in interface Extent
      Parameters:
      region - the region to replace the blocks within
      mask - the mask that blocks must match
      pattern - the pattern that provides the new blocks
      Returns:
      number of blocks affected
      Throws:
      MaxChangedBlocksException - thrown if too many blocks are changed
    • center

      public int center(Region region, Pattern pattern) throws MaxChangedBlocksException
      Description copied from interface: Extent
      Sets the blocks at the center of the given region to the given pattern. If the center sits between two blocks on a certain axis, then two blocks will be placed to mark the center.
      Specified by:
      center in interface Extent
      Parameters:
      region - the region to find the center of
      pattern - the replacement pattern
      Returns:
      the number of blocks placed
      Throws:
      MaxChangedBlocksException - thrown if too many blocks are changed
    • setBlocks

      public int setBlocks(Set<BlockVector3> vset, Pattern pattern)
      Specified by:
      setBlocks in interface Extent
    • getNearestSurfaceLayer

      public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY)
      Description copied from interface: Extent
      Returns the nearest surface layer (up/down from start)

      TODO: Someone understand this..?

      Specified by:
      getNearestSurfaceLayer in interface Extent
      Parameters:
      x - x to search from
      z - y to search from
      y - z to search from
      minY - min y to search (inclusive)
      maxY - max y to search (inclusive)
      Returns:
      nearest surface layer
    • getNearestSurfaceTerrainBlock

      public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask)
      Description copied from interface: Extent
      Gets y value for the nearest block that is considered the surface of the terrain (cave roof/floor, mountain surface, etc) where the block conforms to a given mask. Searches in the x,z column given.
      Specified by:
      getNearestSurfaceTerrainBlock in interface Extent
      Parameters:
      x - column x
      z - column z
      y - start y
      minY - minimum y height to consider. Inclusive.
      maxY - maximum y height to consider. Inclusive.
      failedMin - if nothing found, the minimum y value to return if returning min
      failedMax - if nothing found, the maximum y value to return if returning max
      mask - mask to test blocks against
      Returns:
      The y value of the nearest terrain block
    • getNearestSurfaceTerrainBlock

      public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir)
      Description copied from interface: Extent
      Gets y value for the nearest block that is considered the surface of the terrain (cave roof/floor, mountain surface, etc). Searches in the x,z column given.
      Specified by:
      getNearestSurfaceTerrainBlock in interface Extent
      Parameters:
      x - column x
      z - column z
      y - start y
      minY - minimum y height to consider. Inclusive.
      maxY - maximum y height to consider. Inclusive.
      failedMin - if nothing found, the minimum y value to return if returning min
      failedMax - if nothing found, the maximum y value to return if returning max
      ignoreAir - if air at the final value if no block found should be considered for return, else return -1
      Returns:
      The y value of the nearest terrain block
    • addCaves

      public void addCaves(Region region) throws WorldEditException
      Specified by:
      addCaves in interface Extent
      Throws:
      WorldEditException
    • generate

      public void generate(Region region, GenBase gen) throws WorldEditException
      Specified by:
      generate in interface Extent
      Throws:
      WorldEditException
    • addSchems

      public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException
      Specified by:
      addSchems in interface Extent
      Throws:
      WorldEditException
    • spawnResource

      public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException
      Specified by:
      spawnResource in interface Extent
      Throws:
      WorldEditException
    • addOre

      public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException
      Specified by:
      addOre in interface Extent
      Throws:
      WorldEditException
    • addOres

      public void addOres(Region region, Mask mask) throws WorldEditException
      Specified by:
      addOres in interface Extent
      Throws:
      WorldEditException
    • getBlockDistribution

      public List<Countable<BlockType>> getBlockDistribution(Region region)
      Description copied from interface: Extent
      Get the block distribution inside a region.
      Specified by:
      getBlockDistribution in interface Extent
      Parameters:
      region - a region
      Returns:
      the results
    • getBlockDistributionWithData

      public List<Countable<BlockState>> getBlockDistributionWithData(Region region)
      Description copied from interface: Extent
      Get the block distribution (with data values) inside a region.
      Specified by:
      getBlockDistributionWithData in interface Extent
      Parameters:
      region - a region
      Returns:
      the results
    • processSet

      public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set)
      Description copied from interface: IBatchProcessor
      Process a chunk that has been set.
      Specified by:
      processSet in interface IBatchProcessor
    • postProcessSet

      public Future<?> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set)
      Description copied from interface: IBatchProcessor
      Post-process a chunk that has been edited. Set should NOT be modified here, changes will NOT be flushed to the world, but MAY be flushed to history. Defaults to nothing as most Processors will not use it. Post-processors that are not technically blocking should override this method to allow post-processors to become blocking if required.
      Specified by:
      postProcessSet in interface IBatchProcessor
    • postProcess

      public void postProcess(IChunk chunk, IChunkGet get, IChunkSet set)
      Description copied from interface: IBatchProcessor
      Post-process a chunk that has been edited. Set should NOT be modified here, changes will NOT be flushed to the world, but MAY be flushed to history. Defaults to nothing as most Processors will not use it. If the post-processor will run tasks asynchronously/not be blocking, use IBatchProcessor.postProcessSet(com.fastasyncworldedit.core.queue.IChunk, com.fastasyncworldedit.core.queue.IChunkGet, com.fastasyncworldedit.core.queue.IChunkSet) to return a Future.
      Specified by:
      postProcess in interface IBatchProcessor
    • processGet

      public boolean processGet(int chunkX, int chunkZ)
      Specified by:
      processGet in interface IBatchProcessor
    • construct

      public Extent construct(Extent child)
      Description copied from interface: IBatchProcessor
      Convert this processor into an Extent based processor instead of a queue batch based on.
      Specified by:
      construct in interface IBatchProcessor
      Overrides:
      construct in class FaweRegionExtent
    • getScope

      public ProcessorScope getScope()
      Description copied from interface: IBatchProcessor
      Default to CUSTOM ProcessorScope as we want custom processors people add to be before we write history, but after FAWE does it's own stuff.
      Specified by:
      getScope in interface IBatchProcessor
      Overrides:
      getScope in class FaweRegionExtent