Skip to content

Commit

Permalink
Move height params to DataValidatorExtent constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Oct 22, 2023
1 parent ecb2a10 commit 5c0f6cc
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
*/
public class DataValidatorExtent extends AbstractDelegateExtent {

private final World world;
private final int minY;
private final int maxY;

/**
* Create a new instance.
Expand All @@ -43,16 +44,27 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
* @param world the world
*/
public DataValidatorExtent(Extent extent, World world) {
this(extent, checkNotNull(world).getMinY(), world.getMaxY());
}

/**
* Create a new instance.
*
* @param extent The extent
* @param minY The minimum Y height to allow (inclusive)
* @param maxY The maximum Y height to allow (inclusive)
*/
public DataValidatorExtent(Extent extent, int minY, int maxY) {
super(extent);
checkNotNull(world);
this.world = world;
this.minY = minY;
this.maxY = maxY;
}

@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
final int y = location.getBlockY();
final BlockType type = block.getBlockType();
if (y < world.getMinY() || y > world.getMaxY()) {
if (y < minY || y > maxY) {
return false;
}

Expand Down

0 comments on commit 5c0f6cc

Please sign in to comment.