Skip to content
Permalink
Browse files

Merge branch 'master' into feature/cli

  • Loading branch information...
me4502 committed Aug 6, 2019
2 parents c22c41a + 11a532b commit ad6a8146eac981858e07c76df8e62c5a79148c20
Showing with 375 additions and 130 deletions.
  1. +16 −0 CHANGELOG.txt
  2. +75 −24 worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
  3. +1 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java
  4. +3 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java
  5. +41 −4 worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java
  6. +5 −5 worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java
  7. +2 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java
  8. +1 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java
  9. +1 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java
  10. +1 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java
  11. +1 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java
  12. +2 −3 ...rc/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java
  13. +1 −2 .../src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java
  14. +1 −2 .../src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java
  15. +21 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Capability.java
  16. +53 −4 worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java
  17. +3 −2 worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java
  18. +15 −4 worldedit-core/src/main/java/com/sk89q/worldedit/function/biome/BiomeReplace.java
  19. +6 −7 worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java
  20. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java
  21. +2 −3 worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java
  22. +37 −0 worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BiomePattern.java
  23. +3 −0 worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java
  24. +17 −28 worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java
  25. +40 −0 worldedit-core/src/main/java/com/sk89q/worldedit/regions/AbstractFlatRegion.java
  26. +8 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeType.java
  27. +3 −17 worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java
  28. +8 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java
  29. +2 −2 worldedit-forge/build.gradle.kts
  30. +1 −0 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java
  31. +2 −2 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java
  32. +2 −2 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java
@@ -1,3 +1,19 @@
7.0.1 Release Candidate 2
- Improve //thru (and navwand) in some cases
- Fix error when /up was used below the world
- Fix /up -f using glass anyway.
- Fix suggestions for quoted strings
- Improve suggestions for mask intersections
- Fix setting biomes in unloaded chunks
- BlockStateHolder now extends Pattern (API enhancement)
- Skip invalid blocks when schematic versions are mismatched
- Add -e/-b/-m flags to stack and move, just as copy/paste have
- Fix //center for selections with even-sized height
- (Fabric) Fix setting tile entities
- (Forge) Update to latest Forge builds (28.0.45+ required!)
- (Fabric/Forge Single-player) Fix wrong blocks being used when switching
between worlds generated at different times/with different mods

