Class LimitExtent

java.lang.Object
com.sk89q.worldedit.extent.AbstractDelegateExtent
com.fastasyncworldedit.core.extent.LimitExtent
All Implemented Interfaces:
IBatchProcessor, Extent, InputExtent, OutputExtent

public class LimitExtent extends AbstractDelegateExtent implements IBatchProcessor
  • Constructor Details

    • LimitExtent

      @Deprecated(forRemoval=true, since="2.12.0") public LimitExtent(Extent extent, FaweLimit limit)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a new instance.
      Parameters:
      extent - the extent
      limit - the limit
    • LimitExtent

      @Deprecated(forRemoval=true, since="2.12.0") public LimitExtent(Extent extent, FaweLimit limit, Consumer<com.sk89q.worldedit.util.formatting.text.Component> onErrorMessage)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a new instance.
      Parameters:
      extent - the extent
      limit - the limit
      onErrorMessage - consumer to handle a component generated by exceptions
    • LimitExtent

      public LimitExtent(Extent extent, FaweLimit limit, Consumer<com.sk89q.worldedit.util.formatting.text.Component> onErrorMessage, boolean processing)
      Create a new instance.
      Parameters:
      extent - the extent
      limit - the limit
      onErrorMessage - consumer to handle a component generated by exceptions
      processing - if this limit extent is expected to be processing
      Since:
      2.12.0
  • Method Details

    • getEntities

      public List<? extends 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<? extends 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 location, BaseEntity entity)
      Description copied from interface: Extent
      Create an entity at the given location.
      Specified by:
      createEntity in interface Extent
      Overrides:
      createEntity in class AbstractDelegateExtent
      Parameters:
      location - the location
      entity - the entity
      Returns:
      a reference to the created entity, or null if the entity could not be created
    • createEntity

      @Nullable public Entity createEntity(Location location, BaseEntity entity, UUID uuid)
      Description copied from interface: Extent
      Create an entity at the given location, forcing a UUID onto the entity Only use if you are aware of the consequences of forcing a UUID to an entity.
      Specified by:
      createEntity in interface Extent
      Overrides:
      createEntity in class AbstractDelegateExtent
      Parameters:
      location - the location
      entity - the entity
      uuid - UUID to force the entity to have
      Returns:
      a reference to the created entity, or null if the entity could not be created
    • removeEntity

      public void removeEntity(int x, int y, int z, UUID uuid)
      Description copied from interface: Extent
      Create an entity at the given location.
      Specified by:
      removeEntity in interface Extent
      Overrides:
      removeEntity in class AbstractDelegateExtent
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      uuid - the unique identifier of the entity
    • 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' (movement-blocking) 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 block matching the given mask.
      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'
    • 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), where a layer is 1/16th of a block to allow for snow, liquid, etc.
      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, 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.
      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
    • getNearestSurfaceTerrainBlock

      public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY)
      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.
      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)
      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
      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, 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
    • 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
      Overrides:
      getBlockDistribution in class AbstractDelegateExtent
      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
      Overrides:
      getBlockDistributionWithData in class AbstractDelegateExtent
      Parameters:
      region - a region
      Returns:
      the results
    • 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
      Overrides:
      countBlocks in class AbstractDelegateExtent
      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
      Overrides:
      countBlocks in class AbstractDelegateExtent
      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
      Overrides:
      setBlocks in class AbstractDelegateExtent
      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
      Overrides:
      setBlocks in class AbstractDelegateExtent
      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
      Overrides:
      replaceBlocks in class AbstractDelegateExtent
      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
      Overrides:
      replaceBlocks in class AbstractDelegateExtent
      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
      Overrides:
      replaceBlocks in class AbstractDelegateExtent
      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
    • setBlocks

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

      public <T extends Filter> T apply(Region region, T filter, boolean full)
      Specified by:
      apply in interface Extent
      Overrides:
      apply in class AbstractDelegateExtent
    • apply

      public <T extends Filter> T apply(Iterable<BlockVector3> positions, T filter)
      Specified by:
      apply in interface Extent
    • 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 AbstractDelegateExtent
      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 AbstractDelegateExtent
      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 AbstractDelegateExtent
      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 AbstractDelegateExtent
    • setBlock

      @Deprecated public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException
      Deprecated.
      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 AbstractDelegateExtent
      Throws:
      WorldEditException
    • setTile

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

      public void setProcessing(boolean processing)
    • 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
    • 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 one.
      Specified by:
      construct in interface IBatchProcessor
    • 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