Merge remote-tracking branch 'upstream/master' into breaking

This commit is contained in:
Jesse Boyd
2019-04-03 16:53:34 +11:00
281 changed files with 5963 additions and 5444 deletions

View File

@ -485,7 +485,7 @@ public class Vector2 {
}
Vector2 other = (Vector2) obj;
return other.getX() == this.getX() && other.getZ() == this.getZ();
return other.x == this.x && other.z == this.z;
}
@ -496,7 +496,7 @@ public class Vector2 {
@Override
public String toString() {
return "(" + getX() + ", " + getZ() + ")";
return "(" + x + ", " + z + ")";
}
}

View File

@ -622,13 +622,12 @@ public class Vector3 {
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (!(obj instanceof Vector3)) {
return false;
}
Vector3 other = (Vector3) obj;
return other.getX() == this.getX() && other.getZ() == this.getZ() && other.getY() == this.getY();
return other.x == this.x && other.y == this.y && other.z == this.z;
}
@Override

View File

@ -5,6 +5,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockState;
@ -18,6 +19,8 @@ import java.util.Iterator;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
/**
* Allows applications of Kernels onto the region's height map.
* <p>
@ -44,11 +47,11 @@ public class HeightMap {
this(session, region, false);
}
public HeightMap(EditSession session, Region region, boolean naturalOnly) {
this(session, region, naturalOnly, false);
public HeightMap(EditSession session, Region region, Mask mask) {
this(session, region, mask, false);
}
public HeightMap(EditSession session, Region region, boolean naturalOnly, boolean layers) {
public HeightMap(EditSession session, Region region, Mask mask, boolean layers) {
checkNotNull(session);
checkNotNull(region);
@ -80,35 +83,27 @@ public class HeightMap {
BlockVector2 pos = iter.next();
int x = pos.getBlockX();
int z = pos.getBlockZ();
layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY);
layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY, mask);
data[(z - bz) * width + (x - bx)] = layer;
}
} else {
// Store current heightmap data
int index = 0;
if (naturalOnly) {
for (int z = 0; z < height; ++z) {
for (int x = 0; x < width; ++x, index++) {
data[index] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY);
}
}
} else {
int yTmp = 255;
for (int z = 0; z < height; ++z) {
for (int x = 0; x < width; ++x, index++) {
yTmp = session.getNearestSurfaceTerrainBlock(x + minX, z + minZ, yTmp, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE);
switch (yTmp) {
case Integer.MIN_VALUE:
yTmp = minY;
invalid[index] = true;
break;
case Integer.MAX_VALUE:
yTmp = maxY;
invalid[index] = true;
break;
}
data[index] = yTmp;
int yTmp = 255;
for (int z = 0; z < height; ++z) {
for (int x = 0; x < width; ++x, index++) {
yTmp = session.getNearestSurfaceTerrainBlock(x + minX, z + minZ, yTmp, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE, mask);
switch (yTmp) {
case Integer.MIN_VALUE:
yTmp = minY;
invalid[index] = true;
break;
case Integer.MAX_VALUE:
yTmp = maxY;
invalid[index] = true;
break;
}
data[index] = yTmp;
}
}
}
@ -180,7 +175,6 @@ public class HeightMap {
// Depending on growing or shrinking we need to start at the bottom or top
if (newHeight > curHeight) {
// Set the top block of the column to be the same type (this might go wrong with rounding)
//<<<<<<< HEAD
BlockStateHolder existing = session.getBlock(xr, curBlock, zr);
// Skip water/lava
@ -200,34 +194,13 @@ public class HeightMap {
} else {
existing = PropertyGroup.LEVEL.set(existing, 15);
session.setBlock(xr, newBlock, zr, existing);
//=======
// BlockState existing = session.getBlock(BlockVector3.at(xr, curHeight, zr));
//
// // Skip water/lava
// if (existing.getBlockType() != BlockTypes.WATER && existing.getBlockType() != BlockTypes.LAVA) {
// session.setBlock(BlockVector3.at(xr, newHeight, zr), existing);
// ++blocksChanged;
//
// // Grow -- start from 1 below top replacing airblocks
// for (int y = newHeight - 1 - originY; y >= 0; --y) {
// int copyFrom = (int) (y * scale);
// session.setBlock(BlockVector3.at(xr, originY + y, zr), session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr)));
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
++blocksChanged;
}
}
} else if (curHeight > newHeight) {
//<<<<<<< HEAD
// Fill rest with air
for (int y = newBlock + 1; y <= ((curHeight + 15) >> 4); ++y) {
session.setBlock(xr, y, zr, fillerAir);
//=======
// // Shrink -- start from bottom
// for (int y = 0; y < newHeight - originY; ++y) {
// int copyFrom = (int) (y * scale);
// session.setBlock(BlockVector3.at(xr, originY + y, zr), session.getBlock(BlockVector3.at(xr, originY + copyFrom, zr)));
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
++blocksChanged;
}
// Set the top block of the column to be the same type

View File

@ -21,14 +21,15 @@
package com.sk89q.worldedit.math.interpolation;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.math.Vector3;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Reparametrises another interpolation function by arc length.
@ -38,7 +39,7 @@ import java.util.logging.Logger;
*/
public class ReparametrisingInterpolation implements Interpolation {
private static final Logger log = Logger.getLogger(ReparametrisingInterpolation.class.getCanonicalName());
private static final Logger log = LoggerFactory.getLogger(ReparametrisingInterpolation.class);
private final Interpolation baseInterpolation;
private double totalArcLength;
@ -102,7 +103,7 @@ public class ReparametrisingInterpolation implements Interpolation {
Entry<Double, Double> ceilingEntry = cache.ceilingEntry(arc);
if (ceilingEntry == null) {
log.warning("Error in arcToParameter: no ceiling entry for " + arc + " found!");
log.warn("Error in arcToParameter: no ceiling entry for " + arc + " found!");
return 0;
}
final double rightArc = ceilingEntry.getKey();

View File

@ -3,9 +3,9 @@ package com.sk89q.worldedit.math.transform;
import java.io.IOException;
import java.io.Serializable;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MathUtils;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.Vector3;
/**