diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index 8d92f7b62..ae61ff7e1 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2757,7 +2757,9 @@ public class EditSession { double density, TreeGenerator treeGenerator) throws WorldEditException { - ForestGenerator generator = new ForestGenerator(this, treeGenerator, lowerY, upperY); + ForestGenerator generator = new ForestGenerator(this, treeGenerator); + generator.setLowerY(lowerY); + generator.setUpperY(upperY); generator.setDensity(density); int affected = 0; diff --git a/src/main/java/com/sk89q/worldedit/commands/RegionCommands.java b/src/main/java/com/sk89q/worldedit/commands/RegionCommands.java index f56b80b5d..ed89e9ea6 100644 --- a/src/main/java/com/sk89q/worldedit/commands/RegionCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/RegionCommands.java @@ -576,10 +576,9 @@ public class RegionCommands { flatRegion = CuboidRegion.makeCuboid(region); } - int upperY = flatRegion.getMaximumY(); - int lowerY = flatRegion.getMinimumY(); - - FloraPlacer generator = new FloraPlacer(editSession, lowerY, upperY); + FloraPlacer generator = new FloraPlacer(editSession); + generator.setLowerY(flatRegion.getMinimumY()); + generator.setUpperY(flatRegion.getMaximumY()); generator.setDensity(density); int affected = 0; diff --git a/src/main/java/com/sk89q/worldedit/generator/FloraPlacer.java b/src/main/java/com/sk89q/worldedit/generator/FloraPlacer.java index 7174f8095..be878e326 100644 --- a/src/main/java/com/sk89q/worldedit/generator/FloraPlacer.java +++ b/src/main/java/com/sk89q/worldedit/generator/FloraPlacer.java @@ -44,11 +44,9 @@ public class FloraPlacer extends GroundGenerator { * Create a new instance. * * @param editSession the edit session - * @param lowerY the lower Y - * @param upperY the upper Y (lowerY <= upperY) */ - public FloraPlacer(EditSession editSession, int lowerY, int upperY) { - super(editSession, lowerY, upperY); + public FloraPlacer(EditSession editSession) { + super(editSession); this.editSession = editSession; } diff --git a/src/main/java/com/sk89q/worldedit/generator/ForestGenerator.java b/src/main/java/com/sk89q/worldedit/generator/ForestGenerator.java index fd4f960f3..60ba0a622 100644 --- a/src/main/java/com/sk89q/worldedit/generator/ForestGenerator.java +++ b/src/main/java/com/sk89q/worldedit/generator/ForestGenerator.java @@ -40,11 +40,9 @@ public class ForestGenerator extends GroundGenerator { * * @param editSession the edit session * @param treeGenerator a tree generator - * @param lowerY the lower Y boundary to end the ground search from - * @param upperY the upper Y boundary to start the ground search at */ - public ForestGenerator(EditSession editSession, TreeGenerator treeGenerator, int lowerY, int upperY) { - super(editSession, lowerY, upperY); + public ForestGenerator(EditSession editSession, TreeGenerator treeGenerator) { + super(editSession); this.editSession = editSession; this.treeGenerator = treeGenerator; } diff --git a/src/main/java/com/sk89q/worldedit/generator/GroundGenerator.java b/src/main/java/com/sk89q/worldedit/generator/GroundGenerator.java index 417bfe262..8265f025d 100644 --- a/src/main/java/com/sk89q/worldedit/generator/GroundGenerator.java +++ b/src/main/java/com/sk89q/worldedit/generator/GroundGenerator.java @@ -34,11 +34,9 @@ public abstract class GroundGenerator extends GroundFindingFunction { * Create a new instance. * * @param editSession the edit session - * @param lowerY the lower Y - * @param upperY the upper Y (lowerY <= upperY) */ - protected GroundGenerator(EditSession editSession, int lowerY, int upperY) { - super(editSession, lowerY, upperY); + protected GroundGenerator(EditSession editSession) { + super(editSession); } /** diff --git a/src/main/java/com/sk89q/worldedit/operation/GroundFindingFunction.java b/src/main/java/com/sk89q/worldedit/operation/GroundFindingFunction.java index baa05daaa..cc4b21bb6 100644 --- a/src/main/java/com/sk89q/worldedit/operation/GroundFindingFunction.java +++ b/src/main/java/com/sk89q/worldedit/operation/GroundFindingFunction.java @@ -26,6 +26,13 @@ import com.sk89q.worldedit.blocks.BlockID; /** * An abstract implementation of {@link com.sk89q.worldedit.operation.FlatRegionFunction} * that searches for the ground, which is considered to be any non-air block. + *
+ * It functions by starting from the upperY in each column and traversing + * down the column until it finds the first non-air block, at which point + * {@link #apply(com.sk89q.worldedit.Vector, com.sk89q.worldedit.blocks.BaseBlock)} + * is called on that non-air block. {@link #shouldContinue(com.sk89q.worldedit.Vector2D)} + * is called before each column is traversed, which allows implementations + * to "skip" a column and avoid the ground search. */ public abstract class GroundFindingFunction implements FlatRegionFunction { @@ -37,13 +44,9 @@ public abstract class GroundFindingFunction implements FlatRegionFunction { * Create a new instance. * * @param editSession the edit session - * @param lowerY the lower Y - * @param upperY the upper Y (lowerY <= upperY) */ - protected GroundFindingFunction(EditSession editSession, int lowerY, int upperY) { + protected GroundFindingFunction(EditSession editSession) { this.editSession = editSession; - this.lowerY = lowerY; - this.upperY = upperY; checkYBounds(); } @@ -118,7 +121,8 @@ public abstract class GroundFindingFunction implements FlatRegionFunction { } /** - * Returns whether a search for the ground should be performed for the given point. + * Returns whether a search for the ground should be performed for the given + * column. Return false if the column is to be skipped. * * @param pt the point * @return true if the search should begin @@ -129,6 +133,12 @@ public abstract class GroundFindingFunction implements FlatRegionFunction { /** * Apply the function to the given ground block. + *
+ * The block above the given ground block may or may not be air, but it is + * a block that can be replaced. For example, this block may be a tall + * grass block or a flower. However, the ground block also could be + * the flower or grass block itself, depending on the configuration of the + * GroundFindingFunction. * * @param pt the position * @param block the block