Class EditSession
- All Implemented Interfaces:
Extent
,InputExtent
,OutputExtent
,AutoCloseable
Extent
that handles history, BlockBag
s, change limits,
block re-ordering, and much more. Most operations in WorldEdit use this class.
Most of the actual functionality is implemented with a number of other
Extent
s that are chained together. For example, history is logged
using the ChangeSetExtent
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Reorder mode forsetReorderMode(ReorderMode)
.static enum
Used bysetBlock(BlockVector3, BlockStateHolder, Stage)
to determine whichExtent
s should be bypassed. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Sets the blocks at the center of the given region to the given pattern.void
close()
Closing an EditSession flushes its buffers to the world, and performs other cleanup tasks.commit()
Return anOperation
that should be called to tie up loose ends (such as to commit changes in a buffer).int
countBlocks
(Region region, Mask searchMask) Count the number of blocks of a list of types in a region.int
countBlocks
(Region region, Set<BaseBlock> searchBlocks) Count the number of blocks of a list of types in a region.createEntity
(Location location, BaseEntity entity) Create an entity at the given location.int
deformRegion
(Region region, Vector3 zero, Vector3 unit, Expression expression, int timeout) Internal version ofdeformRegion(Region, Vector3, Vector3, String, int)
.int
deformRegion
(Region region, Vector3 zero, Vector3 unit, String expressionString) Deforms the region by a given expression.int
deformRegion
(Region region, Vector3 zero, Vector3 unit, String expressionString, int timeout) Deforms the region by a given expression.void
Disable all buffering extents.void
Deprecated.int
drainArea
(BlockVector3 origin, double radius) Drain nearby pools of water or lava.int
drainArea
(BlockVector3 origin, double radius, boolean waterlogged) Drain nearby pools of water or lava, optionally removed waterlogged states from blocks.int
drawLine
(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled) Draws a line (out of blocks) between two vectors.int
drawLine
(Pattern pattern, List<BlockVector3> vectors, double radius, boolean filled) Draws a line (out of blocks) between two or more vectors.int
drawSpline
(Pattern pattern, List<BlockVector3> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled) Draws a spline (out of blocks) between specified vectors.void
Deprecated.UsesetReorderMode(ReorderMode)
with MULTI_STAGE instead.void
Turns on specific features for a normal WorldEdit session, such aschunk batching
.<B extends BlockStateHolder<B>>
intfillXZ
(BlockVector3 origin, B block, double radius, int depth, boolean recursive) Fills an area recursively in the X/Z directions.int
fillXZ
(BlockVector3 origin, Pattern pattern, double radius, int depth, boolean recursive) Fills an area recursively in the X/Z directions.int
fixLiquid
(BlockVector3 origin, double radius, BlockType fluid) Fix liquids so that they turn into stationary blocks and extend outward.void
Deprecated.Replace withclose()
for proper cleanup behavior.boolean
Check if this extent fully supports 3D biomes.getBiome
(BlockVector3 position) Get the biome at the given location.getBlock
(BlockVector3 position) Get a snapshot of the block at the given location.Get theBlockBag
is used.int
Get the number of blocks changed, including repeated block changes.int
Get the maximum number of blocks that can be changed.getBlockDistribution
(Region region, boolean separateStates) Get the block distribution inside a region.Get the underlyingChangeSet
.Get a list of all entities.getEntities
(Region region) Get a list of all entities within the given region.getFullBlock
(BlockVector3 position) Get a immutable snapshot of the block at the given location.int
getHighestTerrainBlock
(int x, int z, int minY, int maxY) Returns the highest solid 'terrain' block.int
getHighestTerrainBlock
(int x, int z, int minY, int maxY, Mask filter) Returns the highest solid 'terrain' block.getMask()
Get the mask.Get the maximum point in the extent.Get the minimum point in the extent.Get the reorder mode.Get theSurvivalModeExtent
.getWorld()
Get the world.int
green
(BlockVector3 position, double radius, boolean onlyNormalDirt) Deprecated.int
green
(BlockVector3 position, double radius, int height, boolean onlyNormalDirt) Make dirt green in a cylinder.boolean
Deprecated.int
hollowOutRegion
(Region region, int thickness, Pattern pattern) Hollows out the region (Semi-well-defined for non-cuboid selections).boolean
Returns chunk batching status.boolean
Deprecated.UsegetReorderMode()
with MULTI_STAGE instead.boolean
Check if this session will tick the watchdog.int
makeBiomeShape
(Region region, Vector3 zero, Vector3 unit, BiomeType biomeType, String expressionString, boolean hollow) int
makeBiomeShape
(Region region, Vector3 zero, Vector3 unit, BiomeType biomeType, String expressionString, boolean hollow, int timeout) <B extends BlockStateHolder<B>>
intmakeCuboidFaces
(Region region, B block) Deprecated.int
makeCuboidFaces
(Region region, Pattern pattern) Make the faces of the given region as if it was aCuboidRegion
.<B extends BlockStateHolder<B>>
intmakeCuboidWalls
(Region region, B block) Make the walls (all faces but those parallel to the X-Z plane) of the given region as if it was aCuboidRegion
.int
makeCuboidWalls
(Region region, Pattern pattern) Make the walls (all faces but those parallel to the X-Z plane) of the given region as if it was aCuboidRegion
.int
makeCylinder
(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) Makes a cylinder.int
makeCylinder
(BlockVector3 pos, Pattern block, double radius, int height, boolean filled) Makes a cylinder.int
Make the faces of the given region.int
makeForest
(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) Makes a forest.int
makeForest
(Region region, double density, TreeGenerator.TreeType treeType) Makes a forest.int
makePumpkinPatches
(BlockVector3 position, int apothem) Makes pumpkin patches randomly in an area around the given position.int
makePyramid
(BlockVector3 position, Pattern block, int size, boolean filled) Makes a pyramid.int
makeShape
(Region region, Vector3 zero, Vector3 unit, Pattern pattern, Expression expression, boolean hollow, int timeout) Internal version ofmakeShape(Region, Vector3, Vector3, Pattern, String, boolean, int)
.int
makeShape
(Region region, Vector3 zero, Vector3 unit, Pattern pattern, String expressionString, boolean hollow) Generate a shape for the given expression.int
makeShape
(Region region, Vector3 zero, Vector3 unit, Pattern pattern, String expressionString, boolean hollow, int timeout) Generate a shape for the given expression.int
makeSphere
(BlockVector3 pos, Pattern block, double radius, boolean filled) Makes a sphere.int
makeSphere
(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) Makes a sphere or ellipsoid.int
Make the walls of the given region.int
moveCuboidRegion
(Region region, BlockVector3 dir, int distance, boolean copyAir, Pattern replacement) Move the blocks in a region a certain direction.int
moveRegion
(Region region, BlockVector3 offset, int multiplier, boolean moveEntities, boolean copyBiomes, Mask mask, Pattern replacement) Move the blocks in a region a certain direction.int
moveRegion
(Region region, BlockVector3 offset, int multiplier, boolean copyAir, Pattern replacement) Move the blocks in a region a certain direction.int
naturalizeCuboidBlocks
(Region region) Turns the first 3 layers into dirt/grass and the bottom layers into rock, like a natural Minecraft mountain.<B extends BlockStateHolder<B>>
intoverlayCuboidBlocks
(Region region, B block) Deprecated.int
overlayCuboidBlocks
(Region region, Pattern pattern) Places a layer of blocks on top of ground blocks in the given region (as if it were a cuboid).Gets the list of missing blocks and clears the list for the next operation.<B extends BlockStateHolder<B>>
booleanrawSetBlock
(BlockVector3 position, B block) Set a block, bypassing both history and block re-ordering.void
redo
(EditSession editSession) Sets to new state.int
removeAbove
(BlockVector3 position, int apothem, int height) Remove a cuboid above the given position with a given apothem and a given height.int
removeBelow
(BlockVector3 position, int apothem, int height) Remove a cuboid below the given position with a given apothem and a given height.int
removeNear
(BlockVector3 position, Mask mask, int apothem) Remove blocks of a certain type nearby a given position.int
replaceBlocks
(Region region, Mask mask, Pattern pattern) Replaces all the blocks matching a given mask, within a given region, to a block returned by a given pattern.<B extends BlockStateHolder<B>>
intreplaceBlocks
(Region region, Set<BaseBlock> filter, B replacement) Replaces all the blocks matching a given filter, within a given region, to a block returned by a given pattern.int
replaceBlocks
(Region region, Set<BaseBlock> filter, Pattern pattern) Replaces all the blocks matching a given filter, within a given region, to a block returned by a given pattern.void
setBatchingChunks
(boolean batchingChunks) Enable or disable chunk batching.boolean
setBiome
(BlockVector3 position, BiomeType biome) Set the biome.<B extends BlockStateHolder<B>>
booleansetBlock
(BlockVector3 position, B block) Change the block at the given location to the given block.<B extends BlockStateHolder<B>>
booleansetBlock
(BlockVector3 position, B block, EditSession.Stage stage) Set a block, bypassing both history and block re-ordering.boolean
setBlock
(BlockVector3 position, Pattern pattern) Sets the block at a position, subject to both history and block re-ordering.void
setBlockBag
(BlockBag blockBag) Set aBlockBag
to use.void
setBlockChangeLimit
(int limit) Set the maximum number of blocks that can be changed.<B extends BlockStateHolder<B>>
intSets all the blocks inside a region to a given block type.int
Sets all the blocks inside a region to a given pattern.void
setFastMode
(boolean enabled) Deprecated.void
Set a mask.void
setReorderMode
(EditSession.ReorderMode reorderMode) Sets theEditSession.ReorderMode
of this EditSession, and flushes the session.void
setSideEffectApplier
(SideEffectSet sideEffectSet) Set which block updates should occur.void
setTickingWatchdog
(boolean active) Set all watchdog extents to the given mode.int
simulateSnow
(BlockVector3 position, double radius) Deprecated.int
simulateSnow
(BlockVector3 position, double radius, int height) Make snow in a cylinder.int
simulateSnow
(FlatRegion region, boolean stack) Make snow in a region.int
size()
Get the number of changed blocks.<B extends BlockStateHolder<B>>
booleansmartSetBlock
(BlockVector3 position, B block) Set a block, bypassing history but still utilizing block re-ordering.int
stackCuboidRegion
(Region region, BlockVector3 dir, int count, boolean copyAir) Stack a cuboid region.int
stackCuboidRegion
(Region region, BlockVector3 offset, int count, boolean copyEntities, boolean copyBiomes, Mask mask) Stack a cuboid region.int
stackRegionBlockUnits
(Region region, BlockVector3 offset, int count, boolean copyEntities, boolean copyBiomes, Mask mask) Stack a region using block units.int
thaw
(BlockVector3 position, double radius) Deprecated.int
thaw
(BlockVector3 position, double radius, int height) Thaw blocks in a cylinder.void
undo
(EditSession editSession) Restores all blocks to their initial state.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.sk89q.worldedit.extent.InputExtent
getBiome
Methods inherited from interface com.sk89q.worldedit.extent.OutputExtent
setBiome
-
Field Details
-
world
-
-
Method Details
-
enableStandardMode
public void enableStandardMode()Turns on specific features for a normal WorldEdit session, such aschunk batching
. -
setReorderMode
Sets theEditSession.ReorderMode
of this EditSession, and flushes the session.- Parameters:
reorderMode
- The reorder mode
-
getReorderMode
Get the reorder mode.- Returns:
- the reorder mode
-
getWorld
Get the world.- Returns:
- the world
-
getChangeSet
Get the underlyingChangeSet
.- Returns:
- the change set
-
getBlockChangeLimit
public int getBlockChangeLimit()Get the maximum number of blocks that can be changed. -1 will be returned if it the limit disabled.- Returns:
- the limit (>= 0) or -1 for no limit
-
setBlockChangeLimit
public void setBlockChangeLimit(int limit) Set the maximum number of blocks that can be changed.- Parameters:
limit
- the limit (>= 0) or -1 for no limit
-
isQueueEnabled
Deprecated.UsegetReorderMode()
with MULTI_STAGE instead.Returns queue status.- Returns:
- whether the queue is enabled
-
enableQueue
Deprecated.UsesetReorderMode(ReorderMode)
with MULTI_STAGE instead.Queue certain types of block for better reproduction of those blocks. -
disableQueue
Deprecated.UsesetReorderMode(ReorderMode)
with another mode instead.Disable the queue. This will flush the session. -
getMask
Get the mask.- Returns:
- mask, may be null
-
setMask
Set a mask.- Parameters:
mask
- mask or null
-
getSurvivalExtent
Get theSurvivalModeExtent
.- Returns:
- the survival simulation extent
-
setFastMode
Deprecated.Set whether fast mode is enabled.Fast mode may skip lighting checks or adjacent block notification.
- Parameters:
enabled
- true to enable
-
setSideEffectApplier
Set which block updates should occur.- Parameters:
sideEffectSet
- side effects to enable
-
hasFastMode
Deprecated.Return fast mode status.Fast mode may skip lighting checks or adjacent block notification.
- Returns:
- true if enabled
-
getSideEffectApplier
-
getBlockBag
Get theBlockBag
is used.- Returns:
- a block bag or null
-
setBlockBag
Set aBlockBag
to use.- Parameters:
blockBag
- the block bag to set, or null to use none
-
popMissingBlocks
Gets the list of missing blocks and clears the list for the next operation.- Returns:
- a map of missing blocks
-
isBatchingChunks
public boolean isBatchingChunks()Returns chunk batching status.- Returns:
- whether chunk batching is enabled
-
setBatchingChunks
public void setBatchingChunks(boolean batchingChunks) Enable or disable chunk batching. Disabling will flush the session.- Parameters:
batchingChunks
-true
to enable,false
to disable
-
disableBuffering
public void disableBuffering()Disable all buffering extents. -
isTickingWatchdog
public boolean isTickingWatchdog()Check if this session will tick the watchdog.- Returns:
true
if any watchdog extent is enabled
-
setTickingWatchdog
public void setTickingWatchdog(boolean active) Set all watchdog extents to the given mode. -
getBlockChangeCount
public int getBlockChangeCount()Get the number of blocks changed, including repeated block changes.This number may not be accurate.
- Returns:
- the number of block changes
-
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 fromy = 0
. The biomes will still be set in 3D, but the client will only see the one aty = 0
. It is up to the caller to determine if they want to set that biome instead, or simply warn the actor.- Specified by:
fullySupports3DBiomes
in interfaceOutputExtent
- Returns:
- if the extent fully supports 3D biomes
-
getBiome
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 interfaceInputExtent
- Parameters:
position
- the (x, y, z) location to check the biome at- Returns:
- the biome at the location
-
setBiome
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 interfaceOutputExtent
- Parameters:
position
- the (x, y, z) location to set the biome atbiome
- the biome to set to- Returns:
- true if the biome was successfully set (return value may not be accurate)
-
getBlock
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
Pattern
s and so on.- Specified by:
getBlock
in interfaceInputExtent
- Parameters:
position
- position of the block- Returns:
- the block
-
getFullBlock
Description copied from interface:InputExtent
Get a immutable snapshot of the block at the given location.- Specified by:
getFullBlock
in interfaceInputExtent
- Parameters:
position
- position of the block- Returns:
- the block
-
getHighestTerrainBlock
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) Returns the highest solid 'terrain' block.- Parameters:
x
- the X coordinatez
- the Z coordinateminY
- minimal heightmaxY
- maximal height- Returns:
- height of highest block found or 'minY'
-
getHighestTerrainBlock
Returns the highest solid 'terrain' block.- Parameters:
x
- the X coordinatez
- the Z coordinateminY
- minimal heightmaxY
- maximal heightfilter
- a mask of blocks to consider, or null to consider any solid (movement-blocking) block- Returns:
- height of highest block found or 'minY'
-
setBlock
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, EditSession.Stage stage) throws WorldEditException Set a block, bypassing both history and block re-ordering.- Parameters:
position
- the position to set the block atblock
- the blockstage
- the level- Returns:
- whether the block changed
- Throws:
WorldEditException
- thrown on a set error
-
rawSetBlock
Set a block, bypassing both history and block re-ordering.- Parameters:
position
- the position to set the block atblock
- the block- Returns:
- whether the block changed
-
smartSetBlock
Set a block, bypassing history but still utilizing block re-ordering.- Parameters:
position
- the position to set the block atblock
- the block- Returns:
- whether the block changed
-
setBlock
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws MaxChangedBlocksException Description copied from interface:OutputExtent
Change the block at the given location to the given block. The operation may not tie the givenBlockStateHolder
to the world, so future changes to theBlockStateHolder
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 interfaceOutputExtent
- Parameters:
position
- position of the blockblock
- block to set- Returns:
- true if the block was successfully set (return value may not be accurate)
- Throws:
MaxChangedBlocksException
-
setBlock
Sets the block at a position, subject to both history and block re-ordering.- Parameters:
position
- the positionpattern
- a pattern to use- Returns:
- Whether the block changed -- not entirely dependable
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
createEntity
Description copied from interface:Extent
Create an entity at the given location.- Specified by:
createEntity
in interfaceExtent
- Parameters:
location
- the locationentity
- the entity- Returns:
- a reference to the created entity, or null if the entity could not be created
-
undo
Restores all blocks to their initial state.- Parameters:
editSession
- a newEditSession
to perform the undo in
-
redo
Sets to new state.- Parameters:
editSession
- a newEditSession
to perform the redo in
-
size
public int size()Get the number of changed blocks.- Returns:
- the number of changes
-
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 interfaceExtent
- Returns:
- the minimum point
-
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 interfaceExtent
- Returns:
- the maximum point
-
getEntities
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 interfaceExtent
- Parameters:
region
- the region in which entities must be contained- Returns:
- a list of entities
-
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 interfaceExtent
- Returns:
- a list of entities
-
close
public void close()Closing an EditSession flushes its buffers to the world, and performs other cleanup tasks.- Specified by:
close
in interfaceAutoCloseable
-
flushSession
Deprecated.Replace withclose()
for proper cleanup behavior.Communicate to the EditSession that all block changes are complete, and that it should apply them to the world. -
commit
Description copied from interface:OutputExtent
Return anOperation
that should be called to tie up loose ends (such as to commit changes in a buffer).- Specified by:
commit
in interfaceOutputExtent
- Returns:
- an operation or null if there is none to execute
-
countBlocks
Count the number of blocks of a list of types in a region.- Parameters:
region
- the regionsearchBlocks
- the list of blocks to search- Returns:
- the number of blocks that matched the block
-
countBlocks
Count the number of blocks of a list of types in a region.- Parameters:
region
- the regionsearchMask
- mask to match- Returns:
- the number of blocks that matched the mask
-
fillXZ
public <B extends BlockStateHolder<B>> int fillXZ(BlockVector3 origin, B block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException Fills an area recursively in the X/Z directions.- Parameters:
origin
- the location to start fromblock
- the block to fill withradius
- the radius of the spherical area to filldepth
- the maximum depth, starting from the originrecursive
- whether a breadth-first search should be performed- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
fillXZ
public int fillXZ(BlockVector3 origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException Fills an area recursively in the X/Z directions.- Parameters:
origin
- the origin to start the fill frompattern
- the pattern to fill withradius
- the radius of the spherical area to fill, with 0 as the smallest radiusdepth
- the maximum depth, starting from the origin, with 1 as the smallest depthrecursive
- whether a breadth-first search should be performed- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
removeAbove
public int removeAbove(BlockVector3 position, int apothem, int height) throws MaxChangedBlocksException Remove a cuboid above the given position with a given apothem and a given height.- Parameters:
position
- base positionapothem
- an apothem of the cuboid (on the XZ plane), where the minimum is 1height
- the height of the cuboid, where the minimum is 1- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
removeBelow
public int removeBelow(BlockVector3 position, int apothem, int height) throws MaxChangedBlocksException Remove a cuboid below the given position with a given apothem and a given height.- Parameters:
position
- base positionapothem
- an apothem of the cuboid (on the XZ plane), where the minimum is 1height
- the height of the cuboid, where the minimum is 1- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
removeNear
public int removeNear(BlockVector3 position, Mask mask, int apothem) throws MaxChangedBlocksException Remove blocks of a certain type nearby a given position.- Parameters:
position
- center position of cuboidmask
- the mask to matchapothem
- an apothem of the cuboid, where the minimum is 1- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
setBlocks
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException Sets all the blocks inside a region to a given block type.- Parameters:
region
- the regionblock
- the block- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
setBlocks
Sets all the blocks inside a region to a given pattern.- Parameters:
region
- the regionpattern
- 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 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 withinfilter
- a list of block types to match, or null to useExistingBlockMask
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 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 withinfilter
- a list of block types to match, or null to useExistingBlockMask
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 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 withinmask
- the mask that blocks must matchpattern
- the pattern that provides the new blocks- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
center
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 ofpattern
- the replacement pattern- Returns:
- the number of blocks placed
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeCuboidFaces
@Deprecated public <B extends BlockStateHolder<B>> int makeCuboidFaces(Region region, B block) throws MaxChangedBlocksException Deprecated.Make the faces of the given region as if it was aCuboidRegion
.- Parameters:
region
- the regionblock
- the block to place- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeCuboidFaces
Make the faces of the given region as if it was aCuboidRegion
.- Parameters:
region
- the regionpattern
- the pattern to place- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeFaces
Make the faces of the given region. The method by which the faces are found may be inefficient, because there may not be an efficient implementation supported for that specific shape.- Parameters:
region
- the regionpattern
- the pattern to place- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeCuboidWalls
public <B extends BlockStateHolder<B>> int makeCuboidWalls(Region region, B block) throws MaxChangedBlocksException Make the walls (all faces but those parallel to the X-Z plane) of the given region as if it was aCuboidRegion
.- Parameters:
region
- the regionblock
- the block to place- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeCuboidWalls
Make the walls (all faces but those parallel to the X-Z plane) of the given region as if it was aCuboidRegion
.- Parameters:
region
- the regionpattern
- the pattern to place- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeWalls
Make the walls of the given region. The method by which the walls are found may be inefficient, because there may not be an efficient implementation supported for that specific shape.- Parameters:
region
- the regionpattern
- the pattern to place- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
overlayCuboidBlocks
@Deprecated public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException Deprecated.Places a layer of blocks on top of ground blocks in the given region (as if it were a cuboid).- Parameters:
region
- the regionblock
- the placed block- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
overlayCuboidBlocks
Places a layer of blocks on top of ground blocks in the given region (as if it were a cuboid).- Parameters:
region
- the regionpattern
- the placed block pattern- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
naturalizeCuboidBlocks
Turns the first 3 layers into dirt/grass and the bottom layers into rock, like a natural Minecraft mountain.- Parameters:
region
- the region to affect- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
stackCuboidRegion
public int stackCuboidRegion(Region region, BlockVector3 dir, int count, boolean copyAir) throws MaxChangedBlocksException Stack a cuboid region. For compatibility, entities are copied by biomes are not. UsestackCuboidRegion(Region, BlockVector3, int, boolean, boolean, Mask)
to fine tune.- Parameters:
region
- the region to stackdir
- the direction to stackcount
- the number of times to stackcopyAir
- true to also copy air blocks- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
stackCuboidRegion
public int stackCuboidRegion(Region region, BlockVector3 offset, int count, boolean copyEntities, boolean copyBiomes, Mask mask) throws MaxChangedBlocksException Stack a cuboid region.- Parameters:
region
- the region to stackoffset
- how far to move the contents each stackcount
- the number of times to stackcopyEntities
- true to copy entitiescopyBiomes
- true to copy biomesmask
- source mask for the operation (only matching blocks are copied)- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
stackRegionBlockUnits
public int stackRegionBlockUnits(Region region, BlockVector3 offset, int count, boolean copyEntities, boolean copyBiomes, Mask mask) throws MaxChangedBlocksException, RegionOperationException Stack a region using block units.- Parameters:
region
- the region to stackoffset
- how far to move the contents each stack in block unitscount
- the number of times to stackcopyEntities
- true to copy entitiescopyBiomes
- true to copy biomesmask
- source mask for the operation (only matching blocks are copied)- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changedRegionOperationException
- thrown if the region operation is invalid
-
moveRegion
public int moveRegion(Region region, BlockVector3 offset, int multiplier, boolean copyAir, Pattern replacement) throws MaxChangedBlocksException Move the blocks in a region a certain direction.- Parameters:
region
- the region to moveoffset
- the offsetmultiplier
- the number to multiply the offset bycopyAir
- true to copy air blocksreplacement
- the replacement pattern to fill in after moving, or null to use air- Returns:
- number of blocks moved
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
moveRegion
public int moveRegion(Region region, BlockVector3 offset, int multiplier, boolean moveEntities, boolean copyBiomes, Mask mask, Pattern replacement) throws MaxChangedBlocksException Move the blocks in a region a certain direction.- Parameters:
region
- the region to moveoffset
- the offsetmultiplier
- the number to multiply the offset bymoveEntities
- true to move entitiescopyBiomes
- true to copy biomes (source biome is unchanged)mask
- source mask for the operation (only matching blocks are moved)replacement
- the replacement pattern to fill in after moving, or null to use air- Returns:
- number of blocks moved
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changedIllegalArgumentException
- thrown if the region is not a flat region, but copyBiomes is true
-
moveCuboidRegion
public int moveCuboidRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, Pattern replacement) throws MaxChangedBlocksException Move the blocks in a region a certain direction.- Parameters:
region
- the region to movedir
- the directiondistance
- the distance to movecopyAir
- true to copy air blocksreplacement
- the replacement pattern to fill in after moving, or null to use air- Returns:
- number of blocks moved
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
drainArea
Drain nearby pools of water or lava.- Parameters:
origin
- the origin to drain from, which will search a 3x3 arearadius
- the radius of the removal, where a value should be 0 or greater- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
drainArea
public int drainArea(BlockVector3 origin, double radius, boolean waterlogged) throws MaxChangedBlocksException Drain nearby pools of water or lava, optionally removed waterlogged states from blocks.- Parameters:
origin
- the origin to drain from, which will search a 3x3 arearadius
- the radius of the removal, where a value should be 0 or greaterwaterlogged
- true to make waterlogged blocks non-waterlogged as well- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
fixLiquid
public int fixLiquid(BlockVector3 origin, double radius, BlockType fluid) throws MaxChangedBlocksException Fix liquids so that they turn into stationary blocks and extend outward.- Parameters:
origin
- the original positionradius
- the radius to fixfluid
- the type of the fluid- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeCylinder
public int makeCylinder(BlockVector3 pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException Makes a cylinder.- Parameters:
pos
- Center of the cylinderblock
- The block pattern to useradius
- The cylinder's radiusheight
- The cylinder's up/down extent. If negative, extend downward.filled
- If false, only a shell will be generated.- Returns:
- number of blocks changed
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeCylinder
public int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException Makes a cylinder.- Parameters:
pos
- Center of the cylinderblock
- The block pattern to useradiusX
- The cylinder's largest north/south extentradiusZ
- The cylinder's largest east/west extentheight
- The cylinder's up/down extent. If negative, extend downward.filled
- If false, only a shell will be generated.- Returns:
- number of blocks changed
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeSphere
public int makeSphere(BlockVector3 pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException Makes a sphere.- Parameters:
pos
- Center of the sphere or ellipsoidblock
- The block pattern to useradius
- The sphere's radiusfilled
- If false, only a shell will be generated.- Returns:
- number of blocks changed
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeSphere
public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException Makes a sphere or ellipsoid.- Parameters:
pos
- Center of the sphere or ellipsoidblock
- The block pattern to useradiusX
- The sphere/ellipsoid's largest north/south extentradiusY
- The sphere/ellipsoid's largest up/down extentradiusZ
- The sphere/ellipsoid's largest east/west extentfilled
- If false, only a shell will be generated.- Returns:
- number of blocks changed
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makePyramid
public int makePyramid(BlockVector3 position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException Makes a pyramid.- Parameters:
position
- a positionblock
- a blocksize
- size of pyramidfilled
- true if filled- Returns:
- number of blocks changed
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
thaw
Deprecated.Thaw blocks in a radius.- Parameters:
position
- the positionradius
- the radius- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
thaw
Thaw blocks in a cylinder.- Parameters:
position
- the positionradius
- the radiusheight
- the height (upwards and downwards)- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
simulateSnow
@Deprecated public int simulateSnow(BlockVector3 position, double radius) throws MaxChangedBlocksException Deprecated.Make snow in a radius.- Parameters:
position
- a positionradius
- a radius- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
simulateSnow
public int simulateSnow(BlockVector3 position, double radius, int height) throws MaxChangedBlocksException Make snow in a cylinder.- Parameters:
position
- a positionradius
- a radiusheight
- the height (upwards and downwards)- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
simulateSnow
Make snow in a region.- Parameters:
region
- the region to simulate snow instack
- whether it should stack existing snow- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
green
@Deprecated public int green(BlockVector3 position, double radius, boolean onlyNormalDirt) throws MaxChangedBlocksException Deprecated.Make dirt green.- Parameters:
position
- a positionradius
- a radiusonlyNormalDirt
- only affect normal dirt (all default properties)- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
green
public int green(BlockVector3 position, double radius, int height, boolean onlyNormalDirt) throws MaxChangedBlocksException Make dirt green in a cylinder.- Parameters:
position
- the positionradius
- the radiusheight
- the heightonlyNormalDirt
- only affect normal dirt (all default properties)- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makePumpkinPatches
Makes pumpkin patches randomly in an area around the given position.- Parameters:
position
- the base positionapothem
- the apothem of the (square) area- Returns:
- number of patches created
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeForest
public int makeForest(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException Makes a forest.- Parameters:
basePosition
- a positionsize
- a sizedensity
- between 0 and 1, inclusivetreeType
- the tree type- Returns:
- number of trees created
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeForest
public int makeForest(Region region, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException Makes a forest.- Parameters:
region
- the region to generate trees indensity
- between 0 and 1, inclusivetreeType
- the tree type- Returns:
- number of trees created
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
getBlockDistribution
Get the block distribution inside a region.- Parameters:
region
- a region- Returns:
- the results
-
makeShape
public int makeShape(Region region, Vector3 zero, Vector3 unit, Pattern pattern, String expressionString, boolean hollow) throws ExpressionException, MaxChangedBlocksException Generate a shape for the given expression.- Parameters:
region
- the region to generate the shape inzero
- the coordinate origin for x/y/z variablesunit
- the scale of the x/y/z/ variablespattern
- the default material to make the shape fromexpressionString
- the expression defining the shapehollow
- whether the shape should be hollow- Returns:
- number of blocks changed
- Throws:
ExpressionException
- if there is a problem with the expressionMaxChangedBlocksException
- if the maximum block change limit is exceeded
-
makeShape
public int makeShape(Region region, Vector3 zero, Vector3 unit, Pattern pattern, String expressionString, boolean hollow, int timeout) throws ExpressionException, MaxChangedBlocksException Generate a shape for the given expression.- Parameters:
region
- the region to generate the shape inzero
- the coordinate origin for x/y/z variablesunit
- the scale of the x/y/z/ variablespattern
- the default material to make the shape fromexpressionString
- the expression defining the shapehollow
- whether the shape should be hollowtimeout
- the time, in milliseconds, to wait for each expression evaluation before halting it. -1 to disable- Returns:
- number of blocks changed
- Throws:
ExpressionException
- if there is a problem with the expressionMaxChangedBlocksException
- if the maximum block change limit is exceeded
-
makeShape
public int makeShape(Region region, Vector3 zero, Vector3 unit, Pattern pattern, Expression expression, boolean hollow, int timeout) throws ExpressionException, MaxChangedBlocksException Internal version ofmakeShape(Region, Vector3, Vector3, Pattern, String, boolean, int)
.The Expression class is subject to change. Expressions should be provided via the string overload.
-
deformRegion
public int deformRegion(Region region, Vector3 zero, Vector3 unit, String expressionString) throws ExpressionException, MaxChangedBlocksException Deforms the region by a given expression. A deform provides a block's x, y, and z coordinates (possibly scaled) to an expression, and then sets the block to the block given by the resulting values of the variables, if they have changed.- Parameters:
region
- the region to deformzero
- the origin of the coordinate systemunit
- the scale of the coordinate systemexpressionString
- the expression to evaluate for each block- Returns:
- number of blocks changed
- Throws:
ExpressionException
- thrown on invalid expression inputMaxChangedBlocksException
- thrown if too many blocks are changed
-
deformRegion
public int deformRegion(Region region, Vector3 zero, Vector3 unit, String expressionString, int timeout) throws ExpressionException, MaxChangedBlocksException Deforms the region by a given expression. A deform provides a block's x, y, and z coordinates (possibly scaled) to an expression, and then sets the block to the block given by the resulting values of the variables, if they have changed.- Parameters:
region
- the region to deformzero
- the origin of the coordinate systemunit
- the scale of the coordinate systemexpressionString
- the expression to evaluate for each blocktimeout
- maximum time for the expression to evaluate for each block. -1 for unlimited.- Returns:
- number of blocks changed
- Throws:
ExpressionException
- thrown on invalid expression inputMaxChangedBlocksException
- thrown if too many blocks are changed
-
deformRegion
public int deformRegion(Region region, Vector3 zero, Vector3 unit, Expression expression, int timeout) throws ExpressionException, MaxChangedBlocksException Internal version ofdeformRegion(Region, Vector3, Vector3, String, int)
.The Expression class is subject to change. Expressions should be provided via the string overload.
-
hollowOutRegion
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException Hollows out the region (Semi-well-defined for non-cuboid selections).- Parameters:
region
- the region to hollow out.thickness
- the thickness of the shell to leave (manhattan distance)pattern
- The block pattern to use- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
drawLine
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled) throws MaxChangedBlocksException Draws a line (out of blocks) between two vectors.- Parameters:
pattern
- The block pattern used to draw the line.pos1
- One of the points that define the line.pos2
- The other point that defines the line.radius
- The radius (thickness) of the line.filled
- If false, only a shell will be generated.- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed- See Also:
-
drawLine
public int drawLine(Pattern pattern, List<BlockVector3> vectors, double radius, boolean filled) throws MaxChangedBlocksException Draws a line (out of blocks) between two or more vectors.- Parameters:
pattern
- The block pattern used to draw the line.vectors
- the list of vectors to draw the line betweenradius
- The radius (thickness) of the line.filled
- If false, only a shell will be generated.- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
drawSpline
public int drawSpline(Pattern pattern, List<BlockVector3> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled) throws MaxChangedBlocksException Draws a spline (out of blocks) between specified vectors.- Parameters:
pattern
- The block pattern used to draw the spline.nodevectors
- The list of vectors to draw through.tension
- The tension of every node.bias
- The bias of every node.continuity
- The continuity of every node.quality
- The quality of the spline. Must be greater than 0.radius
- The radius (thickness) of the spline.filled
- If false, only a shell will be generated.- Returns:
- number of blocks affected
- Throws:
MaxChangedBlocksException
- thrown if too many blocks are changed
-
makeBiomeShape
public int makeBiomeShape(Region region, Vector3 zero, Vector3 unit, BiomeType biomeType, String expressionString, boolean hollow) throws ExpressionException - Throws:
ExpressionException
-
makeBiomeShape
public int makeBiomeShape(Region region, Vector3 zero, Vector3 unit, BiomeType biomeType, String expressionString, boolean hollow, int timeout) throws ExpressionException - Throws:
ExpressionException
-
setReorderMode(ReorderMode)
with another mode instead.