Class LimitExtent

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

public class LimitExtent extends AbstractDelegateExtent
  • Constructor Details

    • LimitExtent

      public LimitExtent(Extent extent, FaweLimit limit)
      Create a new instance.
      Parameters:
      extent - the extent
  • 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
    • 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)
    • getHighestTerrainBlock

      public int getHighestTerrainBlock(int x, int z, int minY, int maxY)
      Description copied from interface: Extent
      Returns the highest solid 'terrain' block.
      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.
      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)

      TODO: Someone understand this..?

      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.
      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.
      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.
      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.
      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.
      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
      Throws:
      WorldEditException
    • generate

      public void generate(Region region, GenBase gen) throws WorldEditException
      Throws:
      WorldEditException
    • addSchems

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

      public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException
      Throws:
      WorldEditException
    • addOre

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

      public void addOres(Region region, Mask mask) throws WorldEditException
      Throws:
      WorldEditException
    • getBlockDistribution

      public List<Countable<BlockType>> getBlockDistribution(Region region)
      Description copied from interface: Extent
      Get the block distribution inside a region.
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      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)
    • apply

      public <T extends Filter> T apply(Region region, T filter, boolean full)
    • apply

      public <T extends Filter> T apply(Iterable<BlockVector3> positions, T filter)
    • 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
      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 AbstractDelegateExtent