7.0.1 Release Candidate 1
- Improve //naturalize over large areas
- Fixed //restore with 1.14 worlds
@@ -40,6 +40,7 @@
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.biome.BiomeReplace;
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Counter;
@@ -62,11 +63,11 @@
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.WaterloggedRemover;
import com.sk89q.worldedit.function.util.RegionOffset;
import com.sk89q.worldedit.function.visitor.DownwardVisitor;
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
import com.sk89q.worldedit.function.visitor.LayerVisitor;
import com.sk89q.worldedit.function.visitor.NonRisingVisitor;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
@@ -820,7 +821,7 @@ public int countBlocks(Region region, Mask searchMask) {
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public <B extends BlockStateHolder<B>> int fillXZ(BlockVector3 origin, B block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
return fillXZ(origin, new BlockPattern(block), radius, depth, recursive);
return fillXZ(origin, (Pattern) block, radius, depth, recursive);
}

/**
@@ -885,8 +886,7 @@ public int removeAbove(BlockVector3 position, int apothem, int height) throws Ma
getWorld(), // Causes clamping of Y range
position.add(-apothem + 1, 0, -apothem + 1),
position.add(apothem - 1, height - 1, apothem - 1));
Pattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
return setBlocks(region, pattern);
return setBlocks(region, BlockTypes.AIR.getDefaultState());
}

/**
@@ -907,8 +907,7 @@ public int removeBelow(BlockVector3 position, int apothem, int height) throws Ma
getWorld(), // Causes clamping of Y range
position.add(-apothem + 1, 0, -apothem + 1),
position.add(apothem - 1, -height + 1, apothem - 1));
Pattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
return setBlocks(region, pattern);
return setBlocks(region, BlockTypes.AIR.getDefaultState());
}

/**
@@ -929,8 +928,7 @@ public int removeNear(BlockVector3 position, Mask mask, int apothem) throws MaxC
getWorld(), // Causes clamping of Y range
position.add(adjustment.multiply(-1)),
position.add(adjustment));
Pattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
return replaceBlocks(region, mask, pattern);
return replaceBlocks(region, mask, BlockTypes.AIR.getDefaultState());
}

/**
@@ -942,7 +940,7 @@ public int removeNear(BlockVector3 position, Mask mask, int apothem) throws MaxC
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
return setBlocks(region, new BlockPattern(block));
return setBlocks(region, (Pattern) block);
}

/**
@@ -974,7 +972,7 @@ public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksExce
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
return replaceBlocks(region, filter, new BlockPattern(replacement));
return replaceBlocks(region, filter, (Pattern) replacement);
}

/**
@@ -1032,8 +1030,10 @@ public int center(Region region, Pattern pattern) throws MaxChangedBlocksExcepti
Region centerRegion = new CuboidRegion(
getWorld(), // Causes clamping of Y range
BlockVector3.at(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
BlockVector3.at(MathUtils.roundHalfUp(center.getX()),
center.getY(), MathUtils.roundHalfUp(center.getZ())));
BlockVector3.at(
MathUtils.roundHalfUp(center.getX()),
MathUtils.roundHalfUp(center.getY()),
MathUtils.roundHalfUp(center.getZ())));
return setBlocks(centerRegion, pattern);
}

@@ -1046,7 +1046,7 @@ public int center(Region region, Pattern pattern) throws MaxChangedBlocksExcepti
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public <B extends BlockStateHolder<B>> int makeCuboidFaces(Region region, B block) throws MaxChangedBlocksException {
return makeCuboidFaces(region, new BlockPattern(block));
return makeCuboidFaces(region, block);
}

/**
@@ -1098,7 +1098,7 @@ public int makeFaces(final Region region, Pattern pattern) throws MaxChangedBloc
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public <B extends BlockStateHolder<B>> int makeCuboidWalls(Region region, B block) throws MaxChangedBlocksException {
return makeCuboidWalls(region, new BlockPattern(block));
return makeCuboidWalls(region, (Pattern) block);
}

/**
@@ -1165,7 +1165,7 @@ protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial)
public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException {
checkNotNull(block);

return overlayCuboidBlocks(region, new BlockPattern(block));
return overlayCuboidBlocks(region, (Pattern) block);
}

/**
@@ -1208,7 +1208,8 @@ public int naturalizeCuboidBlocks(Region region) throws MaxChangedBlocksExceptio
}

/**
* Stack a cuboid region.
* Stack a cuboid region. For compatibility, entities are copied by biomes are not.
* Use {@link #stackCuboidRegion(Region, BlockVector3, int, boolean, boolean, Mask)} to fine tune.
*
* @param region the region to stack
* @param dir the direction to stack
@@ -1218,6 +1219,23 @@ public int naturalizeCuboidBlocks(Region region) throws MaxChangedBlocksExceptio
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int stackCuboidRegion(Region region, BlockVector3 dir, int count, boolean copyAir) throws MaxChangedBlocksException {
return stackCuboidRegion(region, dir, count, true, false, copyAir ? null : new ExistingBlockMask(this));
}

/**
* Stack a cuboid region.
*
* @param region the region to stack
* @param dir the direction to stack
* @param count the number of times to stack
* @param copyEntities true to copy entities
* @param copyBiomes true to copy biomes
* @param mask source mask for the operation (only matching blocks are copied)
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int stackCuboidRegion(Region region, BlockVector3 dir, int count,
boolean copyEntities, boolean copyBiomes, Mask mask) throws MaxChangedBlocksException {
checkNotNull(region);
checkNotNull(dir);
checkArgument(count >= 1, "count >= 1 required");
@@ -1227,8 +1245,10 @@ public int stackCuboidRegion(Region region, BlockVector3 dir, int count, boolean
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
copy.setRepetitions(count);
copy.setTransform(new AffineTransform().translate(dir.multiply(size)));
if (!copyAir) {
copy.setSourceMask(new ExistingBlockMask(this));
copy.setCopyingEntities(copyEntities);
copy.setCopyingBiomes(copyBiomes);
if (mask != null) {
copy.setSourceMask(mask);
}
Operations.completeLegacy(copy);
return copy.getAffected();
@@ -1246,33 +1266,64 @@ public int stackCuboidRegion(Region region, BlockVector3 dir, int count, boolean
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, Pattern replacement) throws MaxChangedBlocksException {
return moveRegion(region, dir, distance, true, false, copyAir ? new ExistingBlockMask(this) : null, replacement);
}

/**
* Move the blocks in a region a certain direction.
*
* @param region the region to move
* @param dir the direction
* @param distance the distance to move
* @param moveEntities true to move entities
* @param copyBiomes true to copy biomes (source biome is unchanged)
* @param mask source mask for the operation (only matching blocks are moved)
* @param replacement the replacement pattern to fill in after moving, or null to use air
* @return number of blocks moved
* @throws MaxChangedBlocksException thrown if too many blocks are changed
* @throws IllegalArgumentException thrown if the region is not a flat region, but copyBiomes is true
*/
public int moveRegion(Region region, BlockVector3 dir, int distance,
boolean moveEntities, boolean copyBiomes, Mask mask, Pattern replacement) throws MaxChangedBlocksException {
checkNotNull(region);
checkNotNull(dir);
checkArgument(distance >= 1, "distance >= 1 required");
checkArgument(!copyBiomes || region instanceof FlatRegion, "can't copy biomes from non-flat region");

BlockVector3 to = region.getMinimumPoint();

// Remove the original blocks
Pattern pattern = replacement != null ?
replacement :
new BlockPattern(BlockTypes.AIR.getDefaultState());
BlockTypes.AIR.getDefaultState();
BlockReplace remove = new BlockReplace(this, pattern);

// Copy to a buffer so we don't destroy our original before we can copy all the blocks from it
ForgetfulExtentBuffer buffer = new ForgetfulExtentBuffer(this, new RegionMask(region));
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, buffer, to);
copy.setTransform(new AffineTransform().translate(dir.multiply(distance)));
copy.setSourceFunction(remove); // Remove
copy.setRemovingEntities(true);
if (!copyAir) {
copy.setSourceMask(new ExistingBlockMask(this));

copy.setCopyingEntities(moveEntities);
copy.setRemovingEntities(moveEntities);
copy.setCopyingBiomes(copyBiomes);

if (mask != null) {
copy.setSourceMask(mask);
}

// Then we need to copy the buffer to the world
BlockReplace replace = new BlockReplace(this, buffer);
RegionVisitor visitor = new RegionVisitor(buffer.asRegion(), replace);

OperationQueue operation = new OperationQueue(copy, visitor);

if (copyBiomes) {
BiomeReplace biomeReplace = new BiomeReplace(this, buffer);
FlatRegionVisitor biomeVisitor = new FlatRegionVisitor((FlatRegion) buffer.asRegion(), biomeReplace);
operation.offer(biomeVisitor);
}

Operations.completeLegacy(operation);

return copy.getAffected();
@@ -1334,7 +1385,7 @@ public int drainArea(BlockVector3 origin, double radius, boolean waterlogged) th
if (waterlogged) {
replace = new BlockReplace(this, new WaterloggedRemover(this));
} else {
replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState()));
replace = new BlockReplace(this, BlockTypes.AIR.getDefaultState());
}
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace);

