mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-24 10:17:39 +00:00
fixed superpickaxe for gravel & lightstone, preprocessors faster than postprocessors, added methods so same-type changes are visble client-side, fixed fixliquid & setblocks block count
This commit is contained in:
parent
75660547d9
commit
66dcc99809
@ -178,7 +178,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
length = is.readInt();
|
length = is.readInt();
|
||||||
|
|
||||||
List<Tag> tagList = new ArrayList<Tag>();
|
List<Tag> tagList = new ArrayList<Tag>();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; ++i) {
|
||||||
Tag tag = readTagPayload(childType, "", depth + 1);
|
Tag tag = readTagPayload(childType, "", depth + 1);
|
||||||
if (tag instanceof EndTag) {
|
if (tag instanceof EndTag) {
|
||||||
throw new IOException("TAG_End not permitted in a list.");
|
throw new IOException("TAG_End not permitted in a list.");
|
||||||
|
@ -218,7 +218,7 @@ public final class NBTOutputStream implements Closeable {
|
|||||||
|
|
||||||
os.writeByte(NBTUtils.getTypeCode(clazz));
|
os.writeByte(NBTUtils.getTypeCode(clazz));
|
||||||
os.writeInt(size);
|
os.writeInt(size);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; ++i) {
|
||||||
writeTagPayload(tags.get(i));
|
writeTagPayload(tags.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@ public class CommandContext {
|
|||||||
|
|
||||||
public CommandContext(String[] args) {
|
public CommandContext(String[] args) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (; i < args.length; i++) {
|
for (; i < args.length; ++i) {
|
||||||
if (args[i].length() == 0) {
|
if (args[i].length() == 0) {
|
||||||
// Ignore this
|
// Ignore this
|
||||||
} else if (args[i].charAt(0) == '-' && args[i].matches("^-[a-zA-Z]+$")) {
|
} else if (args[i].charAt(0) == '-' && args[i].matches("^-[a-zA-Z]+$")) {
|
||||||
for (int k = 1; k < args[i].length(); k++) {
|
for (int k = 1; k < args[i].length(); ++k) {
|
||||||
flags.add(args[i].charAt(k));
|
flags.add(args[i].charAt(k));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -70,7 +70,7 @@ public class CommandContext {
|
|||||||
public String getJoinedStrings(int initialIndex) {
|
public String getJoinedStrings(int initialIndex) {
|
||||||
initialIndex = initialIndex + 1;
|
initialIndex = initialIndex + 1;
|
||||||
StringBuilder buffer = new StringBuilder(args[initialIndex]);
|
StringBuilder buffer = new StringBuilder(args[initialIndex]);
|
||||||
for (int i = initialIndex + 1; i < args.length; i++) {
|
for (int i = initialIndex + 1; i < args.length; ++i) {
|
||||||
buffer.append(" ").append(args[i]);
|
buffer.append(" ").append(args[i]);
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
@ -225,7 +225,7 @@ public abstract class CommandsManager<T> {
|
|||||||
|
|
||||||
command.append("/");
|
command.append("/");
|
||||||
|
|
||||||
for (int i = 0; i <= level; i++) {
|
for (int i = 0; i <= level; ++i) {
|
||||||
command.append(args[i] + " ");
|
command.append(args[i] + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ public abstract class CommandsManager<T> {
|
|||||||
|
|
||||||
command.append("/");
|
command.append("/");
|
||||||
|
|
||||||
for (int i = 0; i <= level; i++) {
|
for (int i = 0; i <= level; ++i) {
|
||||||
command.append(args[i] + " ");
|
command.append(args[i] + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class StringUtil {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuilder buffer = new StringBuilder(str[initialIndex]);
|
StringBuilder buffer = new StringBuilder(str[initialIndex]);
|
||||||
for (int i = initialIndex + 1; i < str.length; i++) {
|
for (int i = initialIndex + 1; i < str.length; ++i) {
|
||||||
buffer.append(delimiter).append(str[i]);
|
buffer.append(delimiter).append(str[i]);
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
@ -79,7 +79,7 @@ public class StringUtil {
|
|||||||
buffer.append(quote);
|
buffer.append(quote);
|
||||||
buffer.append(str[initialIndex]);
|
buffer.append(str[initialIndex]);
|
||||||
buffer.append(quote);
|
buffer.append(quote);
|
||||||
for (int i = initialIndex + 1; i < str.length; i++) {
|
for (int i = initialIndex + 1; i < str.length; ++i) {
|
||||||
buffer.append(delimiter).append(quote).append(str[i]).append(quote);
|
buffer.append(delimiter).append(quote).append(str[i]).append(quote);
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
@ -110,7 +110,7 @@ public class StringUtil {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuilder buffer = new StringBuilder(str[initialIndex].toString());
|
StringBuilder buffer = new StringBuilder(str[initialIndex].toString());
|
||||||
for (int i = initialIndex + 1; i < str.length; i++) {
|
for (int i = initialIndex + 1; i < str.length; ++i) {
|
||||||
buffer.append(delimiter).append(str[i].toString());
|
buffer.append(delimiter).append(str[i].toString());
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
@ -130,7 +130,7 @@ public class StringUtil {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuilder buffer = new StringBuilder(Integer.toString(str[initialIndex]));
|
StringBuilder buffer = new StringBuilder(Integer.toString(str[initialIndex]));
|
||||||
for (int i = initialIndex + 1; i < str.length; i++) {
|
for (int i = initialIndex + 1; i < str.length; ++i) {
|
||||||
buffer.append(delimiter).append(Integer.toString(str[i]));
|
buffer.append(delimiter).append(Integer.toString(str[i]));
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
@ -159,7 +159,7 @@ public class StringUtil {
|
|||||||
|
|
||||||
buffer.append(o.toString());
|
buffer.append(o.toString());
|
||||||
}
|
}
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
@ -244,15 +244,15 @@ public class StringUtil {
|
|||||||
|
|
||||||
int cost; // cost
|
int cost; // cost
|
||||||
|
|
||||||
for (i = 0; i <= n; i++) {
|
for (i = 0; i <= n; ++i) {
|
||||||
p[i] = i;
|
p[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 1; j <= m; j++) {
|
for (j = 1; j <= m; ++j) {
|
||||||
t_j = t.charAt(j - 1);
|
t_j = t.charAt(j - 1);
|
||||||
d[0] = j;
|
d[0] = j;
|
||||||
|
|
||||||
for (i = 1; i <= n; i++) {
|
for (i = 1; i <= n; ++i) {
|
||||||
cost = s.charAt(i - 1) == t_j ? 0 : 1;
|
cost = s.charAt(i - 1) == t_j ? 0 : 1;
|
||||||
// minimum of cell to the left+1, to the top+1, diagonally left
|
// minimum of cell to the left+1, to the top+1, diagonally left
|
||||||
// and up +cost
|
// and up +cost
|
||||||
|
@ -77,14 +77,14 @@ public class Countable<T> implements Comparable<Countable<T>> {
|
|||||||
* Decrement the amount.
|
* Decrement the amount.
|
||||||
*/
|
*/
|
||||||
public void decrement() {
|
public void decrement() {
|
||||||
this.amount--;
|
--this.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment the amount.
|
* Increment the amount.
|
||||||
*/
|
*/
|
||||||
public void increment() {
|
public void increment() {
|
||||||
this.amount++;
|
++this.amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,21 +140,21 @@ public class CuboidClipboard {
|
|||||||
[Math.abs(sizeRotated.getBlockY())]
|
[Math.abs(sizeRotated.getBlockY())]
|
||||||
[Math.abs(sizeRotated.getBlockZ())];
|
[Math.abs(sizeRotated.getBlockZ())];
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; ++x) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; ++z) {
|
||||||
Vector v = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0);
|
Vector v = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0);
|
||||||
int newX = v.getBlockX();
|
int newX = v.getBlockX();
|
||||||
int newZ = v.getBlockZ();
|
int newZ = v.getBlockZ();
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
BaseBlock block = data[x][y][z];
|
BaseBlock block = data[x][y][z];
|
||||||
newData[shiftX + newX][y][shiftZ + newZ] = block;
|
newData[shiftX + newX][y][shiftZ + newZ] = block;
|
||||||
|
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
for (int i = 0; i < numRotations; i++) {
|
for (int i = 0; i < numRotations; ++i) {
|
||||||
block.rotate90Reverse();
|
block.rotate90Reverse();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < numRotations; i++) {
|
for (int i = 0; i < numRotations; ++i) {
|
||||||
block.rotate90();
|
block.rotate90();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,9 +182,9 @@ public class CuboidClipboard {
|
|||||||
|
|
||||||
if (dir == FlipDirection.NORTH_SOUTH) {
|
if (dir == FlipDirection.NORTH_SOUTH) {
|
||||||
int len = (int)Math.floor(width / 2);
|
int len = (int)Math.floor(width / 2);
|
||||||
for (int xs = 0; xs < len; xs++) {
|
for (int xs = 0; xs < len; ++xs) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; ++z) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
BaseBlock old = data[xs][y][z];
|
BaseBlock old = data[xs][y][z];
|
||||||
old.flip();
|
old.flip();
|
||||||
data[xs][y][z] = data[width - xs - 1][y][z];
|
data[xs][y][z] = data[width - xs - 1][y][z];
|
||||||
@ -194,9 +194,9 @@ public class CuboidClipboard {
|
|||||||
}
|
}
|
||||||
} else if (dir == FlipDirection.WEST_EAST) {
|
} else if (dir == FlipDirection.WEST_EAST) {
|
||||||
int len = (int)Math.floor(length / 2);
|
int len = (int)Math.floor(length / 2);
|
||||||
for (int zs = 0; zs < len; zs++) {
|
for (int zs = 0; zs < len; ++zs) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; ++x) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
BaseBlock old = data[x][y][zs];
|
BaseBlock old = data[x][y][zs];
|
||||||
old.flip();
|
old.flip();
|
||||||
data[x][y][zs] = data[x][y][length - zs - 1];
|
data[x][y][zs] = data[x][y][length - zs - 1];
|
||||||
@ -206,9 +206,9 @@ public class CuboidClipboard {
|
|||||||
}
|
}
|
||||||
} else if (dir == FlipDirection.UP_DOWN) {
|
} else if (dir == FlipDirection.UP_DOWN) {
|
||||||
int len = (int)Math.floor(height / 2);
|
int len = (int)Math.floor(height / 2);
|
||||||
for (int ys = 0; ys < len; ys++) {
|
for (int ys = 0; ys < len; ++ys) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; ++x) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; ++z) {
|
||||||
BaseBlock old = data[x][ys][z];
|
BaseBlock old = data[x][ys][z];
|
||||||
data[x][ys][z] = data[x][height - ys - 1][z];
|
data[x][ys][z] = data[x][height - ys - 1][z];
|
||||||
data[x][height - ys - 1][z] = old;
|
data[x][height - ys - 1][z] = old;
|
||||||
@ -224,9 +224,9 @@ public class CuboidClipboard {
|
|||||||
* @param editSession
|
* @param editSession
|
||||||
*/
|
*/
|
||||||
public void copy(EditSession editSession) {
|
public void copy(EditSession editSession) {
|
||||||
for (int x = 0; x < size.getBlockX(); x++) {
|
for (int x = 0; x < size.getBlockX(); ++x) {
|
||||||
for (int y = 0; y < size.getBlockY(); y++) {
|
for (int y = 0; y < size.getBlockY(); ++y) {
|
||||||
for (int z = 0; z < size.getBlockZ(); z++) {
|
for (int z = 0; z < size.getBlockZ(); ++z) {
|
||||||
data[x][y][z] =
|
data[x][y][z] =
|
||||||
editSession.getBlock(new Vector(x, y, z).add(getOrigin()));
|
editSession.getBlock(new Vector(x, y, z).add(getOrigin()));
|
||||||
}
|
}
|
||||||
@ -257,9 +257,9 @@ public class CuboidClipboard {
|
|||||||
*/
|
*/
|
||||||
public void place(EditSession editSession, Vector pos, boolean noAir)
|
public void place(EditSession editSession, Vector pos, boolean noAir)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
for (int x = 0; x < size.getBlockX(); x++) {
|
for (int x = 0; x < size.getBlockX(); ++x) {
|
||||||
for (int y = 0; y < size.getBlockY(); y++) {
|
for (int y = 0; y < size.getBlockY(); ++y) {
|
||||||
for (int z = 0; z < size.getBlockZ(); z++) {
|
for (int z = 0; z < size.getBlockZ(); ++z) {
|
||||||
if (noAir && data[x][y][z].isAir())
|
if (noAir && data[x][y][z].isAir())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -330,9 +330,9 @@ public class CuboidClipboard {
|
|||||||
byte[] blockData = new byte[width * height * length];
|
byte[] blockData = new byte[width * height * length];
|
||||||
ArrayList<Tag> tileEntities = new ArrayList<Tag>();
|
ArrayList<Tag> tileEntities = new ArrayList<Tag>();
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; ++x) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; ++z) {
|
||||||
int index = y * width * length + z * width + x;
|
int index = y * width * length + z * width + x;
|
||||||
blocks[index] = (byte)data[x][y][z].getType();
|
blocks[index] = (byte)data[x][y][z].getType();
|
||||||
blockData[index] = (byte)data[x][y][z].getData();
|
blockData[index] = (byte)data[x][y][z].getData();
|
||||||
@ -476,9 +476,9 @@ public class CuboidClipboard {
|
|||||||
clipboard.setOrigin(origin);
|
clipboard.setOrigin(origin);
|
||||||
clipboard.setOffset(offset);
|
clipboard.setOffset(offset);
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; ++x) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; ++z) {
|
||||||
int index = y * width * length + z * width + x;
|
int index = y * width * length + z * width + x;
|
||||||
BlockVector pt = new BlockVector(x, y, z);
|
BlockVector pt = new BlockVector(x, y, z);
|
||||||
BaseBlock block;
|
BaseBlock block;
|
||||||
|
@ -208,20 +208,22 @@ public class EditSession {
|
|||||||
|
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
|
if (BlockType.usesData(id)) {
|
||||||
|
if (fastMode) {
|
||||||
|
result = world.setTypeIdAndDataFast(pt, type, block.getData());
|
||||||
|
} else {
|
||||||
|
result = world.setTypeIdAndData(pt, type, block.getData());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (fastMode) {
|
if (fastMode) {
|
||||||
result = world.setBlockTypeFast(pt, id);
|
result = world.setBlockTypeFast(pt, id);
|
||||||
} else {
|
} else {
|
||||||
result = world.setBlockType(pt, id);
|
result = world.setBlockType(pt, id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//System.out.println(pt + "" +result);
|
||||||
|
|
||||||
if (id != 0) {
|
if (id != 0) {
|
||||||
if (BlockType.usesData(id)) {
|
|
||||||
if (fastMode) {
|
|
||||||
world.setBlockDataFast(pt, block.getData());
|
|
||||||
} else {
|
|
||||||
world.setBlockData(pt, block.getData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Signs
|
// Signs
|
||||||
if (block instanceof SignBlock) {
|
if (block instanceof SignBlock) {
|
||||||
@ -249,7 +251,6 @@ public class EditSession {
|
|||||||
world.copyToWorld(pt, noteBlock);
|
world.copyToWorld(pt, noteBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,13 +337,15 @@ public class EditSession {
|
|||||||
// Place torches, etc. last
|
// Place torches, etc. last
|
||||||
if (BlockType.shouldPlaceLast(block.getType())) {
|
if (BlockType.shouldPlaceLast(block.getType())) {
|
||||||
queueLast.put(pt.toBlockVector(), block);
|
queueLast.put(pt.toBlockVector(), block);
|
||||||
return getBlockType(pt) != block.getType();
|
return !(getBlockType(pt) == block.getType()
|
||||||
|
&& getBlockData(pt) == block.getData());
|
||||||
// Destroy torches, etc. first
|
// Destroy torches, etc. first
|
||||||
} else if (BlockType.shouldPlaceLast(getBlockType(pt))) {
|
} else if (BlockType.shouldPlaceLast(getBlockType(pt))) {
|
||||||
rawSetBlock(pt, new BaseBlock(0));
|
rawSetBlock(pt, new BaseBlock(0));
|
||||||
} else {
|
} else {
|
||||||
queueAfter.put(pt.toBlockVector(), block);
|
queueAfter.put(pt.toBlockVector(), block);
|
||||||
return getBlockType(pt) != block.getType();
|
return !(getBlockType(pt) == block.getType()
|
||||||
|
&& getBlockData(pt) == block.getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,6 +394,20 @@ public class EditSession {
|
|||||||
return world.getBlockType(pt);
|
return world.getBlockType(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getBlockData(Vector pt) {
|
||||||
|
// In the case of the queue, the block may have not actually been
|
||||||
|
// changed yet
|
||||||
|
if (queued) {
|
||||||
|
/*
|
||||||
|
* BlockVector blockPt = pt.toBlockVector();
|
||||||
|
*
|
||||||
|
* if (current.containsKey(blockPt)) { return current.get(blockPt);
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
return world.getBlockData(pt);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the block type at a position x, y, z.
|
* Gets the block type at a position x, y, z.
|
||||||
*
|
*
|
||||||
@ -607,7 +624,7 @@ public class EditSession {
|
|||||||
|
|
||||||
if (getBlock(pt).isAir()) {
|
if (getBlock(pt).isAir()) {
|
||||||
if (setBlock(pt, block)) {
|
if (setBlock(pt, block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
@ -655,12 +672,12 @@ public class EditSession {
|
|||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (int y = cy; y >= minY; y--) {
|
for (int y = cy; y >= minY; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
if (getBlock(pt).isAir()) {
|
if (getBlock(pt).isAir()) {
|
||||||
setBlock(pt, block);
|
setBlock(pt, block);
|
||||||
affected++;
|
++affected;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -712,7 +729,7 @@ public class EditSession {
|
|||||||
|
|
||||||
if (getBlock(pt).isAir()) {
|
if (getBlock(pt).isAir()) {
|
||||||
if (setBlock(pt, pattern.next(pt))) {
|
if (setBlock(pt, pattern.next(pt))) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
@ -760,12 +777,12 @@ public class EditSession {
|
|||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (int y = cy; y >= minY; y--) {
|
for (int y = cy; y >= minY; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
if (getBlock(pt).isAir()) {
|
if (getBlock(pt).isAir()) {
|
||||||
setBlock(pt, pattern.next(pt));
|
setBlock(pt, pattern.next(pt));
|
||||||
affected++;
|
++affected;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -786,21 +803,21 @@ public class EditSession {
|
|||||||
public int removeAbove(Vector pos, int size, int height)
|
public int removeAbove(Vector pos, int size, int height)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
int maxY = Math.min(127, pos.getBlockY() + height - 1);
|
int maxY = Math.min(127, pos.getBlockY() + height - 1);
|
||||||
size--;
|
--size;
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
int oX = pos.getBlockX();
|
int oX = pos.getBlockX();
|
||||||
int oY = pos.getBlockY();
|
int oY = pos.getBlockY();
|
||||||
int oZ = pos.getBlockZ();
|
int oZ = pos.getBlockZ();
|
||||||
|
|
||||||
for (int x = oX - size; x <= oX + size; x++) {
|
for (int x = oX - size; x <= oX + size; ++x) {
|
||||||
for (int z = oZ - size; z <= oZ + size; z++) {
|
for (int z = oZ - size; z <= oZ + size; ++z) {
|
||||||
for (int y = oY; y <= maxY; y++) {
|
for (int y = oY; y <= maxY; ++y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
if (getBlockType(pt) != 0) {
|
if (getBlockType(pt) != 0) {
|
||||||
setBlock(pt, new BaseBlock(0));
|
setBlock(pt, new BaseBlock(0));
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -821,21 +838,21 @@ public class EditSession {
|
|||||||
public int removeBelow(Vector pos, int size, int height)
|
public int removeBelow(Vector pos, int size, int height)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
int minY = Math.max(0, pos.getBlockY() - height);
|
int minY = Math.max(0, pos.getBlockY() - height);
|
||||||
size--;
|
--size;
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
int oX = pos.getBlockX();
|
int oX = pos.getBlockX();
|
||||||
int oY = pos.getBlockY();
|
int oY = pos.getBlockY();
|
||||||
int oZ = pos.getBlockZ();
|
int oZ = pos.getBlockZ();
|
||||||
|
|
||||||
for (int x = oX - size; x <= oX + size; x++) {
|
for (int x = oX - size; x <= oX + size; ++x) {
|
||||||
for (int z = oZ - size; z <= oZ + size; z++) {
|
for (int z = oZ - size; z <= oZ + size; ++z) {
|
||||||
for (int y = oY; y >= minY; y--) {
|
for (int y = oY; y >= minY; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
if (getBlockType(pt) != 0) {
|
if (getBlockType(pt) != 0) {
|
||||||
setBlock(pt, new BaseBlock(0));
|
setBlock(pt, new BaseBlock(0));
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -865,14 +882,14 @@ public class EditSession {
|
|||||||
int minZ = pos.getBlockZ() - size;
|
int minZ = pos.getBlockZ() - size;
|
||||||
int maxZ = pos.getBlockZ() + size;
|
int maxZ = pos.getBlockZ() + size;
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector p = new Vector(x, y, z);
|
Vector p = new Vector(x, y, z);
|
||||||
|
|
||||||
if (getBlockType(p) == blockType) {
|
if (getBlockType(p) == blockType) {
|
||||||
if (setBlock(p, air)) {
|
if (setBlock(p, air)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -906,13 +923,13 @@ public class EditSession {
|
|||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
if (setBlock(pt, block)) {
|
if (setBlock(pt, block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -920,7 +937,7 @@ public class EditSession {
|
|||||||
} else {
|
} else {
|
||||||
for (Vector pt : region) {
|
for (Vector pt : region) {
|
||||||
if (setBlock(pt, block)) {
|
if (setBlock(pt, block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -952,13 +969,13 @@ public class EditSession {
|
|||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
if (setBlock(pt, pattern.next(pt))) {
|
if (setBlock(pt, pattern.next(pt))) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -966,7 +983,7 @@ public class EditSession {
|
|||||||
} else {
|
} else {
|
||||||
for (Vector pt : region) {
|
for (Vector pt : region) {
|
||||||
if (setBlock(pt, pattern.next(pt))) {
|
if (setBlock(pt, pattern.next(pt))) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -999,9 +1016,9 @@ public class EditSession {
|
|||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
int curBlockType = getBlockType(pt);
|
int curBlockType = getBlockType(pt);
|
||||||
|
|
||||||
@ -1009,7 +1026,7 @@ public class EditSession {
|
|||||||
|| (fromBlockTypes != null && fromBlockTypes
|
|| (fromBlockTypes != null && fromBlockTypes
|
||||||
.contains(curBlockType))) {
|
.contains(curBlockType))) {
|
||||||
if (setBlock(pt, toBlock)) {
|
if (setBlock(pt, toBlock)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1022,7 +1039,7 @@ public class EditSession {
|
|||||||
if (fromBlockTypes == null && curBlockType != 0
|
if (fromBlockTypes == null && curBlockType != 0
|
||||||
|| fromBlockTypes.contains(curBlockType)) {
|
|| fromBlockTypes.contains(curBlockType)) {
|
||||||
if (setBlock(pt, toBlock)) {
|
if (setBlock(pt, toBlock)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1056,9 +1073,9 @@ public class EditSession {
|
|||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
int curBlockType = getBlockType(pt);
|
int curBlockType = getBlockType(pt);
|
||||||
|
|
||||||
@ -1066,7 +1083,7 @@ public class EditSession {
|
|||||||
|| (fromBlockTypes != null && fromBlockTypes
|
|| (fromBlockTypes != null && fromBlockTypes
|
||||||
.contains(curBlockType))) {
|
.contains(curBlockType))) {
|
||||||
if (setBlock(pt, pattern.next(pt))) {
|
if (setBlock(pt, pattern.next(pt))) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1079,7 +1096,7 @@ public class EditSession {
|
|||||||
if (fromBlockTypes == null && curBlockType != 0
|
if (fromBlockTypes == null && curBlockType != 0
|
||||||
|| fromBlockTypes.contains(curBlockType)) {
|
|| fromBlockTypes.contains(curBlockType)) {
|
||||||
if (setBlock(pt, pattern.next(pt))) {
|
if (setBlock(pt, pattern.next(pt))) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1110,36 +1127,36 @@ public class EditSession {
|
|||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
if (setBlock(new Vector(x, y, minZ), block)) {
|
if (setBlock(new Vector(x, y, minZ), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(new Vector(x, y, maxZ), block)) {
|
if (setBlock(new Vector(x, y, maxZ), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
if (setBlock(new Vector(minX, y, z), block)) {
|
if (setBlock(new Vector(minX, y, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(new Vector(maxX, y, z), block)) {
|
if (setBlock(new Vector(maxX, y, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
if (setBlock(new Vector(x, minY, z), block)) {
|
if (setBlock(new Vector(x, minY, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(new Vector(x, maxY, z), block)) {
|
if (setBlock(new Vector(x, maxY, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1169,25 +1186,25 @@ public class EditSession {
|
|||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
if (setBlock(new Vector(x, y, minZ), block)) {
|
if (setBlock(new Vector(x, y, minZ), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(new Vector(x, y, maxZ), block)) {
|
if (setBlock(new Vector(x, y, maxZ), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
if (setBlock(new Vector(minX, y, z), block)) {
|
if (setBlock(new Vector(minX, y, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(new Vector(maxX, y, z), block)) {
|
if (setBlock(new Vector(maxX, y, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1218,15 +1235,15 @@ public class EditSession {
|
|||||||
int maxX = max.getBlockX();
|
int maxX = max.getBlockX();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
for (int y = upperY; y >= lowerY; y--) {
|
for (int y = upperY; y >= lowerY; --y) {
|
||||||
Vector above = new Vector(x, y + 1, z);
|
Vector above = new Vector(x, y + 1, z);
|
||||||
|
|
||||||
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
|
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
|
||||||
&& getBlock(above).isAir()) {
|
&& getBlock(above).isAir()) {
|
||||||
if (setBlock(above, block)) {
|
if (setBlock(above, block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1260,15 +1277,15 @@ public class EditSession {
|
|||||||
int maxX = max.getBlockX();
|
int maxX = max.getBlockX();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
for (int y = upperY; y >= lowerY; y--) {
|
for (int y = upperY; y >= lowerY; --y) {
|
||||||
Vector above = new Vector(x, y + 1, z);
|
Vector above = new Vector(x, y + 1, z);
|
||||||
|
|
||||||
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
|
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
|
||||||
&& getBlock(above).isAir()) {
|
&& getBlock(above).isAir()) {
|
||||||
if (setBlock(above, pattern.next(above))) {
|
if (setBlock(above, pattern.next(above))) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1307,19 +1324,19 @@ public class EditSession {
|
|||||||
int ys = region.getHeight();
|
int ys = region.getHeight();
|
||||||
int zs = region.getLength();
|
int zs = region.getLength();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
BaseBlock block = getBlock(new Vector(x, y, z));
|
BaseBlock block = getBlock(new Vector(x, y, z));
|
||||||
|
|
||||||
if (!block.isAir() || copyAir) {
|
if (!block.isAir() || copyAir) {
|
||||||
for (int i = 1; i <= count; i++) {
|
for (int i = 1; i <= count; ++i) {
|
||||||
Vector pos = new Vector(x + xs * dir.getBlockX()
|
Vector pos = new Vector(x + xs * dir.getBlockX()
|
||||||
* i, y + ys * dir.getBlockY() * i, z + zs
|
* i, y + ys * dir.getBlockY() * i, z + zs
|
||||||
* dir.getBlockZ() * i);
|
* dir.getBlockZ() * i);
|
||||||
|
|
||||||
if (setBlock(pos, block)) {
|
if (setBlock(pos, block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1362,9 +1379,9 @@ public class EditSession {
|
|||||||
|
|
||||||
Map<Vector, BaseBlock> delayed = new LinkedHashMap<Vector, BaseBlock>();
|
Map<Vector, BaseBlock> delayed = new LinkedHashMap<Vector, BaseBlock>();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
Vector pos = new Vector(x, y, z);
|
Vector pos = new Vector(x, y, z);
|
||||||
BaseBlock block = getBlock(pos);
|
BaseBlock block = getBlock(pos);
|
||||||
|
|
||||||
@ -1390,7 +1407,7 @@ public class EditSession {
|
|||||||
|
|
||||||
for (Map.Entry<Vector, BaseBlock> entry : delayed.entrySet()) {
|
for (Map.Entry<Vector, BaseBlock> entry : delayed.entrySet()) {
|
||||||
setBlock(entry.getKey(), entry.getValue());
|
setBlock(entry.getKey(), entry.getValue());
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
return affected;
|
return affected;
|
||||||
@ -1411,9 +1428,9 @@ public class EditSession {
|
|||||||
HashSet<BlockVector> visited = new HashSet<BlockVector>();
|
HashSet<BlockVector> visited = new HashSet<BlockVector>();
|
||||||
Stack<BlockVector> queue = new Stack<BlockVector>();
|
Stack<BlockVector> queue = new Stack<BlockVector>();
|
||||||
|
|
||||||
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
|
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; ++x) {
|
||||||
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
|
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; ++z) {
|
||||||
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
|
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; ++y) {
|
||||||
queue.push(new BlockVector(x, y, z));
|
queue.push(new BlockVector(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1441,9 +1458,9 @@ public class EditSession {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = cur.getBlockX() - 1; x <= cur.getBlockX() + 1; x++) {
|
for (int x = cur.getBlockX() - 1; x <= cur.getBlockX() + 1; ++x) {
|
||||||
for (int z = cur.getBlockZ() - 1; z <= cur.getBlockZ() + 1; z++) {
|
for (int z = cur.getBlockZ() - 1; z <= cur.getBlockZ() + 1; ++z) {
|
||||||
for (int y = cur.getBlockY() - 1; y <= cur.getBlockY() + 1; y++) {
|
for (int y = cur.getBlockY() - 1; y <= cur.getBlockY() + 1; ++y) {
|
||||||
BlockVector newPos = new BlockVector(x, y, z);
|
BlockVector newPos = new BlockVector(x, y, z);
|
||||||
|
|
||||||
if (!cur.equals(newPos)) {
|
if (!cur.equals(newPos)) {
|
||||||
@ -1454,7 +1471,7 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setBlock(cur, new BaseBlock(0))) {
|
if (setBlock(cur, new BaseBlock(0))) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1478,9 +1495,9 @@ public class EditSession {
|
|||||||
HashSet<BlockVector> visited = new HashSet<BlockVector>();
|
HashSet<BlockVector> visited = new HashSet<BlockVector>();
|
||||||
Stack<BlockVector> queue = new Stack<BlockVector>();
|
Stack<BlockVector> queue = new Stack<BlockVector>();
|
||||||
|
|
||||||
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
|
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; ++x) {
|
||||||
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
|
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; ++z) {
|
||||||
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
|
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; ++y) {
|
||||||
int type = getBlock(new Vector(x, y, z)).getType();
|
int type = getBlock(new Vector(x, y, z)).getType();
|
||||||
|
|
||||||
// Check block type
|
// Check block type
|
||||||
@ -1510,8 +1527,8 @@ public class EditSession {
|
|||||||
|
|
||||||
visited.add(cur);
|
visited.add(cur);
|
||||||
|
|
||||||
if (setBlock(cur, stationaryBlock)) {
|
if (setBlock(cur, stationaryBlock)){
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check radius
|
// Check radius
|
||||||
@ -1543,7 +1560,7 @@ public class EditSession {
|
|||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
setBlock(center.add(0, y, z), block);
|
setBlock(center.add(0, y, z), block);
|
||||||
setBlock(center.add(0, y, -z), block);
|
setBlock(center.add(0, y, -z), block);
|
||||||
setBlock(center.add(z, y, 0), block);
|
setBlock(center.add(z, y, 0), block);
|
||||||
@ -1551,7 +1568,7 @@ public class EditSession {
|
|||||||
affected += 4;
|
affected += 4;
|
||||||
}
|
}
|
||||||
} else if (x == z) {
|
} else if (x == z) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
setBlock(center.add(x, y, z), block);
|
setBlock(center.add(x, y, z), block);
|
||||||
setBlock(center.add(-x, y, z), block);
|
setBlock(center.add(-x, y, z), block);
|
||||||
setBlock(center.add(x, y, -z), block);
|
setBlock(center.add(x, y, -z), block);
|
||||||
@ -1559,7 +1576,7 @@ public class EditSession {
|
|||||||
affected += 4;
|
affected += 4;
|
||||||
}
|
}
|
||||||
} else if (x < z) {
|
} else if (x < z) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
setBlock(center.add(x, y, z), block);
|
setBlock(center.add(x, y, z), block);
|
||||||
setBlock(center.add(-x, y, z), block);
|
setBlock(center.add(-x, y, z), block);
|
||||||
setBlock(center.add(x, y, -z), block);
|
setBlock(center.add(x, y, -z), block);
|
||||||
@ -1608,11 +1625,10 @@ public class EditSession {
|
|||||||
affected += makeHCylinderPoints(pos, x, z, height, block);
|
affected += makeHCylinderPoints(pos, x, z, height, block);
|
||||||
|
|
||||||
while (x < z) {
|
while (x < z) {
|
||||||
x++;
|
++x;
|
||||||
|
|
||||||
if (d >= 0) {
|
if (d >= 0) {
|
||||||
z--;
|
d += 2 * (x - --z) + 1;
|
||||||
d += 2 * (x - z) + 1;
|
|
||||||
} else {
|
} else {
|
||||||
d += 2 * x + 1;
|
d += 2 * x + 1;
|
||||||
}
|
}
|
||||||
@ -1638,19 +1654,19 @@ public class EditSession {
|
|||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
if (x == z) {
|
if (x == z) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
for (int z2 = -z; z2 <= z; z2++) {
|
for (int z2 = -z; z2 <= z; ++z2) {
|
||||||
setBlock(center.add(x, y, z2), block);
|
setBlock(center.add(x, y, z2), block);
|
||||||
setBlock(center.add(-x, y, z2), block);
|
setBlock(center.add(-x, y, z2), block);
|
||||||
affected += 2;
|
affected += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (x < z) {
|
} else if (x < z) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
for (int x2 = -x; x2 <= x; x2++) {
|
for (int x2 = -x; x2 <= x; ++x2) {
|
||||||
for (int z2 = -z; z2 <= z; z2++) {
|
for (int z2 = -z; z2 <= z; ++z2) {
|
||||||
setBlock(center.add(x2, y, z2), block);
|
setBlock(center.add(x2, y, z2), block);
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
setBlock(center.add(z, y, x2), block);
|
setBlock(center.add(z, y, x2), block);
|
||||||
setBlock(center.add(-z, y, x2), block);
|
setBlock(center.add(-z, y, x2), block);
|
||||||
@ -1695,11 +1711,10 @@ public class EditSession {
|
|||||||
affected += makeCylinderPoints(pos, x, z, height, block);
|
affected += makeCylinderPoints(pos, x, z, height, block);
|
||||||
|
|
||||||
while (x < z) {
|
while (x < z) {
|
||||||
x++;
|
++x;
|
||||||
|
|
||||||
if (d >= 0) {
|
if (d >= 0) {
|
||||||
z--;
|
d += 2 * (x - --z) + 1;
|
||||||
d += 2 * (x - z) + 1;
|
|
||||||
} else {
|
} else {
|
||||||
d += 2 * x + 1;
|
d += 2 * x + 1;
|
||||||
}
|
}
|
||||||
@ -1724,36 +1739,36 @@ public class EditSession {
|
|||||||
boolean filled) throws MaxChangedBlocksException {
|
boolean filled) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (int x = 0; x <= radius; x++) {
|
for (int x = 0; x <= radius; ++x) {
|
||||||
for (int y = 0; y <= radius; y++) {
|
for (int y = 0; y <= radius; ++y) {
|
||||||
for (int z = 0; z <= radius; z++) {
|
for (int z = 0; z <= radius; ++z) {
|
||||||
Vector vec = pos.add(x, y, z);
|
Vector vec = pos.add(x, y, z);
|
||||||
double d = vec.distance(pos);
|
double d = vec.distance(pos);
|
||||||
|
|
||||||
if (d <= radius + 0.5 && (filled || d >= radius - 0.5)) {
|
if (d <= radius + 0.5 && (filled || d >= radius - 0.5)) {
|
||||||
if (setBlock(vec, block)) {
|
if (setBlock(vec, block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(pos.add(-x, y, z), block)) {
|
if (setBlock(pos.add(-x, y, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(pos.add(x, -y, z), block)) {
|
if (setBlock(pos.add(x, -y, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(pos.add(x, y, -z), block)) {
|
if (setBlock(pos.add(x, y, -z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(pos.add(-x, -y, z), block)) {
|
if (setBlock(pos.add(-x, -y, z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(pos.add(x, -y, -z), block)) {
|
if (setBlock(pos.add(x, -y, -z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(pos.add(-x, y, -z), block)) {
|
if (setBlock(pos.add(-x, y, -z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
if (setBlock(pos.add(-x, -y, -z), block)) {
|
if (setBlock(pos.add(-x, -y, -z), block)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1783,23 +1798,23 @@ public class EditSession {
|
|||||||
BaseBlock air = new BaseBlock(0);
|
BaseBlock air = new BaseBlock(0);
|
||||||
BaseBlock water = new BaseBlock(BlockID.STATIONARY_WATER);
|
BaseBlock water = new BaseBlock(BlockID.STATIONARY_WATER);
|
||||||
|
|
||||||
for (int x = ox - radius; x <= ox + radius; x++) {
|
for (int x = ox - radius; x <= ox + radius; ++x) {
|
||||||
for (int z = oz - radius; z <= oz + radius; z++) {
|
for (int z = oz - radius; z <= oz + radius; ++z) {
|
||||||
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
|
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = 127; y >= 1; y--) {
|
for (int y = 127; y >= 1; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
int id = getBlockType(pt);
|
int id = getBlockType(pt);
|
||||||
|
|
||||||
if (id == BlockID.ICE) { // Ice
|
if (id == BlockID.ICE) { // Ice
|
||||||
if (setBlock(pt, water)) {
|
if (setBlock(pt, water)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
} else if (id == BlockID.SNOW) {
|
} else if (id == BlockID.SNOW) {
|
||||||
if (setBlock(pt, air)) {
|
if (setBlock(pt, air)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
} else if (id != 0) {
|
} else if (id != 0) {
|
||||||
break;
|
break;
|
||||||
@ -1831,13 +1846,13 @@ public class EditSession {
|
|||||||
BaseBlock ice = new BaseBlock(79);
|
BaseBlock ice = new BaseBlock(79);
|
||||||
BaseBlock snow = new BaseBlock(78);
|
BaseBlock snow = new BaseBlock(78);
|
||||||
|
|
||||||
for (int x = ox - radius; x <= ox + radius; x++) {
|
for (int x = ox - radius; x <= ox + radius; ++x) {
|
||||||
for (int z = oz - radius; z <= oz + radius; z++) {
|
for (int z = oz - radius; z <= oz + radius; ++z) {
|
||||||
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
|
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = 127; y >= 1; y--) {
|
for (int y = 127; y >= 1; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
int id = getBlockType(pt);
|
int id = getBlockType(pt);
|
||||||
|
|
||||||
@ -1871,7 +1886,7 @@ public class EditSession {
|
|||||||
// Ice!
|
// Ice!
|
||||||
if (id == 8 || id == 9) {
|
if (id == 8 || id == 9) {
|
||||||
if (setBlock(pt, ice)) {
|
if (setBlock(pt, ice)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1883,7 +1898,7 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setBlock(pt.add(0, 1, 0), snow)) {
|
if (setBlock(pt.add(0, 1, 0), snow)) {
|
||||||
affected++;
|
++affected;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1943,7 +1958,7 @@ public class EditSession {
|
|||||||
if (getBlockType(pos) != 0)
|
if (getBlockType(pos) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = -1; i > -3; i--) {
|
for (int i = -1; i > -3; --i) {
|
||||||
Vector testPos = pos.add(0, i, 0);
|
Vector testPos = pos.add(0, i, 0);
|
||||||
if (getBlockType(testPos) == 0) {
|
if (getBlockType(testPos) == 0) {
|
||||||
pos = testPos;
|
pos = testPos;
|
||||||
@ -1997,9 +2012,9 @@ public class EditSession {
|
|||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX()
|
for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX()
|
||||||
+ size; x++) {
|
+ size; ++x) {
|
||||||
for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ()
|
for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ()
|
||||||
+ size; z++) {
|
+ size; ++z) {
|
||||||
// Don't want to be in the ground
|
// Don't want to be in the ground
|
||||||
if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir())
|
if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir())
|
||||||
continue;
|
continue;
|
||||||
@ -2008,12 +2023,12 @@ public class EditSession {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; y--) {
|
for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; --y) {
|
||||||
// Check if we hit the ground
|
// Check if we hit the ground
|
||||||
int t = getBlock(new Vector(x, y, z)).getType();
|
int t = getBlock(new Vector(x, y, z)).getType();
|
||||||
if (t == 2 || t == 3) {
|
if (t == 2 || t == 3) {
|
||||||
makePumpkinPatch(new Vector(x, y + 1, z));
|
makePumpkinPatch(new Vector(x, y + 1, z));
|
||||||
affected++;
|
++affected;
|
||||||
break;
|
break;
|
||||||
} else if (t != 0) { // Trees won't grow on this!
|
} else if (t != 0) { // Trees won't grow on this!
|
||||||
break;
|
break;
|
||||||
@ -2040,9 +2055,9 @@ public class EditSession {
|
|||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX()
|
for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX()
|
||||||
+ size; x++) {
|
+ size; ++x) {
|
||||||
for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ()
|
for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ()
|
||||||
+ size; z++) {
|
+ size; ++z) {
|
||||||
// Don't want to be in the ground
|
// Don't want to be in the ground
|
||||||
if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir())
|
if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir())
|
||||||
continue;
|
continue;
|
||||||
@ -2051,12 +2066,12 @@ public class EditSession {
|
|||||||
continue;
|
continue;
|
||||||
} // def 0.05
|
} // def 0.05
|
||||||
|
|
||||||
for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; y--) {
|
for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; --y) {
|
||||||
// Check if we hit the ground
|
// Check if we hit the ground
|
||||||
int t = getBlock(new Vector(x, y, z)).getType();
|
int t = getBlock(new Vector(x, y, z)).getType();
|
||||||
if (t == 2 || t == 3) {
|
if (t == 2 || t == 3) {
|
||||||
treeGenerator.generate(this, new Vector(x, y + 1, z));
|
treeGenerator.generate(this, new Vector(x, y + 1, z));
|
||||||
affected++;
|
++affected;
|
||||||
break;
|
break;
|
||||||
} else if (t != 0) { // Trees won't grow on this!
|
} else if (t != 0) { // Trees won't grow on this!
|
||||||
break;
|
break;
|
||||||
@ -2090,13 +2105,13 @@ public class EditSession {
|
|||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
if (searchIDs.contains(getBlockType(pt))) {
|
if (searchIDs.contains(getBlockType(pt))) {
|
||||||
count++;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2104,7 +2119,7 @@ public class EditSession {
|
|||||||
} else {
|
} else {
|
||||||
for (Vector pt : region) {
|
for (Vector pt : region) {
|
||||||
if (searchIDs.contains(getBlockType(pt))) {
|
if (searchIDs.contains(getBlockType(pt))) {
|
||||||
count++;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2134,9 +2149,9 @@ public class EditSession {
|
|||||||
int maxY = max.getBlockY();
|
int maxY = max.getBlockY();
|
||||||
int maxZ = max.getBlockZ();
|
int maxZ = max.getBlockZ();
|
||||||
|
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; ++x) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
int id = getBlockType(pt);
|
int id = getBlockType(pt);
|
||||||
@ -2184,7 +2199,7 @@ public class EditSession {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||||
for (int y = maxY; y >= minY; y--) {
|
for (int y = maxY; y >= minY; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
int id = getBlockType(pt);
|
int id = getBlockType(pt);
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ public class HeightMap {
|
|||||||
|
|
||||||
// Store current heightmap data
|
// Store current heightmap data
|
||||||
data = new int[width * height];
|
data = new int[width * height];
|
||||||
for (int z = 0; z < height; z++) {
|
for (int z = 0; z < height; ++z) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; ++x) {
|
||||||
data[z * width + x] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY);
|
data[z * width + x] = session.getHighestTerrainBlock(x + minX, z + minZ, minY, maxY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class HeightMap {
|
|||||||
int[] newData = new int[data.length];
|
int[] newData = new int[data.length];
|
||||||
System.arraycopy(data, 0, newData, 0, data.length);
|
System.arraycopy(data, 0, newData, 0, data.length);
|
||||||
|
|
||||||
for (int i = 0; i < iterations; i++)
|
for (int i = 0; i < iterations; ++i)
|
||||||
newData = filter.filter(newData, width, height);
|
newData = filter.filter(newData, width, height);
|
||||||
|
|
||||||
return apply(newData);
|
return apply(newData);
|
||||||
@ -104,8 +104,8 @@ public class HeightMap {
|
|||||||
int blocksChanged = 0;
|
int blocksChanged = 0;
|
||||||
|
|
||||||
// Apply heightmap
|
// Apply heightmap
|
||||||
for (int z = 0; z < height; z++) {
|
for (int z = 0; z < height; ++z) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; ++x) {
|
||||||
int index = z * width + x;
|
int index = z * width + x;
|
||||||
int curHeight = this.data[index];
|
int curHeight = this.data[index];
|
||||||
|
|
||||||
@ -127,32 +127,32 @@ public class HeightMap {
|
|||||||
// Skip water/lava
|
// Skip water/lava
|
||||||
if (existing.getType() < 8 || existing.getType() > 11) {
|
if (existing.getType() < 8 || existing.getType() > 11) {
|
||||||
session.setBlock(new Vector(X, newHeight, Z), existing);
|
session.setBlock(new Vector(X, newHeight, Z), existing);
|
||||||
blocksChanged++;
|
++blocksChanged;
|
||||||
|
|
||||||
// Grow -- start from 1 below top replacing airblocks
|
// Grow -- start from 1 below top replacing airblocks
|
||||||
for (int y = newHeight - 1 - originY; y >= 0; y--) {
|
for (int y = newHeight - 1 - originY; y >= 0; --y) {
|
||||||
int copyFrom = (int) (y * scale);
|
int copyFrom = (int) (y * scale);
|
||||||
session.setBlock(new Vector(X, originY + y, Z), session.getBlock(new Vector(X, originY + copyFrom, Z)));
|
session.setBlock(new Vector(X, originY + y, Z), session.getBlock(new Vector(X, originY + copyFrom, Z)));
|
||||||
blocksChanged++;
|
++blocksChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (curHeight > newHeight) {
|
} else if (curHeight > newHeight) {
|
||||||
// Shrink -- start from bottom
|
// Shrink -- start from bottom
|
||||||
for (int y = 0; y < newHeight - originY; y++) {
|
for (int y = 0; y < newHeight - originY; ++y) {
|
||||||
int copyFrom = (int) (y * scale);
|
int copyFrom = (int) (y * scale);
|
||||||
session.setBlock(new Vector(X, originY + y, Z), session.getBlock(new Vector(X, originY + copyFrom, Z)));
|
session.setBlock(new Vector(X, originY + y, Z), session.getBlock(new Vector(X, originY + copyFrom, Z)));
|
||||||
blocksChanged++;
|
++blocksChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the top block of the column to be the same type
|
// Set the top block of the column to be the same type
|
||||||
// (this could otherwise go wrong with rounding)
|
// (this could otherwise go wrong with rounding)
|
||||||
session.setBlock(new Vector(X, newHeight, Z), session.getBlock(new Vector(X, curHeight, Z)));
|
session.setBlock(new Vector(X, newHeight, Z), session.getBlock(new Vector(X, curHeight, Z)));
|
||||||
blocksChanged++;
|
++blocksChanged;
|
||||||
|
|
||||||
// Fill rest with air
|
// Fill rest with air
|
||||||
for (int y = newHeight + 1; y <= curHeight; y++) {
|
for (int y = newHeight + 1; y <= curHeight; ++y) {
|
||||||
session.setBlock(new Vector(X, y, Z), fillerAir);
|
session.setBlock(new Vector(X, y, Z), fillerAir);
|
||||||
blocksChanged++;
|
++blocksChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public abstract class LocalPlayer {
|
|||||||
|
|
||||||
while (y <= 129) {
|
while (y <= 129) {
|
||||||
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
||||||
free++;
|
++free;
|
||||||
} else {
|
} else {
|
||||||
free = 0;
|
free = 0;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ public abstract class LocalPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
y++;
|
++y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ public abstract class LocalPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
y--;
|
--y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,13 +139,13 @@ public abstract class LocalPlayer {
|
|||||||
|
|
||||||
while (y <= 129) {
|
while (y <= 129) {
|
||||||
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
||||||
free++;
|
++free;
|
||||||
} else {
|
} else {
|
||||||
free = 0;
|
free = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (free == 2) {
|
if (free == 2) {
|
||||||
spots++;
|
++spots;
|
||||||
if (spots == 2) {
|
if (spots == 2) {
|
||||||
int type = world.getBlockType(new Vector(x, y - 2, z));
|
int type = world.getBlockType(new Vector(x, y - 2, z));
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ public abstract class LocalPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y++;
|
++y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -181,7 +181,7 @@ public abstract class LocalPlayer {
|
|||||||
|
|
||||||
while (y >= 1) {
|
while (y >= 1) {
|
||||||
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
|
||||||
free++;
|
++free;
|
||||||
} else {
|
} else {
|
||||||
free = 0;
|
free = 0;
|
||||||
}
|
}
|
||||||
@ -200,13 +200,13 @@ public abstract class LocalPlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
y--;
|
--y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
y--;
|
--y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -241,7 +241,7 @@ public abstract class LocalPlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
y++;
|
++y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -274,7 +274,7 @@ public abstract class LocalPlayer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
y++;
|
++y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -462,19 +462,19 @@ public abstract class LocalPlayer {
|
|||||||
firstBlock = false;
|
firstBlock = false;
|
||||||
|
|
||||||
if (!free) {
|
if (!free) {
|
||||||
freeToFind--;
|
--freeToFind;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchDist++;
|
++searchDist;
|
||||||
if (searchDist > 20) {
|
if (searchDist > 20) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inFree != free) {
|
if (inFree != free) {
|
||||||
if (free) {
|
if (free) {
|
||||||
freeToFind--;
|
--freeToFind;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ public class LocalSession {
|
|||||||
* @return whether anything was undone
|
* @return whether anything was undone
|
||||||
*/
|
*/
|
||||||
public EditSession undo(BlockBag newBlockBag) {
|
public EditSession undo(BlockBag newBlockBag) {
|
||||||
historyPointer--;
|
--historyPointer;
|
||||||
if (historyPointer >= 0) {
|
if (historyPointer >= 0) {
|
||||||
EditSession editSession = history.get(historyPointer);
|
EditSession editSession = history.get(historyPointer);
|
||||||
EditSession newEditSession =
|
EditSession newEditSession =
|
||||||
@ -170,7 +170,7 @@ public class LocalSession {
|
|||||||
newEditSession.enableQueue();
|
newEditSession.enableQueue();
|
||||||
newEditSession.setFastMode(fastMode);
|
newEditSession.setFastMode(fastMode);
|
||||||
editSession.redo(newEditSession);
|
editSession.redo(newEditSession);
|
||||||
historyPointer++;
|
++historyPointer;
|
||||||
return editSession;
|
return editSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +591,7 @@ public class LocalSession {
|
|||||||
player.dispatchCUIEvent(
|
player.dispatchCUIEvent(
|
||||||
new SelectionPointEvent(i, pt, size));
|
new SelectionPointEvent(i, pt, size));
|
||||||
}
|
}
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ public abstract class LocalWorld {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract void setBlockData(Vector pt, int data);
|
public abstract void setBlockData(Vector pt, int data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,9 +78,25 @@ public abstract class LocalWorld {
|
|||||||
* @param pt
|
* @param pt
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
public void setBlockDataFast(Vector pt, int data) {
|
public abstract void setBlockDataFast(Vector pt, int data);
|
||||||
setBlockData(pt, data);
|
|
||||||
}
|
/**
|
||||||
|
* set block type & data
|
||||||
|
* @param pt
|
||||||
|
* @param type
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract boolean setTypeIdAndData(Vector pt, int type, int data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set block type & data
|
||||||
|
* @param pt
|
||||||
|
* @param type
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract boolean setTypeIdAndDataFast(Vector pt, int type, int data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get block data.
|
* Get block data.
|
||||||
@ -195,7 +212,7 @@ public abstract class LocalWorld {
|
|||||||
* @param times
|
* @param times
|
||||||
*/
|
*/
|
||||||
public void dropItem(Vector pt, BaseItemStack item, int times) {
|
public void dropItem(Vector pt, BaseItemStack item, int times) {
|
||||||
for (int i = 0; i < times; i++) {
|
for (int i = 0; i < times; ++i) {
|
||||||
dropItem(pt, item);
|
dropItem(pt, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ public class Vector {
|
|||||||
public Vector add(Vector ... others) {
|
public Vector add(Vector ... others) {
|
||||||
double newX = x, newY = y, newZ = z;
|
double newX = x, newY = y, newZ = z;
|
||||||
|
|
||||||
for (int i = 0; i < others.length; i++) {
|
for (int i = 0; i < others.length; ++i) {
|
||||||
newX += others[i].x;
|
newX += others[i].x;
|
||||||
newY += others[i].y;
|
newY += others[i].y;
|
||||||
newZ += others[i].z;
|
newZ += others[i].z;
|
||||||
@ -281,7 +281,7 @@ public class Vector {
|
|||||||
public Vector subtract(Vector ... others) {
|
public Vector subtract(Vector ... others) {
|
||||||
double newX = x, newY = y, newZ = z;
|
double newX = x, newY = y, newZ = z;
|
||||||
|
|
||||||
for (int i = 0; i < others.length; i++) {
|
for (int i = 0; i < others.length; ++i) {
|
||||||
newX -= others[i].x;
|
newX -= others[i].x;
|
||||||
newY -= others[i].y;
|
newY -= others[i].y;
|
||||||
newZ -= others[i].z;
|
newZ -= others[i].z;
|
||||||
@ -332,7 +332,7 @@ public class Vector {
|
|||||||
public Vector multiply(Vector ... others) {
|
public Vector multiply(Vector ... others) {
|
||||||
double newX = x, newY = y, newZ = z;
|
double newX = x, newY = y, newZ = z;
|
||||||
|
|
||||||
for (int i = 0; i < others.length; i++) {
|
for (int i = 0; i < others.length; ++i) {
|
||||||
newX *= others[i].x;
|
newX *= others[i].x;
|
||||||
newY *= others[i].y;
|
newY *= others[i].y;
|
||||||
newZ *= others[i].z;
|
newZ *= others[i].z;
|
||||||
|
@ -812,7 +812,7 @@ public class WorldEdit {
|
|||||||
? type.getName() + " (" + id + ")"
|
? type.getName() + " (" + id + ")"
|
||||||
: id.toString());
|
: id.toString());
|
||||||
|
|
||||||
i++;
|
++i;
|
||||||
|
|
||||||
if (i != size) {
|
if (i != size) {
|
||||||
str.append(", ");
|
str.append(", ");
|
||||||
|
@ -100,7 +100,7 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerB
|
|||||||
public Map<String,Tag> toTileEntityNBT()
|
public Map<String,Tag> toTileEntityNBT()
|
||||||
throws DataException {
|
throws DataException {
|
||||||
List<Tag> itemsList = new ArrayList<Tag>();
|
List<Tag> itemsList = new ArrayList<Tag>();
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; ++i) {
|
||||||
BaseItemStack item = items[i];
|
BaseItemStack item = items[i];
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
Map<String,Tag> data = new HashMap<String,Tag>();
|
Map<String,Tag> data = new HashMap<String,Tag>();
|
||||||
|
@ -100,7 +100,7 @@ public class DispenserBlock extends BaseBlock implements TileEntityBlock, Contai
|
|||||||
public Map<String,Tag> toTileEntityNBT()
|
public Map<String,Tag> toTileEntityNBT()
|
||||||
throws DataException {
|
throws DataException {
|
||||||
List<Tag> itemsList = new ArrayList<Tag>();
|
List<Tag> itemsList = new ArrayList<Tag>();
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; ++i) {
|
||||||
BaseItemStack item = items[i];
|
BaseItemStack item = items[i];
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
Map<String,Tag> data = new HashMap<String,Tag>();
|
Map<String,Tag> data = new HashMap<String,Tag>();
|
||||||
|
@ -142,7 +142,7 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
|
|||||||
public Map<String,Tag> toTileEntityNBT()
|
public Map<String,Tag> toTileEntityNBT()
|
||||||
throws DataException {
|
throws DataException {
|
||||||
List<Tag> itemsList = new ArrayList<Tag>();
|
List<Tag> itemsList = new ArrayList<Tag>();
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; ++i) {
|
||||||
BaseItemStack item = items[i];
|
BaseItemStack item = items[i];
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
Map<String,Tag> data = new HashMap<String,Tag>();
|
Map<String,Tag> data = new HashMap<String,Tag>();
|
||||||
|
@ -76,7 +76,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
for (int slot = 0; slot < items.length; slot++) {
|
for (int slot = 0; slot < items.length; ++slot) {
|
||||||
ItemStack item = items[slot];
|
ItemStack item = items[slot];
|
||||||
|
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
@ -123,7 +123,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
int freeSlot = -1;
|
int freeSlot = -1;
|
||||||
|
|
||||||
for (int slot = 0; slot < items.length; slot++) {
|
for (int slot = 0; slot < items.length; ++slot) {
|
||||||
ItemStack item = items[slot];
|
ItemStack item = items[slot];
|
||||||
|
|
||||||
// Delay using up a free slot until we know there are no stacks
|
// Delay using up a free slot until we know there are no stacks
|
||||||
|
@ -94,6 +94,30 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeId(type, false);
|
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeId(type, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set block type & data
|
||||||
|
* @param pt
|
||||||
|
* @param type
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean setTypeIdAndData(Vector pt, int type, int data){
|
||||||
|
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeIdAndData(type, (byte) data, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set block type & data
|
||||||
|
* @param pt
|
||||||
|
* @param type
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean setTypeIdAndDataFast(Vector pt, int type, int data){
|
||||||
|
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeIdAndData(type, (byte) data, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get block type.
|
* Get block type.
|
||||||
*
|
*
|
||||||
@ -164,9 +188,9 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||||
|
|
||||||
// First save all the blocks inside
|
// First save all the blocks inside
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; ++x) {
|
||||||
for (int y = 0; y < 128; y++) {
|
for (int y = 0; y < 128; ++y) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; ++z) {
|
||||||
Vector pt = min.add(x, y, z);
|
Vector pt = min.add(x, y, z);
|
||||||
int index = y * 16 * 16 + z * 16 + x;
|
int index = y * 16 * 16 + z * 16 + x;
|
||||||
history[index] = editSession.getBlock(pt);
|
history[index] = editSession.getBlock(pt);
|
||||||
@ -181,9 +205,9 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then restore
|
// Then restore
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; ++x) {
|
||||||
for (int y = 0; y < 128; y++) {
|
for (int y = 0; y < 128; ++y) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; ++z) {
|
||||||
Vector pt = min.add(x, y, z);
|
Vector pt = min.add(x, y, z);
|
||||||
int index = y * 16 * 16 + z * 16 + x;
|
int index = y * 16 * 16 + z * 16 + x;
|
||||||
|
|
||||||
@ -446,7 +470,7 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
if (radius == -1
|
if (radius == -1
|
||||||
|| origin.distanceSq(BukkitUtil.toVector(ent.getLocation())) <= radiusSq) {
|
|| origin.distanceSq(BukkitUtil.toVector(ent.getLocation())) <= radiusSq) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
num++;
|
++num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,32 +499,32 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
if (type == EntityType.ARROWS) {
|
if (type == EntityType.ARROWS) {
|
||||||
if (ent instanceof Arrow) {
|
if (ent instanceof Arrow) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
num++;
|
++num;
|
||||||
}
|
}
|
||||||
} else if (type == EntityType.BOATS) {
|
} else if (type == EntityType.BOATS) {
|
||||||
if (ent instanceof Boat) {
|
if (ent instanceof Boat) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
num++;
|
++num;
|
||||||
}
|
}
|
||||||
} else if (type == EntityType.ITEMS) {
|
} else if (type == EntityType.ITEMS) {
|
||||||
if (ent instanceof Item) {
|
if (ent instanceof Item) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
num++;
|
++num;
|
||||||
}
|
}
|
||||||
} else if (type == EntityType.MINECARTS) {
|
} else if (type == EntityType.MINECARTS) {
|
||||||
if (ent instanceof Minecart) {
|
if (ent instanceof Minecart) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
num++;
|
++num;
|
||||||
}
|
}
|
||||||
} else if (type == EntityType.PAINTINGS) {
|
} else if (type == EntityType.PAINTINGS) {
|
||||||
if (ent instanceof Painting) {
|
if (ent instanceof Painting) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
num++;
|
++num;
|
||||||
}
|
}
|
||||||
} else if (type == EntityType.TNT) {
|
} else if (type == EntityType.TNT) {
|
||||||
if (ent instanceof TNTPrimed) {
|
if (ent instanceof TNTPrimed) {
|
||||||
ent.remove();
|
ent.remove();
|
||||||
num++;
|
++num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -578,7 +602,7 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
int size = inven.getSize();
|
int size = inven.getSize();
|
||||||
BaseItemStack[] contents = new BaseItemStack[size];
|
BaseItemStack[] contents = new BaseItemStack[size];
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; ++i) {
|
||||||
ItemStack bukkitStack = inven.getItem(i);
|
ItemStack bukkitStack = inven.getItem(i);
|
||||||
if (bukkitStack.getTypeId() > 0) {
|
if (bukkitStack.getTypeId() > 0) {
|
||||||
contents[i] = new BaseItemStack(
|
contents[i] = new BaseItemStack(
|
||||||
@ -612,7 +636,7 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
Inventory inven = chest.getInventory();
|
Inventory inven = chest.getInventory();
|
||||||
int size = inven.getSize();
|
int size = inven.getSize();
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; ++i) {
|
||||||
if (i >= contents.length) {
|
if (i >= contents.length) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ public class GeneralCommands {
|
|||||||
for (String alias : type.getAliases()) {
|
for (String alias : type.getAliases()) {
|
||||||
if (alias.contains(query)) {
|
if (alias.contains(query)) {
|
||||||
player.print("#" + type.getID() + " (" + type.getName() + ")");
|
player.print("#" + type.getID() + " (" + type.getName() + ")");
|
||||||
found++;
|
++found;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class HistoryCommands {
|
|||||||
|
|
||||||
int times = Math.max(1, args.getInteger(0, 1));
|
int times = Math.max(1, args.getInteger(0, 1));
|
||||||
|
|
||||||
for (int i = 0; i < times; i++) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession undone = session.undo(session.getBlockBag(player));
|
EditSession undone = session.undo(session.getBlockBag(player));
|
||||||
if (undone != null) {
|
if (undone != null) {
|
||||||
player.print("Undo successful.");
|
player.print("Undo successful.");
|
||||||
@ -70,7 +70,7 @@ public class HistoryCommands {
|
|||||||
|
|
||||||
int times = Math.max(1, args.getInteger(0, 1));
|
int times = Math.max(1, args.getInteger(0, 1));
|
||||||
|
|
||||||
for (int i = 0; i < times; i++) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession redone = session.redo(session.getBlockBag(player));
|
EditSession redone = session.redo(session.getBlockBag(player));
|
||||||
if (redone != null) {
|
if (redone != null) {
|
||||||
player.print("Redo successful.");
|
player.print("Redo successful.");
|
||||||
|
@ -65,7 +65,7 @@ public class NavigationCommands {
|
|||||||
}
|
}
|
||||||
int ascentLevels = 1;
|
int ascentLevels = 1;
|
||||||
while (player.ascendLevel() && levelsToAscend != ascentLevels) {
|
while (player.ascendLevel() && levelsToAscend != ascentLevels) {
|
||||||
ascentLevels++;
|
++ascentLevels;
|
||||||
}
|
}
|
||||||
if (ascentLevels == 0) {
|
if (ascentLevels == 0) {
|
||||||
player.printError("No free spot above you found.");
|
player.printError("No free spot above you found.");
|
||||||
@ -94,7 +94,7 @@ public class NavigationCommands {
|
|||||||
}
|
}
|
||||||
int descentLevels = 1;
|
int descentLevels = 1;
|
||||||
while (player.descendLevel() && levelsToDescend != descentLevels) {
|
while (player.descendLevel() && levelsToDescend != descentLevels) {
|
||||||
descentLevels++;
|
++descentLevels;
|
||||||
}
|
}
|
||||||
if (descentLevels == 0) {
|
if (descentLevels == 0) {
|
||||||
player.printError("No free spot above you found.");
|
player.printError("No free spot above you found.");
|
||||||
|
@ -63,7 +63,7 @@ public class SnapshotCommands {
|
|||||||
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true);
|
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true);
|
||||||
|
|
||||||
if (snapshots.size() > 0) {
|
if (snapshots.size() > 0) {
|
||||||
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
|
for (byte i = 0; i < Math.min(num, snapshots.size()); ++i) {
|
||||||
player.print((i + 1) + ". " + snapshots.get(i).getName());
|
player.print((i + 1) + ". " + snapshots.get(i).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class ForwardSeekableInputStream extends InputStream {
|
|||||||
@Override
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
int ret = parent.read();
|
int ret = parent.read();
|
||||||
position++;
|
++position;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public class DocumentationPrinter {
|
|||||||
method.getAnnotation(CommandPermissions.class);
|
method.getAnnotation(CommandPermissions.class);
|
||||||
|
|
||||||
String[] permKeys = perms.value();
|
String[] permKeys = perms.value();
|
||||||
for (int i = 0; i < permKeys.length; i++) {
|
for (int i = 0; i < permKeys.length; ++i) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
stream.print(", ");
|
stream.print(", ");
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ public class GaussianKernel extends Kernel {
|
|||||||
|
|
||||||
double sigma22 = 2 * sigma * sigma;
|
double sigma22 = 2 * sigma * sigma;
|
||||||
double constant = Math.PI * sigma22;
|
double constant = Math.PI * sigma22;
|
||||||
for (int y = -radius; y <= radius; y++) {
|
for (int y = -radius; y <= radius; ++y) {
|
||||||
for (int x = -radius; x <= radius; x++) {
|
for (int x = -radius; x <= radius; ++x) {
|
||||||
data[(y+radius) * diameter + x+radius] = (float) (Math.exp(-(x * x + y * y) / sigma22) / constant);
|
data[(y+radius) * diameter + x+radius] = (float) (Math.exp(-(x * x + y * y) / sigma22) / constant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,11 +85,11 @@ public class HeightMapFilter {
|
|||||||
int kox = kernel.getXOrigin();
|
int kox = kernel.getXOrigin();
|
||||||
int koy = kernel.getYOrigin();
|
int koy = kernel.getYOrigin();
|
||||||
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; ++y) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; ++x) {
|
||||||
float z = 0;
|
float z = 0;
|
||||||
|
|
||||||
for (int ky = 0; ky < kh; ky++) {
|
for (int ky = 0; ky < kh; ++ky) {
|
||||||
int offsetY = y + ky - koy;
|
int offsetY = y + ky - koy;
|
||||||
// Clamp coordinates inside data
|
// Clamp coordinates inside data
|
||||||
if (offsetY < 0 || offsetY >= height)
|
if (offsetY < 0 || offsetY >= height)
|
||||||
@ -98,7 +98,7 @@ public class HeightMapFilter {
|
|||||||
offsetY *= width;
|
offsetY *= width;
|
||||||
|
|
||||||
int matrixOffset = ky * kw;
|
int matrixOffset = ky * kw;
|
||||||
for (int kx = 0; kx < kw; kx++) {
|
for (int kx = 0; kx < kw; ++kx) {
|
||||||
float f = matrix[matrixOffset + kx];
|
float f = matrix[matrixOffset + kx];
|
||||||
if (f == 0) continue;
|
if (f == 0) continue;
|
||||||
|
|
||||||
|
@ -275,9 +275,9 @@ public class CuboidRegion implements Region {
|
|||||||
Vector min = getMinimumPoint();
|
Vector min = getMinimumPoint();
|
||||||
Vector max = getMaximumPoint();
|
Vector max = getMaximumPoint();
|
||||||
|
|
||||||
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
chunks.add(ChunkStore.toChunk(pt));
|
chunks.add(ChunkStore.toChunk(pt));
|
||||||
}
|
}
|
||||||
@ -325,14 +325,11 @@ public class CuboidRegion implements Region {
|
|||||||
public BlockVector next() {
|
public BlockVector next() {
|
||||||
if (!hasNext()) throw new java.util.NoSuchElementException();
|
if (!hasNext()) throw new java.util.NoSuchElementException();
|
||||||
BlockVector answer = new BlockVector(nextX, nextY, nextZ);
|
BlockVector answer = new BlockVector(nextX, nextY, nextZ);
|
||||||
nextX++;
|
if (++nextX > max.getBlockX()) {
|
||||||
if (nextX > max.getBlockX()) {
|
|
||||||
nextX = min.getBlockX();
|
nextX = min.getBlockX();
|
||||||
nextY++;
|
if (++nextY > max.getBlockY()) {
|
||||||
if (nextY > max.getBlockY()) {
|
|
||||||
nextY = min.getBlockY();
|
nextY = min.getBlockY();
|
||||||
nextZ++;
|
if (++nextZ > max.getBlockZ()) {
|
||||||
if (nextZ > max.getBlockZ()) {
|
|
||||||
nextX = Integer.MIN_VALUE;
|
nextX = Integer.MIN_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ public class Polygonal2DRegion implements Region {
|
|||||||
double area = 0;
|
double area = 0;
|
||||||
int i, j = points.size() - 1;
|
int i, j = points.size() - 1;
|
||||||
|
|
||||||
for (i = 0; i < points.size(); i++) {
|
for (i = 0; i < points.size(); ++i) {
|
||||||
area += (points.get(j).getBlockX() + points.get(i).getBlockX())
|
area += (points.get(j).getBlockX() + points.get(i).getBlockX())
|
||||||
* (points.get(j).getBlockZ() - points.get(i).getBlockZ());
|
* (points.get(j).getBlockZ() - points.get(i).getBlockZ());
|
||||||
j = i;
|
j = i;
|
||||||
@ -307,7 +307,7 @@ public class Polygonal2DRegion implements Region {
|
|||||||
xOld = points.get(npoints - 1).getBlockX();
|
xOld = points.get(npoints - 1).getBlockX();
|
||||||
zOld = points.get(npoints - 1).getBlockZ();
|
zOld = points.get(npoints - 1).getBlockZ();
|
||||||
|
|
||||||
for (i = 0; i < npoints; i++) {
|
for (i = 0; i < npoints; ++i) {
|
||||||
xNew = points.get(i).getBlockX();
|
xNew = points.get(i).getBlockX();
|
||||||
zNew = points.get(i).getBlockZ();
|
zNew = points.get(i).getBlockZ();
|
||||||
//Check for corner
|
//Check for corner
|
||||||
@ -348,9 +348,9 @@ public class Polygonal2DRegion implements Region {
|
|||||||
Vector min = getMinimumPoint();
|
Vector min = getMinimumPoint();
|
||||||
Vector max = getMaximumPoint();
|
Vector max = getMaximumPoint();
|
||||||
|
|
||||||
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
if (contains(pt)) { // Not the best
|
if (contains(pt)) { // Not the best
|
||||||
chunks.add(ChunkStore.toChunk(pt));
|
chunks.add(ChunkStore.toChunk(pt));
|
||||||
@ -414,11 +414,11 @@ public class Polygonal2DRegion implements Region {
|
|||||||
int minZ = getMinimumPoint().getBlockZ();
|
int minZ = getMinimumPoint().getBlockZ();
|
||||||
int maxZ = getMaximumPoint().getBlockZ();
|
int maxZ = getMaximumPoint().getBlockZ();
|
||||||
|
|
||||||
for (pixelZ = minZ; pixelZ < maxZ; pixelZ++) {
|
for (pixelZ = minZ; pixelZ < maxZ; ++pixelZ) {
|
||||||
// Build a list of nodes
|
// Build a list of nodes
|
||||||
nodes = 0;
|
nodes = 0;
|
||||||
j = n - 1;
|
j = n - 1;
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; ++i) {
|
||||||
if (points.get(i).getBlockZ() < (double) pixelZ
|
if (points.get(i).getBlockZ() < (double) pixelZ
|
||||||
&& points.get(j).getBlockZ() >= (double) pixelZ
|
&& points.get(j).getBlockZ() >= (double) pixelZ
|
||||||
|| points.get(j).getBlockZ() < (double) pixelZ
|
|| points.get(j).getBlockZ() < (double) pixelZ
|
||||||
@ -441,16 +441,16 @@ public class Polygonal2DRegion implements Region {
|
|||||||
nodeX[i] = nodeX[i + 1];
|
nodeX[i] = nodeX[i + 1];
|
||||||
nodeX[i + 1] = swap;
|
nodeX[i + 1] = swap;
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
i--;
|
--i;
|
||||||
} else {
|
} else {
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill the pixels between node pairs
|
// Fill the pixels between node pairs
|
||||||
for (i = 0; i < nodes; i += 2) {
|
for (i = 0; i < nodes; i += 2) {
|
||||||
for (j = nodeX[i]; j < nodeX[i + 1]; j++) {
|
for (j = nodeX[i]; j < nodeX[i + 1]; ++j) {
|
||||||
for (int y = minY; y >= maxY; y++) {
|
for (int y = minY; y >= maxY; ++y) {
|
||||||
items.add(new BlockVector(j, y, pixelZ));
|
items.add(new BlockVector(j, y, pixelZ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,10 +504,10 @@ public class Polygonal2DRegion implements Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (next != null && curY <= maxY) {
|
if (next != null && curY <= maxY) {
|
||||||
curY++;
|
++curY;
|
||||||
next = new BlockVector(curX, curY, curZ);
|
next = new BlockVector(curX, curY, curZ);
|
||||||
if (curY > maxY) {
|
if (curY > maxY) {
|
||||||
i++;
|
++i;
|
||||||
curY = minY;
|
curY = minY;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@ -522,7 +522,7 @@ public class Polygonal2DRegion implements Region {
|
|||||||
next = pt;
|
next = pt;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i++;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
next = null;
|
next = null;
|
||||||
|
@ -79,7 +79,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
|
|||||||
s.append(m);
|
s.append(m);
|
||||||
s.append("(");
|
s.append("(");
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; ++i) {
|
||||||
s.append(args[i]);
|
s.append(args[i]);
|
||||||
if (i < args.length - 1) {
|
if (i < args.length - 1) {
|
||||||
s.append(",");
|
s.append(",");
|
||||||
|
@ -82,9 +82,9 @@ public class SnapshotRestore {
|
|||||||
|
|
||||||
// First, we need to group points by chunk so that we only need
|
// First, we need to group points by chunk so that we only need
|
||||||
// to keep one chunk in memory at any given moment
|
// to keep one chunk in memory at any given moment
|
||||||
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
|
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||||
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
|
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
|
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||||
Vector pos = new Vector(x, y, z);
|
Vector pos = new Vector(x, y, z);
|
||||||
BlockVector2D chunkPos = ChunkStore.toChunk(pos);
|
BlockVector2D chunkPos = ChunkStore.toChunk(pos);
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (int x = ox - range; x <= ox + range; x++) {
|
for (int x = ox - range; x <= ox + range; ++x) {
|
||||||
for (int y = oy - range; y <= oy + range; y++) {
|
for (int y = oy - range; y <= oy + range; ++y) {
|
||||||
for (int z = oz - range; z <= oz + range; z++) {
|
for (int z = oz - range; z <= oz + range; ++z) {
|
||||||
Vector pos = new Vector(x, y, z);
|
Vector pos = new Vector(x, y, z);
|
||||||
if (world.getBlockType(pos) == initialType) {
|
if (world.getBlockType(pos) == initialType) {
|
||||||
if (config.superPickaxeManyDrop) {
|
if (config.superPickaxeManyDrop) {
|
||||||
|
@ -119,9 +119,9 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = -1; i <= 1; i++) {
|
for (int i = -1; i <= 1; ++i) {
|
||||||
for (int j = -1; j <= 1; j++) {
|
for (int j = -1; j <= 1; ++j) {
|
||||||
for (int k = -1; k <= 1; k++) {
|
for (int k = -1; k <= 1; ++k) {
|
||||||
if (Math.abs(i) + Math.abs(j) + Math.abs(k) == 1) {
|
if (Math.abs(i) + Math.abs(j) + Math.abs(k) == 1) {
|
||||||
if (!recurse(server, editSession, world, pos.add(i, j, k).toBlockVector(),
|
if (!recurse(server, editSession, world, pos.add(i, j, k).toBlockVector(),
|
||||||
origin, size, visited, block)) {
|
origin, size, visited, block)) {
|
||||||
|
@ -181,7 +181,7 @@ public class TreeGenerator {
|
|||||||
BaseBlock leavesBlock = new BaseBlock(18);
|
BaseBlock leavesBlock = new BaseBlock(18);
|
||||||
|
|
||||||
// Create trunk
|
// Create trunk
|
||||||
for (int i = 0; i < trunkHeight; i++) {
|
for (int i = 0; i < trunkHeight; ++i) {
|
||||||
if (!editSession.setBlockIfAir(basePos.add(0, i, 0), logBlock)) {
|
if (!editSession.setBlockIfAir(basePos.add(0, i, 0), logBlock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ public class TreeGenerator {
|
|||||||
basePos = basePos.add(0, trunkHeight, 0);
|
basePos = basePos.add(0, trunkHeight, 0);
|
||||||
|
|
||||||
// Create tree + leaves
|
// Create tree + leaves
|
||||||
for (int i = 0; i < height; i++) {
|
for (int i = 0; i < height; ++i) {
|
||||||
editSession.setBlockIfAir(basePos.add(0, i, 0), logBlock);
|
editSession.setBlockIfAir(basePos.add(0, i, 0), logBlock);
|
||||||
|
|
||||||
// Less leaves at these levels
|
// Less leaves at these levels
|
||||||
@ -208,16 +208,16 @@ public class TreeGenerator {
|
|||||||
editSession.setChanceBlockIfAir(basePos.add(-1, i, -1), leavesBlock, chance);
|
editSession.setChanceBlockIfAir(basePos.add(-1, i, -1), leavesBlock, chance);
|
||||||
|
|
||||||
if (!(i == 0 || i == height - 1)) {
|
if (!(i == 0 || i == height - 1)) {
|
||||||
for (int j = -2; j <= 2; j++) {
|
for (int j = -2; j <= 2; ++j) {
|
||||||
editSession.setChanceBlockIfAir(basePos.add(-2, i, j), leavesBlock, 0.6);
|
editSession.setChanceBlockIfAir(basePos.add(-2, i, j), leavesBlock, 0.6);
|
||||||
}
|
}
|
||||||
for (int j = -2; j <= 2; j++) {
|
for (int j = -2; j <= 2; ++j) {
|
||||||
editSession.setChanceBlockIfAir(basePos.add(2, i, j), leavesBlock, 0.6);
|
editSession.setChanceBlockIfAir(basePos.add(2, i, j), leavesBlock, 0.6);
|
||||||
}
|
}
|
||||||
for (int j = -2; j <= 2; j++) {
|
for (int j = -2; j <= 2; ++j) {
|
||||||
editSession.setChanceBlockIfAir(basePos.add(j, i, -2), leavesBlock, 0.6);
|
editSession.setChanceBlockIfAir(basePos.add(j, i, -2), leavesBlock, 0.6);
|
||||||
}
|
}
|
||||||
for (int j = -2; j <= 2; j++) {
|
for (int j = -2; j <= 2; ++j) {
|
||||||
editSession.setChanceBlockIfAir(basePos.add(j, i, 2), leavesBlock, 0.6);
|
editSession.setChanceBlockIfAir(basePos.add(j, i, 2), leavesBlock, 0.6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user