mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 20:56:41 +00:00
Refactor vector system to be cleaner
- Move Vector, etc. into `.math` package - Drop many methods that will be auto-promoted anyways, eg. with `divide(int)` and `divide(double)` the first is now gone. - Take Block vectors into their own class hierarchy - Make it clear throughout the API what takes blockvectors - many more improvements
This commit is contained in:
@ -25,8 +25,6 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
@ -48,6 +46,7 @@ import com.sk89q.worldedit.extent.world.FastModeExtent;
|
||||
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
|
||||
import com.sk89q.worldedit.function.GroundFunction;
|
||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.block.BlockDistributionCounter;
|
||||
import com.sk89q.worldedit.function.block.BlockReplace;
|
||||
import com.sk89q.worldedit.function.block.Counter;
|
||||
import com.sk89q.worldedit.function.block.Naturalizer;
|
||||
@ -81,7 +80,11 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.interpolation.Interpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.Node;
|
||||
@ -113,8 +116,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -139,7 +140,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName());
|
||||
|
||||
/**
|
||||
* Used by {@link #setBlock(Vector, BlockStateHolder, Stage)} to
|
||||
* Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to
|
||||
* determine which {@link Extent}s should be bypassed.
|
||||
*/
|
||||
public enum Stage {
|
||||
@ -451,22 +452,22 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
public BaseBiome getBiome(BlockVector2 position) {
|
||||
return bypassNone.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
public boolean setBiome(BlockVector2 position, BaseBiome biome) {
|
||||
return bypassNone.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return world.getBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(Vector position) {
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return world.getFullBlock(position);
|
||||
}
|
||||
|
||||
@ -481,7 +482,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
*/
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
BlockState block = getBlock(pt);
|
||||
if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
return y;
|
||||
@ -500,7 +501,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return whether the block changed
|
||||
* @throws WorldEditException thrown on a set error
|
||||
*/
|
||||
public boolean setBlock(Vector position, BlockStateHolder block, Stage stage) throws WorldEditException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block, Stage stage) throws WorldEditException {
|
||||
switch (stage) {
|
||||
case BEFORE_HISTORY:
|
||||
return bypassNone.setBlock(position, block);
|
||||
@ -520,7 +521,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @param block the block
|
||||
* @return whether the block changed
|
||||
*/
|
||||
public boolean rawSetBlock(Vector position, BlockStateHolder block) {
|
||||
public boolean rawSetBlock(BlockVector3 position, BlockStateHolder block) {
|
||||
try {
|
||||
return setBlock(position, block, Stage.BEFORE_CHANGE);
|
||||
} catch (WorldEditException e) {
|
||||
@ -535,7 +536,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @param block the block
|
||||
* @return whether the block changed
|
||||
*/
|
||||
public boolean smartSetBlock(Vector position, BlockStateHolder block) {
|
||||
public boolean smartSetBlock(BlockVector3 position, BlockStateHolder block) {
|
||||
try {
|
||||
return setBlock(position, block, Stage.BEFORE_REORDER);
|
||||
} catch (WorldEditException e) {
|
||||
@ -544,7 +545,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws MaxChangedBlocksException {
|
||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException {
|
||||
try {
|
||||
return setBlock(position, block, Stage.BEFORE_HISTORY);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
@ -562,7 +563,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return Whether the block changed -- not entirely dependable
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public boolean setBlock(Vector position, Pattern pattern) throws MaxChangedBlocksException {
|
||||
public boolean setBlock(BlockVector3 position, Pattern pattern) throws MaxChangedBlocksException {
|
||||
return setBlock(position, pattern.apply(position));
|
||||
}
|
||||
|
||||
@ -575,9 +576,9 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return the number of changed blocks
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
private int setBlocks(Set<Vector> vset, Pattern pattern) throws MaxChangedBlocksException {
|
||||
private int setBlocks(Set<BlockVector3> vset, Pattern pattern) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
for (Vector v : vset) {
|
||||
for (BlockVector3 v : vset) {
|
||||
affected += setBlock(v, pattern) ? 1 : 0;
|
||||
}
|
||||
return affected;
|
||||
@ -623,12 +624,12 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return getWorld().getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return getWorld().getMaximumPoint();
|
||||
}
|
||||
|
||||
@ -690,7 +691,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int fillXZ(Vector origin, BlockStateHolder block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||
public int fillXZ(BlockVector3 origin, BlockStateHolder block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||
return fillXZ(origin, new BlockPattern(block), radius, depth, recursive);
|
||||
}
|
||||
|
||||
@ -705,14 +706,14 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int fillXZ(Vector origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||
public int fillXZ(BlockVector3 origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||
checkNotNull(origin);
|
||||
checkNotNull(pattern);
|
||||
checkArgument(radius >= 0, "radius >= 0");
|
||||
checkArgument(depth >= 1, "depth >= 1");
|
||||
|
||||
MaskIntersection mask = new MaskIntersection(
|
||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
|
||||
new BoundedHeightMask(
|
||||
Math.max(origin.getBlockY() - depth + 1, 0),
|
||||
Math.min(getWorld().getMaxY(), origin.getBlockY())),
|
||||
@ -747,7 +748,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int removeAbove(Vector position, int apothem, int height) throws MaxChangedBlocksException {
|
||||
public int removeAbove(BlockVector3 position, int apothem, int height) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
checkArgument(height >= 1, "height >= 1");
|
||||
@ -769,7 +770,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int removeBelow(Vector position, int apothem, int height) throws MaxChangedBlocksException {
|
||||
public int removeBelow(BlockVector3 position, int apothem, int height) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
checkArgument(height >= 1, "height >= 1");
|
||||
@ -791,12 +792,12 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int removeNear(Vector position, BlockType blockType, int apothem) throws MaxChangedBlocksException {
|
||||
public int removeNear(BlockVector3 position, BlockType blockType, int apothem) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
|
||||
Mask mask = new BlockTypeMask(this, blockType);
|
||||
Vector adjustment = new Vector(1, 1, 1).multiply(apothem - 1);
|
||||
BlockVector3 adjustment = BlockVector3.ONE.multiply(apothem - 1);
|
||||
Region region = new CuboidRegion(
|
||||
getWorld(), // Causes clamping of Y range
|
||||
position.add(adjustment.multiply(-1)),
|
||||
@ -900,11 +901,11 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
Vector center = region.getCenter();
|
||||
Vector3 center = region.getCenter();
|
||||
Region centerRegion = new CuboidRegion(
|
||||
getWorld(), // Causes clamping of Y range
|
||||
new Vector(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
|
||||
new Vector(MathUtils.roundHalfUp(center.getX()),
|
||||
new BlockVector3(((int) center.getX()), ((int) center.getY()), ((int) center.getZ())),
|
||||
new BlockVector3(MathUtils.roundHalfUp(center.getX()),
|
||||
center.getY(), MathUtils.roundHalfUp(center.getZ())));
|
||||
return setBlocks(centerRegion, pattern);
|
||||
}
|
||||
@ -1054,7 +1055,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionOffset offset = new RegionOffset(new Vector(0, 1, 0), replace);
|
||||
RegionOffset offset = new RegionOffset(new BlockVector3(0, 1, 0), replace);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset);
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||
Operations.completeLegacy(visitor);
|
||||
@ -1089,13 +1090,13 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int stackCuboidRegion(Region region, Vector dir, int count, boolean copyAir) throws MaxChangedBlocksException {
|
||||
public int stackCuboidRegion(Region region, BlockVector3 dir, int count, boolean copyAir) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(dir);
|
||||
checkArgument(count >= 1, "count >= 1 required");
|
||||
|
||||
Vector size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||
Vector to = region.getMinimumPoint();
|
||||
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||
BlockVector3 to = region.getMinimumPoint();
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
|
||||
copy.setRepetitions(count);
|
||||
copy.setTransform(new AffineTransform().translate(dir.multiply(size)));
|
||||
@ -1117,12 +1118,12 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks moved
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int moveRegion(Region region, Vector dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
||||
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(dir);
|
||||
checkArgument(distance >= 1, "distance >= 1 required");
|
||||
|
||||
Vector to = region.getMinimumPoint();
|
||||
BlockVector3 to = region.getMinimumPoint();
|
||||
|
||||
// Remove the original blocks
|
||||
com.sk89q.worldedit.function.pattern.Pattern pattern = replacement != null ?
|
||||
@ -1161,7 +1162,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks moved
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int moveCuboidRegion(Region region, Vector dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
||||
public int moveCuboidRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
||||
return moveRegion(region, dir, distance, copyAir, replacement);
|
||||
}
|
||||
|
||||
@ -1173,20 +1174,20 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int drainArea(Vector origin, double radius) throws MaxChangedBlocksException {
|
||||
public int drainArea(BlockVector3 origin, double radius) throws MaxChangedBlocksException {
|
||||
checkNotNull(origin);
|
||||
checkArgument(radius >= 0, "radius >= 0 required");
|
||||
|
||||
MaskIntersection mask = new MaskIntersection(
|
||||
new BoundedHeightMask(0, getWorld().getMaxY()),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
|
||||
getWorld().createLiquidMask());
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState()));
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace);
|
||||
|
||||
// Around the origin in a 3x3 block
|
||||
for (BlockVector position : CuboidRegion.fromCenter(origin, 1)) {
|
||||
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||
if (mask.test(position)) {
|
||||
visitor.visit(position);
|
||||
}
|
||||
@ -1206,7 +1207,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int fixLiquid(Vector origin, double radius, BlockType fluid) throws MaxChangedBlocksException {
|
||||
public int fixLiquid(BlockVector3 origin, double radius, BlockType fluid) throws MaxChangedBlocksException {
|
||||
checkNotNull(origin);
|
||||
checkArgument(radius >= 0, "radius >= 0 required");
|
||||
|
||||
@ -1219,7 +1220,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
// There are boundaries that the routine needs to stay in
|
||||
MaskIntersection mask = new MaskIntersection(
|
||||
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
|
||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector3(radius, radius, radius))),
|
||||
blockMask
|
||||
);
|
||||
|
||||
@ -1227,7 +1228,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||
|
||||
// Around the origin in a 3x3 block
|
||||
for (BlockVector position : CuboidRegion.fromCenter(origin, 1)) {
|
||||
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||
if (liquidMask.test(position)) {
|
||||
visitor.visit(position);
|
||||
}
|
||||
@ -1249,7 +1250,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeCylinder(Vector pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException {
|
||||
public int makeCylinder(BlockVector3 pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException {
|
||||
return makeCylinder(pos, block, radius, radius, height, filled);
|
||||
}
|
||||
|
||||
@ -1265,7 +1266,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeCylinder(Vector pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException {
|
||||
public int makeCylinder(BlockVector3 pos, Pattern block, double radiusX, double radiusZ, int height, boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
radiusX += 0.5;
|
||||
@ -1279,7 +1280,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
}
|
||||
|
||||
if (pos.getBlockY() < 0) {
|
||||
pos = pos.setY(0);
|
||||
pos = pos.withY(0);
|
||||
} else if (pos.getBlockY() + height - 1 > world.getMaxY()) {
|
||||
height = world.getMaxY() - pos.getBlockY() + 1;
|
||||
}
|
||||
@ -1343,7 +1344,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeSphere(Vector pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
|
||||
public int makeSphere(BlockVector3 pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException {
|
||||
return makeSphere(pos, block, radius, radius, radius, filled);
|
||||
}
|
||||
|
||||
@ -1359,7 +1360,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeSphere(Vector pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
|
||||
public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
radiusX += 0.5;
|
||||
@ -1445,7 +1446,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makePyramid(Vector position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException {
|
||||
public int makePyramid(BlockVector3 position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
int height = size;
|
||||
@ -1485,7 +1486,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int thaw(Vector position, double radius)
|
||||
public int thaw(BlockVector3 position, double radius)
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
double radiusSq = radius * radius;
|
||||
@ -1500,12 +1501,12 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
int ceilRadius = (int) Math.ceil(radius);
|
||||
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
||||
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
||||
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int y = world.getMaxY(); y >= 1; --y) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
BlockType id = getBlock(pt).getBlockType();
|
||||
|
||||
if (id == BlockTypes.ICE) {
|
||||
@ -1536,7 +1537,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int simulateSnow(Vector position, double radius) throws MaxChangedBlocksException {
|
||||
public int simulateSnow(BlockVector3 position, double radius) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
double radiusSq = radius * radius;
|
||||
|
||||
@ -1550,12 +1551,12 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
int ceilRadius = (int) Math.ceil(radius);
|
||||
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
||||
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
||||
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int y = world.getMaxY(); y >= 1; --y) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
BlockType id = getBlock(pt).getBlockType();
|
||||
|
||||
if (id.getMaterial().isAir()) {
|
||||
@ -1604,7 +1605,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int green(Vector position, double radius, boolean onlyNormalDirt)
|
||||
public int green(BlockVector3 position, double radius, boolean onlyNormalDirt)
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
final double radiusSq = radius * radius;
|
||||
@ -1618,12 +1619,12 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
final int ceilRadius = (int) Math.ceil(radius);
|
||||
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
|
||||
for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) {
|
||||
if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||
if ((new BlockVector3(x, oy, z)).distanceSq(position) > radiusSq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int y = world.getMaxY(); y >= 1; --y) {
|
||||
final Vector pt = new Vector(x, y, z);
|
||||
final BlockVector3 pt = new BlockVector3(x, y, z);
|
||||
final BlockState block = getBlock(pt);
|
||||
|
||||
if (block.getBlockType() == BlockTypes.DIRT ||
|
||||
@ -1652,7 +1653,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of patches created
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makePumpkinPatches(Vector position, int apothem) throws MaxChangedBlocksException {
|
||||
public int makePumpkinPatches(BlockVector3 position, int apothem) throws MaxChangedBlocksException {
|
||||
// We want to generate pumpkins
|
||||
GardenPatchGenerator generator = new GardenPatchGenerator(this);
|
||||
generator.setPlant(GardenPatchGenerator.getPumpkinPattern());
|
||||
@ -1681,7 +1682,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of trees created
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeForest(Vector basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
|
||||
public int makeForest(BlockVector3 basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX()
|
||||
@ -1689,7 +1690,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ()
|
||||
+ size; ++z) {
|
||||
// Don't want to be in the ground
|
||||
if (!getBlock(new Vector(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) {
|
||||
if (!getBlock(new BlockVector3(x, basePosition.getBlockY(), z)).getBlockType().getMaterial().isAir()) {
|
||||
continue;
|
||||
}
|
||||
// The gods don't want a tree here
|
||||
@ -1699,13 +1700,13 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
|
||||
for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) {
|
||||
// Check if we hit the ground
|
||||
BlockType t = getBlock(new Vector(x, y, z)).getBlockType();
|
||||
BlockType t = getBlock(new BlockVector3(x, y, z)).getBlockType();
|
||||
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
|
||||
treeType.generate(this, new Vector(x, y + 1, z));
|
||||
treeType.generate(this, new BlockVector3(x, y + 1, z));
|
||||
++affected;
|
||||
break;
|
||||
} else if (t == BlockTypes.SNOW) {
|
||||
setBlock(new Vector(x, y, z), BlockTypes.AIR.getDefaultState());
|
||||
setBlock(new BlockVector3(x, y, z), BlockTypes.AIR.getDefaultState());
|
||||
} else if (!t.getMaterial().isAir()) { // Trees won't grow on this!
|
||||
break;
|
||||
}
|
||||
@ -1729,7 +1730,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
return count.getDistribution();
|
||||
}
|
||||
|
||||
public int makeShape(final Region region, final Vector zero, final Vector unit, final Pattern pattern, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
||||
public int makeShape(final Region region, final Vector3 zero, final Vector3 unit, final Pattern pattern, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
||||
final Expression expression = Expression.compile(expressionString, "x", "y", "z", "type", "data");
|
||||
expression.optimize();
|
||||
|
||||
@ -1742,9 +1743,9 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
final ArbitraryShape shape = new ArbitraryShape(region) {
|
||||
@Override
|
||||
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
|
||||
final Vector current = new Vector(x, y, z);
|
||||
final Vector3 current = new Vector3(x, y, z);
|
||||
environment.setCurrentBlock(current);
|
||||
final Vector scaled = current.subtract(zero).divide(unit);
|
||||
final Vector3 scaled = current.subtract(zero).divide(unit);
|
||||
|
||||
try {
|
||||
if (expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getBlockType().getLegacyId(), 0) <= 0) {
|
||||
@ -1763,7 +1764,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
return shape.generate(this, pattern, hollow);
|
||||
}
|
||||
|
||||
public int deformRegion(final Region region, final Vector zero, final Vector unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException {
|
||||
public int deformRegion(final Region region, final Vector3 zero, final Vector3 unit, final String expressionString) throws ExpressionException, MaxChangedBlocksException {
|
||||
final Expression expression = Expression.compile(expressionString, "x", "y", "z");
|
||||
expression.optimize();
|
||||
|
||||
@ -1774,16 +1775,16 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
||||
expression.setEnvironment(environment);
|
||||
|
||||
final DoubleArrayList<BlockVector, BaseBlock> queue = new DoubleArrayList<>(false);
|
||||
final DoubleArrayList<BlockVector3, BaseBlock> queue = new DoubleArrayList<>(false);
|
||||
|
||||
for (BlockVector position : region) {
|
||||
for (BlockVector3 position : region) {
|
||||
// offset, scale
|
||||
final Vector scaled = position.subtract(zero).divide(unit);
|
||||
final Vector3 scaled = position.toVector3().subtract(zero).divide(unit);
|
||||
|
||||
// transform
|
||||
expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ());
|
||||
|
||||
final BlockVector sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue());
|
||||
final BlockVector3 sourcePosition = environment.toWorld(x.getValue(), y.getValue(), z.getValue());
|
||||
|
||||
// read block from world
|
||||
final BaseBlock material = world.getFullBlock(sourcePosition);
|
||||
@ -1793,8 +1794,8 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
}
|
||||
|
||||
int affected = 0;
|
||||
for (Map.Entry<BlockVector, BaseBlock> entry : queue) {
|
||||
BlockVector position = entry.getKey();
|
||||
for (Map.Entry<BlockVector3, BaseBlock> entry : queue) {
|
||||
BlockVector3 position = entry.getKey();
|
||||
BaseBlock material = entry.getValue();
|
||||
|
||||
// set at new position
|
||||
@ -1819,10 +1820,10 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
final Set<BlockVector> outside = new HashSet<>();
|
||||
final Set<BlockVector3> outside = new HashSet<>();
|
||||
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
final BlockVector3 min = region.getMinimumPoint();
|
||||
final BlockVector3 max = region.getMaximumPoint();
|
||||
|
||||
final int minX = min.getBlockX();
|
||||
final int minY = min.getBlockY();
|
||||
@ -1833,30 +1834,30 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
recurseHollow(region, new BlockVector(x, y, minZ), outside);
|
||||
recurseHollow(region, new BlockVector(x, y, maxZ), outside);
|
||||
recurseHollow(region, new BlockVector3(x, y, minZ), outside);
|
||||
recurseHollow(region, new BlockVector3(x, y, maxZ), outside);
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
recurseHollow(region, new BlockVector(minX, y, z), outside);
|
||||
recurseHollow(region, new BlockVector(maxX, y, z), outside);
|
||||
recurseHollow(region, new BlockVector3(minX, y, z), outside);
|
||||
recurseHollow(region, new BlockVector3(maxX, y, z), outside);
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = minZ; z <= maxZ; ++z) {
|
||||
for (int x = minX; x <= maxX; ++x) {
|
||||
recurseHollow(region, new BlockVector(x, minY, z), outside);
|
||||
recurseHollow(region, new BlockVector(x, maxY, z), outside);
|
||||
recurseHollow(region, new BlockVector3(x, minY, z), outside);
|
||||
recurseHollow(region, new BlockVector3(x, maxY, z), outside);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < thickness; ++i) {
|
||||
final Set<BlockVector> newOutside = new HashSet<>();
|
||||
outer: for (BlockVector position : region) {
|
||||
for (Vector recurseDirection: recurseDirections) {
|
||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
||||
final Set<BlockVector3> newOutside = new HashSet<>();
|
||||
outer: for (BlockVector3 position : region) {
|
||||
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||
BlockVector3 neighbor = position.add(recurseDirection);
|
||||
|
||||
if (outside.contains(neighbor)) {
|
||||
newOutside.add(position);
|
||||
@ -1868,9 +1869,9 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
outside.addAll(newOutside);
|
||||
}
|
||||
|
||||
outer: for (BlockVector position : region) {
|
||||
for (Vector recurseDirection: recurseDirections) {
|
||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
||||
outer: for (BlockVector3 position : region) {
|
||||
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||
BlockVector3 neighbor = position.add(recurseDirection);
|
||||
|
||||
if (outside.contains(neighbor)) {
|
||||
continue outer;
|
||||
@ -1897,10 +1898,10 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int drawLine(Pattern pattern, Vector pos1, Vector pos2, double radius, boolean filled)
|
||||
public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled)
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
Set<Vector> vset = new HashSet<>();
|
||||
Set<BlockVector3> vset = new HashSet<>();
|
||||
boolean notdrawn = true;
|
||||
|
||||
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
|
||||
@ -1909,7 +1910,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1);
|
||||
|
||||
if (dx + dy + dz == 0) {
|
||||
vset.add(new Vector(tipx, tipy, tipz));
|
||||
vset.add(new BlockVector3(tipx, tipy, tipz));
|
||||
notdrawn = false;
|
||||
}
|
||||
|
||||
@ -1919,7 +1920,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
|
||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
|
||||
|
||||
vset.add(new Vector(tipx, tipy, tipz));
|
||||
vset.add(new BlockVector3(tipx, tipy, tipz));
|
||||
}
|
||||
notdrawn = false;
|
||||
}
|
||||
@ -1930,7 +1931,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
|
||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
|
||||
|
||||
vset.add(new Vector(tipx, tipy, tipz));
|
||||
vset.add(new BlockVector3(tipx, tipy, tipz));
|
||||
}
|
||||
notdrawn = false;
|
||||
}
|
||||
@ -1941,7 +1942,7 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1));
|
||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1));
|
||||
|
||||
vset.add(new Vector(tipx, tipy, tipz));
|
||||
vset.add(new BlockVector3(tipx, tipy, tipz));
|
||||
}
|
||||
notdrawn = false;
|
||||
}
|
||||
@ -1968,16 +1969,16 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int drawSpline(Pattern pattern, List<Vector> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled)
|
||||
public int drawSpline(Pattern pattern, List<BlockVector3> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled)
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
Set<Vector> vset = new HashSet<>();
|
||||
Set<BlockVector3> vset = new HashSet<>();
|
||||
List<Node> nodes = new ArrayList<>(nodevectors.size());
|
||||
|
||||
Interpolation interpol = new KochanekBartelsInterpolation();
|
||||
|
||||
for (Vector nodevector : nodevectors) {
|
||||
Node n = new Node(nodevector);
|
||||
for (BlockVector3 nodevector : nodevectors) {
|
||||
Node n = new Node(nodevector.toVector3());
|
||||
n.setTension(tension);
|
||||
n.setBias(bias);
|
||||
n.setContinuity(continuity);
|
||||
@ -1987,12 +1988,9 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
interpol.setNodes(nodes);
|
||||
double splinelength = interpol.arcLength(0, 1);
|
||||
for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
|
||||
Vector tipv = interpol.getPosition(loop);
|
||||
int tipx = (int) Math.round(tipv.getX());
|
||||
int tipy = (int) Math.round(tipv.getY());
|
||||
int tipz = (int) Math.round(tipv.getZ());
|
||||
Vector3 tipv = interpol.getPosition(loop);
|
||||
|
||||
vset.add(new Vector(tipx, tipy, tipz));
|
||||
vset.add(tipv.toBlockPoint());
|
||||
}
|
||||
|
||||
vset = getBallooned(vset, radius);
|
||||
@ -2010,18 +2008,18 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
return Math.sqrt(sum);
|
||||
}
|
||||
|
||||
private static Set<Vector> getBallooned(Set<Vector> vset, double radius) {
|
||||
Set<Vector> returnset = new HashSet<>();
|
||||
private static Set<BlockVector3> getBallooned(Set<BlockVector3> vset, double radius) {
|
||||
Set<BlockVector3> returnset = new HashSet<>();
|
||||
int ceilrad = (int) Math.ceil(radius);
|
||||
|
||||
for (Vector v : vset) {
|
||||
for (BlockVector3 v : vset) {
|
||||
int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
|
||||
|
||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||
for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) {
|
||||
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||
if (hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) {
|
||||
returnset.add(new Vector(loopx, loopy, loopz));
|
||||
returnset.add(new BlockVector3(loopx, loopy, loopz));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2030,28 +2028,28 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
return returnset;
|
||||
}
|
||||
|
||||
private static Set<Vector> getHollowed(Set<Vector> vset) {
|
||||
Set<Vector> returnset = new HashSet<>();
|
||||
for (Vector v : vset) {
|
||||
private static Set<BlockVector3> getHollowed(Set<BlockVector3> vset) {
|
||||
Set<BlockVector3> returnset = new HashSet<>();
|
||||
for (BlockVector3 v : vset) {
|
||||
double x = v.getX(), y = v.getY(), z = v.getZ();
|
||||
if (!(vset.contains(new Vector(x + 1, y, z)) &&
|
||||
vset.contains(new Vector(x - 1, y, z)) &&
|
||||
vset.contains(new Vector(x, y + 1, z)) &&
|
||||
vset.contains(new Vector(x, y - 1, z)) &&
|
||||
vset.contains(new Vector(x, y, z + 1)) &&
|
||||
vset.contains(new Vector(x, y, z - 1)))) {
|
||||
if (!(vset.contains(new BlockVector3(x + 1, y, z)) &&
|
||||
vset.contains(new BlockVector3(x - 1, y, z)) &&
|
||||
vset.contains(new BlockVector3(x, y + 1, z)) &&
|
||||
vset.contains(new BlockVector3(x, y - 1, z)) &&
|
||||
vset.contains(new BlockVector3(x, y, z + 1)) &&
|
||||
vset.contains(new BlockVector3(x, y, z - 1)))) {
|
||||
returnset.add(v);
|
||||
}
|
||||
}
|
||||
return returnset;
|
||||
}
|
||||
|
||||
private void recurseHollow(Region region, BlockVector origin, Set<BlockVector> outside) {
|
||||
final LinkedList<BlockVector> queue = new LinkedList<>();
|
||||
private void recurseHollow(Region region, BlockVector3 origin, Set<BlockVector3> outside) {
|
||||
final LinkedList<BlockVector3> queue = new LinkedList<>();
|
||||
queue.addLast(origin);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
final BlockVector current = queue.removeFirst();
|
||||
final BlockVector3 current = queue.removeFirst();
|
||||
final BlockState block = getBlock(current);
|
||||
if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
continue;
|
||||
@ -2065,15 +2063,15 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Vector recurseDirection: recurseDirections) {
|
||||
queue.addLast(current.add(recurseDirection).toBlockVector());
|
||||
for (BlockVector3 recurseDirection : recurseDirections) {
|
||||
queue.addLast(current.add(recurseDirection));
|
||||
}
|
||||
} // while
|
||||
}
|
||||
}
|
||||
|
||||
public int makeBiomeShape(final Region region, final Vector zero, final Vector unit, final BaseBiome biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
||||
final Vector2D zero2D = zero.toVector2D();
|
||||
final Vector2D unit2D = unit.toVector2D();
|
||||
public int makeBiomeShape(final Region region, final Vector3 zero, final Vector3 unit, final BaseBiome biomeType, final String expressionString, final boolean hollow) throws ExpressionException, MaxChangedBlocksException {
|
||||
final Vector2 zero2D = zero.toVector2();
|
||||
final Vector2 unit2D = unit.toVector2();
|
||||
|
||||
final Expression expression = Expression.compile(expressionString, "x", "z");
|
||||
expression.optimize();
|
||||
@ -2085,9 +2083,9 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
final ArbitraryBiomeShape shape = new ArbitraryBiomeShape(region) {
|
||||
@Override
|
||||
protected BaseBiome getBiome(int x, int z, BaseBiome defaultBiomeType) {
|
||||
final Vector2D current = new Vector2D(x, z);
|
||||
environment.setCurrentBlock(current.toVector(0));
|
||||
final Vector2D scaled = current.subtract(zero2D).divide(unit2D);
|
||||
final Vector2 current = new Vector2(x, z);
|
||||
environment.setCurrentBlock(current.toVector3(0));
|
||||
final Vector2 scaled = current.subtract(zero2D).divide(unit2D);
|
||||
|
||||
try {
|
||||
if (expression.evaluate(scaled.getX(), scaled.getZ()) <= 0) {
|
||||
@ -2106,13 +2104,13 @@ public class EditSession implements Extent, AutoCloseable {
|
||||
return shape.generate(this, biomeType, hollow);
|
||||
}
|
||||
|
||||
private static final Vector[] recurseDirections = {
|
||||
Direction.NORTH.toVector(),
|
||||
Direction.EAST.toVector(),
|
||||
Direction.SOUTH.toVector(),
|
||||
Direction.WEST.toVector(),
|
||||
Direction.UP.toVector(),
|
||||
Direction.DOWN.toVector(),
|
||||
private static final BlockVector3[] recurseDirections = {
|
||||
Direction.NORTH.toBlockVector(),
|
||||
Direction.EAST.toBlockVector(),
|
||||
Direction.SOUTH.toBlockVector(),
|
||||
Direction.WEST.toBlockVector(),
|
||||
Direction.UP.toBlockVector(),
|
||||
Direction.DOWN.toBlockVector(),
|
||||
};
|
||||
|
||||
private static double lengthSq(double x, double y, double z) {
|
||||
|
Reference in New Issue
Block a user