@@ -1376,7 +1427,7 @@ public int fixLiquid(BlockVector3 origin, double radius, BlockType fluid) throws
blockMask
);

BlockReplace replace = new BlockReplace(this, new BlockPattern(fluid.getDefaultState()));
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);

// Around the origin in a 3x3 block
@@ -47,7 +47,6 @@
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.factory.RegionFactory;
@@ -207,8 +206,7 @@ public void extinguishBrush(Player player, LocalSession session,
worldEdit.checkMaxBrushRadius(radius);

BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
Pattern fill = new BlockPattern(BlockTypes.AIR.getDefaultState());
tool.setFill(fill);
tool.setFill(BlockTypes.AIR.getDefaultState());
tool.setSize(radius);
tool.setMask(new BlockTypeMask(new RequestExtent(), BlockTypes.FIRE));
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
@@ -208,6 +208,7 @@ public int forestGen(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The density of the forest, between 0 and 100", def = "5")
double density) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100");
worldEdit.checkMaxRadius(size);
density /= 100;
int affected = editSession.makeForest(session.getPlacementPosition(actor), size, density, type);
actor.print(affected + " trees created.");
@@ -223,6 +224,7 @@ public int forestGen(Actor actor, LocalSession session, EditSession editSession,
public int pumpkins(Actor actor, LocalSession session, EditSession editSession,
@Arg(desc = "The size of the patch", def = "10")
int size) throws WorldEditException {
worldEdit.checkMaxRadius(size);
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(actor), size);
actor.print(affected + " pumpkin patches created.");
return affected;
@@ -255,8 +257,8 @@ public int pyramid(Actor actor, LocalSession session, EditSession editSession,
int size,
@Switch(name = 'h', desc = "Make a hollow pyramid")
boolean hollow) throws WorldEditException {
BlockVector3 pos = session.getPlacementPosition(actor);
worldEdit.checkMaxRadius(size);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
if (actor instanceof Player) {
((Player) actor).findFreePosition();
@@ -35,6 +35,7 @@
import com.sk89q.worldedit.function.generator.FloraGenerator;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
@@ -58,6 +59,7 @@
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;

import java.util.ArrayList;
@@ -295,10 +297,27 @@ public int move(Actor actor, World world, EditSession editSession, LocalSession
@Switch(name = 's', desc = "Shift the selection to the target location")
boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks) throws WorldEditException {
boolean ignoreAirBlocks,
@Switch(name = 'e', desc = "Also copy entities")
boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
Mask mask) throws WorldEditException {
checkCommandArgument(count >= 1, "Count must be >= 1");

int affected = editSession.moveRegion(region, direction, count, !ignoreAirBlocks, replace);
Mask combinedMask;
if (ignoreAirBlocks) {
if (mask == null) {
combinedMask = new ExistingBlockMask(editSession);
} else {
combinedMask = new MaskIntersection(mask, new ExistingBlockMask(editSession));
}
} else {
combinedMask = mask;
}

int affected = editSession.moveRegion(region, direction, count, copyEntities, copyBiomes, combinedMask, replace);

if (moveSelection) {
try {
@@ -331,8 +350,26 @@ public int stack(Actor actor, World world, EditSession editSession, LocalSession
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks) throws WorldEditException {
int affected = editSession.stackCuboidRegion(region, direction, count, !ignoreAirBlocks);
boolean ignoreAirBlocks,
@Switch(name = 'e', desc = "Also copy entities")
boolean copyEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "")
Mask mask) throws WorldEditException {

Mask combinedMask;
if (ignoreAirBlocks) {
if (mask == null) {
combinedMask = new ExistingBlockMask(editSession);
} else {
combinedMask = new MaskIntersection(mask, new ExistingBlockMask(editSession));
}
} else {
combinedMask = mask;
}

int affected = editSession.stackCuboidRegion(region, direction, count, copyEntities, copyBiomes, combinedMask);

if (moveSelection) {
try {

0 comments on commit ad6a814

Please sign in to comment.
You can’t perform that action at this time.