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:
Jacob Scott 2011-07-15 02:00:48 -05:00
parent 75660547d9
commit 66dcc99809
34 changed files with 365 additions and 312 deletions

View File

@ -178,7 +178,7 @@ public final class NBTInputStream implements Closeable {
length = is.readInt();
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);
if (tag instanceof EndTag) {
throw new IOException("TAG_End not permitted in a list.");

View File

@ -218,7 +218,7 @@ public final class NBTOutputStream implements Closeable {
os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size);
for (int i = 0; i < size; i++) {
for (int i = 0; i < size; ++i) {
writeTagPayload(tags.get(i));
}
}

View File

@ -31,11 +31,11 @@ public class CommandContext {
public CommandContext(String[] args) {
int i = 1;
for (; i < args.length; i++) {
for (; i < args.length; ++i) {
if (args[i].length() == 0) {
// Ignore this
} 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));
}
} else {
@ -70,7 +70,7 @@ public class CommandContext {
public String getJoinedStrings(int initialIndex) {
initialIndex = initialIndex + 1;
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]);
}
return buffer.toString();

View File

@ -225,7 +225,7 @@ public abstract class CommandsManager<T> {
command.append("/");
for (int i = 0; i <= level; i++) {
for (int i = 0; i <= level; ++i) {
command.append(args[i] + " ");
}
@ -252,7 +252,7 @@ public abstract class CommandsManager<T> {
command.append("/");
for (int i = 0; i <= level; i++) {
for (int i = 0; i <= level; ++i) {
command.append(args[i] + " ");
}

View File

@ -55,7 +55,7 @@ public class StringUtil {
return "";
}
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]);
}
return buffer.toString();
@ -79,7 +79,7 @@ public class StringUtil {
buffer.append(quote);
buffer.append(str[initialIndex]);
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);
}
return buffer.toString();
@ -110,7 +110,7 @@ public class StringUtil {
return "";
}
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());
}
return buffer.toString();
@ -130,7 +130,7 @@ public class StringUtil {
return "";
}
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]));
}
return buffer.toString();
@ -159,7 +159,7 @@ public class StringUtil {
buffer.append(o.toString());
}
i++;
++i;
}
return buffer.toString();
}
@ -244,15 +244,15 @@ public class StringUtil {
int cost; // cost
for (i = 0; i <= n; i++) {
for (i = 0; i <= n; ++i) {
p[i] = i;
}
for (j = 1; j <= m; j++) {
for (j = 1; j <= m; ++j) {
t_j = t.charAt(j - 1);
d[0] = j;
for (i = 1; i <= n; i++) {
for (i = 1; i <= n; ++i) {
cost = s.charAt(i - 1) == t_j ? 0 : 1;
// minimum of cell to the left+1, to the top+1, diagonally left
// and up +cost

View File

@ -77,14 +77,14 @@ public class Countable<T> implements Comparable<Countable<T>> {
* Decrement the amount.
*/
public void decrement() {
this.amount--;
--this.amount;
}
/**
* Increment the amount.
*/
public void increment() {
this.amount++;
++this.amount;
}
/**

View File

@ -140,21 +140,21 @@ public class CuboidClipboard {
[Math.abs(sizeRotated.getBlockY())]
[Math.abs(sizeRotated.getBlockZ())];
for (int x = 0; x < width; x++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; ++x) {
for (int z = 0; z < length; ++z) {
Vector v = (new Vector(x, 0, z)).transform2D(angle, 0, 0, 0, 0);
int newX = v.getBlockX();
int newZ = v.getBlockZ();
for (int y = 0; y < height; y++) {
for (int y = 0; y < height; ++y) {
BaseBlock block = data[x][y][z];
newData[shiftX + newX][y][shiftZ + newZ] = block;
if (reverse) {
for (int i = 0; i < numRotations; i++) {
for (int i = 0; i < numRotations; ++i) {
block.rotate90Reverse();
}
} else {
for (int i = 0; i < numRotations; i++) {
for (int i = 0; i < numRotations; ++i) {
block.rotate90();
}
}
@ -182,9 +182,9 @@ public class CuboidClipboard {
if (dir == FlipDirection.NORTH_SOUTH) {
int len = (int)Math.floor(width / 2);
for (int xs = 0; xs < len; xs++) {
for (int z = 0; z < length; z++) {
for (int y = 0; y < height; y++) {
for (int xs = 0; xs < len; ++xs) {
for (int z = 0; z < length; ++z) {
for (int y = 0; y < height; ++y) {
BaseBlock old = data[xs][y][z];
old.flip();
data[xs][y][z] = data[width - xs - 1][y][z];
@ -194,9 +194,9 @@ public class CuboidClipboard {
}
} else if (dir == FlipDirection.WEST_EAST) {
int len = (int)Math.floor(length / 2);
for (int zs = 0; zs < len; zs++) {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
for (int zs = 0; zs < len; ++zs) {
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
BaseBlock old = data[x][y][zs];
old.flip();
data[x][y][zs] = data[x][y][length - zs - 1];
@ -206,9 +206,9 @@ public class CuboidClipboard {
}
} else if (dir == FlipDirection.UP_DOWN) {
int len = (int)Math.floor(height / 2);
for (int ys = 0; ys < len; ys++) {
for (int x = 0; x < width; x++) {
for (int z = 0; z < length; z++) {
for (int ys = 0; ys < len; ++ys) {
for (int x = 0; x < width; ++x) {
for (int z = 0; z < length; ++z) {
BaseBlock old = data[x][ys][z];
data[x][ys][z] = data[x][height - ys - 1][z];
data[x][height - ys - 1][z] = old;
@ -224,9 +224,9 @@ public class CuboidClipboard {
* @param editSession
*/
public void copy(EditSession editSession) {
for (int x = 0; x < size.getBlockX(); x++) {
for (int y = 0; y < size.getBlockY(); y++) {
for (int z = 0; z < size.getBlockZ(); z++) {
for (int x = 0; x < size.getBlockX(); ++x) {
for (int y = 0; y < size.getBlockY(); ++y) {
for (int z = 0; z < size.getBlockZ(); ++z) {
data[x][y][z] =
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)
throws MaxChangedBlocksException {
for (int x = 0; x < size.getBlockX(); x++) {
for (int y = 0; y < size.getBlockY(); y++) {
for (int z = 0; z < size.getBlockZ(); z++) {
for (int x = 0; x < size.getBlockX(); ++x) {
for (int y = 0; y < size.getBlockY(); ++y) {
for (int z = 0; z < size.getBlockZ(); ++z) {
if (noAir && data[x][y][z].isAir())
continue;
@ -330,9 +330,9 @@ public class CuboidClipboard {
byte[] blockData = new byte[width * height * length];
ArrayList<Tag> tileEntities = new ArrayList<Tag>();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
for (int z = 0; z < length; ++z) {
int index = y * width * length + z * width + x;
blocks[index] = (byte)data[x][y][z].getType();
blockData[index] = (byte)data[x][y][z].getData();
@ -476,9 +476,9 @@ public class CuboidClipboard {
clipboard.setOrigin(origin);
clipboard.setOffset(offset);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
for (int z = 0; z < length; ++z) {
int index = y * width * length + z * width + x;
BlockVector pt = new BlockVector(x, y, z);
BaseBlock block;

View File

@ -208,20 +208,22 @@ public class EditSession {
boolean result;
if (fastMode) {
result = world.setBlockTypeFast(pt, id);
if (BlockType.usesData(id)) {
if (fastMode) {
result = world.setTypeIdAndDataFast(pt, type, block.getData());
} else {
result = world.setTypeIdAndData(pt, type, block.getData());
}
} else {
result = world.setBlockType(pt, id);
if (fastMode) {
result = world.setBlockTypeFast(pt, id);
} else {
result = world.setBlockType(pt, id);
}
}
//System.out.println(pt + "" +result);
if (id != 0) {
if (BlockType.usesData(id)) {
if (fastMode) {
world.setBlockDataFast(pt, block.getData());
} else {
world.setBlockData(pt, block.getData());
}
}
// Signs
if (block instanceof SignBlock) {
@ -249,7 +251,6 @@ public class EditSession {
world.copyToWorld(pt, noteBlock);
}
}
return result;
}
@ -336,13 +337,15 @@ public class EditSession {
// Place torches, etc. last
if (BlockType.shouldPlaceLast(block.getType())) {
queueLast.put(pt.toBlockVector(), block);
return getBlockType(pt) != block.getType();
return !(getBlockType(pt) == block.getType()
&& getBlockData(pt) == block.getData());
// Destroy torches, etc. first
} else if (BlockType.shouldPlaceLast(getBlockType(pt))) {
rawSetBlock(pt, new BaseBlock(0));
} else {
queueAfter.put(pt.toBlockVector(), block);
return getBlockType(pt) != block.getType();
return !(getBlockType(pt) == block.getType()
&& getBlockData(pt) == block.getData());
}
}
@ -390,7 +393,21 @@ public class EditSession {
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.
*
@ -607,7 +624,7 @@ public class EditSession {
if (getBlock(pt).isAir()) {
if (setBlock(pt, block)) {
affected++;
++affected;
}
} else {
continue;
@ -655,12 +672,12 @@ public class EditSession {
throws MaxChangedBlocksException {
int affected = 0;
for (int y = cy; y >= minY; y--) {
for (int y = cy; y >= minY; --y) {
Vector pt = new Vector(x, y, z);
if (getBlock(pt).isAir()) {
setBlock(pt, block);
affected++;
++affected;
} else {
break;
}
@ -712,7 +729,7 @@ public class EditSession {
if (getBlock(pt).isAir()) {
if (setBlock(pt, pattern.next(pt))) {
affected++;
++affected;
}
} else {
continue;
@ -760,12 +777,12 @@ public class EditSession {
throws MaxChangedBlocksException {
int affected = 0;
for (int y = cy; y >= minY; y--) {
for (int y = cy; y >= minY; --y) {
Vector pt = new Vector(x, y, z);
if (getBlock(pt).isAir()) {
setBlock(pt, pattern.next(pt));
affected++;
++affected;
} else {
break;
}
@ -786,21 +803,21 @@ public class EditSession {
public int removeAbove(Vector pos, int size, int height)
throws MaxChangedBlocksException {
int maxY = Math.min(127, pos.getBlockY() + height - 1);
size--;
--size;
int affected = 0;
int oX = pos.getBlockX();
int oY = pos.getBlockY();
int oZ = pos.getBlockZ();
for (int x = oX - size; x <= oX + size; x++) {
for (int z = oZ - size; z <= oZ + size; z++) {
for (int y = oY; y <= maxY; y++) {
for (int x = oX - size; x <= oX + size; ++x) {
for (int z = oZ - size; z <= oZ + size; ++z) {
for (int y = oY; y <= maxY; ++y) {
Vector pt = new Vector(x, y, z);
if (getBlockType(pt) != 0) {
setBlock(pt, new BaseBlock(0));
affected++;
++affected;
}
}
}
@ -821,21 +838,21 @@ public class EditSession {
public int removeBelow(Vector pos, int size, int height)
throws MaxChangedBlocksException {
int minY = Math.max(0, pos.getBlockY() - height);
size--;
--size;
int affected = 0;
int oX = pos.getBlockX();
int oY = pos.getBlockY();
int oZ = pos.getBlockZ();
for (int x = oX - size; x <= oX + size; x++) {
for (int z = oZ - size; z <= oZ + size; z++) {
for (int y = oY; y >= minY; y--) {
for (int x = oX - size; x <= oX + size; ++x) {
for (int z = oZ - size; z <= oZ + size; ++z) {
for (int y = oY; y >= minY; --y) {
Vector pt = new Vector(x, y, z);
if (getBlockType(pt) != 0) {
setBlock(pt, new BaseBlock(0));
affected++;
++affected;
}
}
}
@ -865,14 +882,14 @@ public class EditSession {
int minZ = pos.getBlockZ() - size;
int maxZ = pos.getBlockZ() + size;
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector p = new Vector(x, y, z);
if (getBlockType(p) == blockType) {
if (setBlock(p, air)) {
affected++;
++affected;
}
}
}
@ -906,13 +923,13 @@ public class EditSession {
int maxY = max.getBlockY();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector pt = new Vector(x, y, z);
if (setBlock(pt, block)) {
affected++;
++affected;
}
}
}
@ -920,7 +937,7 @@ public class EditSession {
} else {
for (Vector pt : region) {
if (setBlock(pt, block)) {
affected++;
++affected;
}
}
}
@ -952,13 +969,13 @@ public class EditSession {
int maxY = max.getBlockY();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector pt = new Vector(x, y, z);
if (setBlock(pt, pattern.next(pt))) {
affected++;
++affected;
}
}
}
@ -966,7 +983,7 @@ public class EditSession {
} else {
for (Vector pt : region) {
if (setBlock(pt, pattern.next(pt))) {
affected++;
++affected;
}
}
}
@ -999,9 +1016,9 @@ public class EditSession {
int maxY = max.getBlockY();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector pt = new Vector(x, y, z);
int curBlockType = getBlockType(pt);
@ -1009,7 +1026,7 @@ public class EditSession {
|| (fromBlockTypes != null && fromBlockTypes
.contains(curBlockType))) {
if (setBlock(pt, toBlock)) {
affected++;
++affected;
}
}
}
@ -1022,7 +1039,7 @@ public class EditSession {
if (fromBlockTypes == null && curBlockType != 0
|| fromBlockTypes.contains(curBlockType)) {
if (setBlock(pt, toBlock)) {
affected++;
++affected;
}
}
}
@ -1056,9 +1073,9 @@ public class EditSession {
int maxY = max.getBlockY();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector pt = new Vector(x, y, z);
int curBlockType = getBlockType(pt);
@ -1066,7 +1083,7 @@ public class EditSession {
|| (fromBlockTypes != null && fromBlockTypes
.contains(curBlockType))) {
if (setBlock(pt, pattern.next(pt))) {
affected++;
++affected;
}
}
}
@ -1079,7 +1096,7 @@ public class EditSession {
if (fromBlockTypes == null && curBlockType != 0
|| fromBlockTypes.contains(curBlockType)) {
if (setBlock(pt, pattern.next(pt))) {
affected++;
++affected;
}
}
}
@ -1110,36 +1127,36 @@ public class EditSession {
int maxY = max.getBlockY();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
if (setBlock(new Vector(x, y, minZ), block)) {
affected++;
++affected;
}
if (setBlock(new Vector(x, y, maxZ), block)) {
affected++;
++affected;
}
affected++;
++affected;
}
}
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
if (setBlock(new Vector(minX, y, z), block)) {
affected++;
++affected;
}
if (setBlock(new Vector(maxX, y, z), block)) {
affected++;
++affected;
}
}
}
for (int z = minZ; z <= maxZ; z++) {
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; ++z) {
for (int x = minX; x <= maxX; ++x) {
if (setBlock(new Vector(x, minY, z), block)) {
affected++;
++affected;
}
if (setBlock(new Vector(x, maxY, z), block)) {
affected++;
++affected;
}
}
}
@ -1169,25 +1186,25 @@ public class EditSession {
int maxY = max.getBlockY();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
if (setBlock(new Vector(x, y, minZ), block)) {
affected++;
++affected;
}
if (setBlock(new Vector(x, y, maxZ), block)) {
affected++;
++affected;
}
affected++;
++affected;
}
}
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
if (setBlock(new Vector(minX, y, z), block)) {
affected++;
++affected;
}
if (setBlock(new Vector(maxX, y, z), block)) {
affected++;
++affected;
}
}
}
@ -1218,15 +1235,15 @@ public class EditSession {
int maxX = max.getBlockX();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = upperY; y >= lowerY; y--) {
for (int x = minX; x <= maxX; ++x) {
for (int z = minZ; z <= maxZ; ++z) {
for (int y = upperY; y >= lowerY; --y) {
Vector above = new Vector(x, y + 1, z);
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
&& getBlock(above).isAir()) {
if (setBlock(above, block)) {
affected++;
++affected;
}
break;
}
@ -1260,15 +1277,15 @@ public class EditSession {
int maxX = max.getBlockX();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = upperY; y >= lowerY; y--) {
for (int x = minX; x <= maxX; ++x) {
for (int z = minZ; z <= maxZ; ++z) {
for (int y = upperY; y >= lowerY; --y) {
Vector above = new Vector(x, y + 1, z);
if (y + 1 <= 127 && !getBlock(new Vector(x, y, z)).isAir()
&& getBlock(above).isAir()) {
if (setBlock(above, pattern.next(above))) {
affected++;
++affected;
}
break;
}
@ -1307,19 +1324,19 @@ public class EditSession {
int ys = region.getHeight();
int zs = region.getLength();
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; ++x) {
for (int z = minZ; z <= maxZ; ++z) {
for (int y = minY; y <= maxY; ++y) {
BaseBlock block = getBlock(new Vector(x, y, z));
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()
* i, y + ys * dir.getBlockY() * i, z + zs
* dir.getBlockZ() * i);
if (setBlock(pos, block)) {
affected++;
++affected;
}
}
}
@ -1362,9 +1379,9 @@ public class EditSession {
Map<Vector, BaseBlock> delayed = new LinkedHashMap<Vector, BaseBlock>();
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; ++x) {
for (int z = minZ; z <= maxZ; ++z) {
for (int y = minY; y <= maxY; ++y) {
Vector pos = new Vector(x, y, z);
BaseBlock block = getBlock(pos);
@ -1390,7 +1407,7 @@ public class EditSession {
for (Map.Entry<Vector, BaseBlock> entry : delayed.entrySet()) {
setBlock(entry.getKey(), entry.getValue());
affected++;
++affected;
}
return affected;
@ -1411,9 +1428,9 @@ public class EditSession {
HashSet<BlockVector> visited = new HashSet<BlockVector>();
Stack<BlockVector> queue = new Stack<BlockVector>();
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; ++x) {
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; ++z) {
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; ++y) {
queue.push(new BlockVector(x, y, z));
}
}
@ -1441,9 +1458,9 @@ public class EditSession {
continue;
}
for (int x = cur.getBlockX() - 1; x <= cur.getBlockX() + 1; x++) {
for (int z = cur.getBlockZ() - 1; z <= cur.getBlockZ() + 1; z++) {
for (int y = cur.getBlockY() - 1; y <= cur.getBlockY() + 1; y++) {
for (int x = cur.getBlockX() - 1; x <= cur.getBlockX() + 1; ++x) {
for (int z = cur.getBlockZ() - 1; z <= cur.getBlockZ() + 1; ++z) {
for (int y = cur.getBlockY() - 1; y <= cur.getBlockY() + 1; ++y) {
BlockVector newPos = new BlockVector(x, y, z);
if (!cur.equals(newPos)) {
@ -1454,7 +1471,7 @@ public class EditSession {
}
if (setBlock(cur, new BaseBlock(0))) {
affected++;
++affected;
}
}
@ -1478,9 +1495,9 @@ public class EditSession {
HashSet<BlockVector> visited = new HashSet<BlockVector>();
Stack<BlockVector> queue = new Stack<BlockVector>();
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; ++x) {
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; ++z) {
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; ++y) {
int type = getBlock(new Vector(x, y, z)).getType();
// Check block type
@ -1510,8 +1527,8 @@ public class EditSession {
visited.add(cur);
if (setBlock(cur, stationaryBlock)) {
affected++;
if (setBlock(cur, stationaryBlock)){
++affected;
}
// Check radius
@ -1543,7 +1560,7 @@ public class EditSession {
int affected = 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(z, y, 0), block);
@ -1551,7 +1568,7 @@ public class EditSession {
affected += 4;
}
} 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);
@ -1559,7 +1576,7 @@ public class EditSession {
affected += 4;
}
} 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);
@ -1608,11 +1625,10 @@ public class EditSession {
affected += makeHCylinderPoints(pos, x, z, height, block);
while (x < z) {
x++;
++x;
if (d >= 0) {
z--;
d += 2 * (x - z) + 1;
d += 2 * (x - --z) + 1;
} else {
d += 2 * x + 1;
}
@ -1638,19 +1654,19 @@ public class EditSession {
int affected = 0;
if (x == z) {
for (int y = 0; y < height; y++) {
for (int z2 = -z; z2 <= z; z2++) {
for (int y = 0; y < height; ++y) {
for (int z2 = -z; z2 <= z; ++z2) {
setBlock(center.add(x, y, z2), block);
setBlock(center.add(-x, y, z2), block);
affected += 2;
}
}
} else if (x < z) {
for (int y = 0; y < height; y++) {
for (int x2 = -x; x2 <= x; x2++) {
for (int z2 = -z; z2 <= z; z2++) {
for (int y = 0; y < height; ++y) {
for (int x2 = -x; x2 <= x; ++x2) {
for (int z2 = -z; z2 <= z; ++z2) {
setBlock(center.add(x2, y, z2), block);
affected++;
++affected;
}
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);
while (x < z) {
x++;
++x;
if (d >= 0) {
z--;
d += 2 * (x - z) + 1;
d += 2 * (x - --z) + 1;
} else {
d += 2 * x + 1;
}
@ -1724,36 +1739,36 @@ public class EditSession {
boolean filled) throws MaxChangedBlocksException {
int affected = 0;
for (int x = 0; x <= radius; x++) {
for (int y = 0; y <= radius; y++) {
for (int z = 0; z <= radius; z++) {
for (int x = 0; x <= radius; ++x) {
for (int y = 0; y <= radius; ++y) {
for (int z = 0; z <= radius; ++z) {
Vector vec = pos.add(x, y, z);
double d = vec.distance(pos);
if (d <= radius + 0.5 && (filled || d >= radius - 0.5)) {
if (setBlock(vec, block)) {
affected++;
++affected;
}
if (setBlock(pos.add(-x, y, z), block)) {
affected++;
++affected;
}
if (setBlock(pos.add(x, -y, z), block)) {
affected++;
++affected;
}
if (setBlock(pos.add(x, y, -z), block)) {
affected++;
++affected;
}
if (setBlock(pos.add(-x, -y, z), block)) {
affected++;
++affected;
}
if (setBlock(pos.add(x, -y, -z), block)) {
affected++;
++affected;
}
if (setBlock(pos.add(-x, y, -z), block)) {
affected++;
++affected;
}
if (setBlock(pos.add(-x, -y, -z), block)) {
affected++;
++affected;
}
}
}
@ -1783,23 +1798,23 @@ public class EditSession {
BaseBlock air = new BaseBlock(0);
BaseBlock water = new BaseBlock(BlockID.STATIONARY_WATER);
for (int x = ox - radius; x <= ox + radius; x++) {
for (int z = oz - radius; z <= oz + radius; z++) {
for (int x = ox - radius; x <= ox + radius; ++x) {
for (int z = oz - radius; z <= oz + radius; ++z) {
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
continue;
}
for (int y = 127; y >= 1; y--) {
for (int y = 127; y >= 1; --y) {
Vector pt = new Vector(x, y, z);
int id = getBlockType(pt);
if (id == BlockID.ICE) { // Ice
if (setBlock(pt, water)) {
affected++;
++affected;
}
} else if (id == BlockID.SNOW) {
if (setBlock(pt, air)) {
affected++;
++affected;
}
} else if (id != 0) {
break;
@ -1831,13 +1846,13 @@ public class EditSession {
BaseBlock ice = new BaseBlock(79);
BaseBlock snow = new BaseBlock(78);
for (int x = ox - radius; x <= ox + radius; x++) {
for (int z = oz - radius; z <= oz + radius; z++) {
for (int x = ox - radius; x <= ox + radius; ++x) {
for (int z = oz - radius; z <= oz + radius; ++z) {
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
continue;
}
for (int y = 127; y >= 1; y--) {
for (int y = 127; y >= 1; --y) {
Vector pt = new Vector(x, y, z);
int id = getBlockType(pt);
@ -1871,7 +1886,7 @@ public class EditSession {
// Ice!
if (id == 8 || id == 9) {
if (setBlock(pt, ice)) {
affected++;
++affected;
}
break;
}
@ -1883,7 +1898,7 @@ public class EditSession {
}
if (setBlock(pt.add(0, 1, 0), snow)) {
affected++;
++affected;
}
break;
}
@ -1943,7 +1958,7 @@ public class EditSession {
if (getBlockType(pos) != 0)
return;
for (int i = -1; i > -3; i--) {
for (int i = -1; i > -3; --i) {
Vector testPos = pos.add(0, i, 0);
if (getBlockType(testPos) == 0) {
pos = testPos;
@ -1997,9 +2012,9 @@ public class EditSession {
int affected = 0;
for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX()
+ size; x++) {
+ size; ++x) {
for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ()
+ size; z++) {
+ size; ++z) {
// Don't want to be in the ground
if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir())
continue;
@ -2008,12 +2023,12 @@ public class EditSession {
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
int t = getBlock(new Vector(x, y, z)).getType();
if (t == 2 || t == 3) {
makePumpkinPatch(new Vector(x, y + 1, z));
affected++;
++affected;
break;
} else if (t != 0) { // Trees won't grow on this!
break;
@ -2040,9 +2055,9 @@ public class EditSession {
int affected = 0;
for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX()
+ size; x++) {
+ size; ++x) {
for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ()
+ size; z++) {
+ size; ++z) {
// Don't want to be in the ground
if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir())
continue;
@ -2051,12 +2066,12 @@ public class EditSession {
continue;
} // 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
int t = getBlock(new Vector(x, y, z)).getType();
if (t == 2 || t == 3) {
treeGenerator.generate(this, new Vector(x, y + 1, z));
affected++;
++affected;
break;
} else if (t != 0) { // Trees won't grow on this!
break;
@ -2090,13 +2105,13 @@ public class EditSession {
int maxY = max.getBlockY();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector pt = new Vector(x, y, z);
if (searchIDs.contains(getBlockType(pt))) {
count++;
++count;
}
}
}
@ -2104,7 +2119,7 @@ public class EditSession {
} else {
for (Vector pt : region) {
if (searchIDs.contains(getBlockType(pt))) {
count++;
++count;
}
}
}
@ -2134,9 +2149,9 @@ public class EditSession {
int maxY = max.getBlockY();
int maxZ = max.getBlockZ();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
for (int z = minZ; z <= maxZ; ++z) {
Vector pt = new Vector(x, y, z);
int id = getBlockType(pt);
@ -2184,7 +2199,7 @@ public class EditSession {
*/
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);
int id = getBlockType(pt);

View File

@ -58,8 +58,8 @@ public class HeightMap {
// Store current heightmap data
data = new int[width * height];
for (int z = 0; z < height; z++) {
for (int x = 0; x < width; x++) {
for (int z = 0; z < height; ++z) {
for (int x = 0; x < width; ++x) {
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];
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);
return apply(newData);
@ -104,8 +104,8 @@ public class HeightMap {
int blocksChanged = 0;
// Apply heightmap
for (int z = 0; z < height; z++) {
for (int x = 0; x < width; x++) {
for (int z = 0; z < height; ++z) {
for (int x = 0; x < width; ++x) {
int index = z * width + x;
int curHeight = this.data[index];
@ -127,32 +127,32 @@ public class HeightMap {
// Skip water/lava
if (existing.getType() < 8 || existing.getType() > 11) {
session.setBlock(new Vector(X, newHeight, Z), existing);
blocksChanged++;
++blocksChanged;
// 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);
session.setBlock(new Vector(X, originY + y, Z), session.getBlock(new Vector(X, originY + copyFrom, Z)));
blocksChanged++;
++blocksChanged;
}
}
} else if (curHeight > newHeight) {
// 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);
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
// (this could otherwise go wrong with rounding)
session.setBlock(new Vector(X, newHeight, Z), session.getBlock(new Vector(X, curHeight, Z)));
blocksChanged++;
++blocksChanged;
// 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);
blocksChanged++;
++blocksChanged;
}
}
}

View File

@ -74,7 +74,7 @@ public abstract class LocalPlayer {
while (y <= 129) {
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
free++;
++free;
} else {
free = 0;
}
@ -87,7 +87,7 @@ public abstract class LocalPlayer {
return;
}
y++;
++y;
}
}
@ -108,7 +108,7 @@ public abstract class LocalPlayer {
return;
}
y--;
--y;
}
}
@ -139,13 +139,13 @@ public abstract class LocalPlayer {
while (y <= 129) {
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
free++;
++free;
} else {
free = 0;
}
if (free == 2) {
spots++;
++spots;
if (spots == 2) {
int type = world.getBlockType(new Vector(x, y - 2, z));
@ -159,7 +159,7 @@ public abstract class LocalPlayer {
}
}
y++;
++y;
}
return false;
@ -181,7 +181,7 @@ public abstract class LocalPlayer {
while (y >= 1) {
if (BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) {
free++;
++free;
} else {
free = 0;
}
@ -200,13 +200,13 @@ public abstract class LocalPlayer {
return true;
}
y--;
--y;
}
return false;
}
y--;
--y;
}
return false;
@ -241,7 +241,7 @@ public abstract class LocalPlayer {
return true;
}
y++;
++y;
}
return false;
@ -274,7 +274,7 @@ public abstract class LocalPlayer {
return true;
}
y++;
++y;
}
return false;
@ -462,19 +462,19 @@ public abstract class LocalPlayer {
firstBlock = false;
if (!free) {
freeToFind--;
--freeToFind;
continue;
}
}
searchDist++;
++searchDist;
if (searchDist > 20) {
return false;
}
if (inFree != free) {
if (free) {
freeToFind--;
--freeToFind;
}
}

View File

@ -141,7 +141,7 @@ public class LocalSession {
* @return whether anything was undone
*/
public EditSession undo(BlockBag newBlockBag) {
historyPointer--;
--historyPointer;
if (historyPointer >= 0) {
EditSession editSession = history.get(historyPointer);
EditSession newEditSession =
@ -170,7 +170,7 @@ public class LocalSession {
newEditSession.enableQueue();
newEditSession.setFastMode(fastMode);
editSession.redo(newEditSession);
historyPointer++;
++historyPointer;
return editSession;
}
@ -591,7 +591,7 @@ public class LocalSession {
player.dispatchCUIEvent(
new SelectionPointEvent(i, pt, size));
}
i++;
++i;
}
}
}

View File

@ -69,6 +69,7 @@ public abstract class LocalWorld {
* @param pt
* @param data
*/
public abstract void setBlockData(Vector pt, int data);
/**
@ -77,10 +78,26 @@ public abstract class LocalWorld {
* @param pt
* @param data
*/
public void setBlockDataFast(Vector pt, int data) {
setBlockData(pt, data);
}
public abstract void setBlockDataFast(Vector pt, int 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.
*
@ -195,7 +212,7 @@ public abstract class LocalWorld {
* @param 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);
}
}

View File

@ -230,7 +230,7 @@ public class Vector {
public Vector add(Vector ... others) {
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;
newY += others[i].y;
newZ += others[i].z;
@ -281,7 +281,7 @@ public class Vector {
public Vector subtract(Vector ... others) {
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;
newY -= others[i].y;
newZ -= others[i].z;
@ -332,7 +332,7 @@ public class Vector {
public Vector multiply(Vector ... others) {
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;
newY *= others[i].y;
newZ *= others[i].z;

View File

@ -812,7 +812,7 @@ public class WorldEdit {
? type.getName() + " (" + id + ")"
: id.toString());
i++;
++i;
if (i != size) {
str.append(", ");

View File

@ -100,7 +100,7 @@ public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerB
public Map<String,Tag> toTileEntityNBT()
throws DataException {
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];
if (item != null) {
Map<String,Tag> data = new HashMap<String,Tag>();

View File

@ -100,7 +100,7 @@ public class DispenserBlock extends BaseBlock implements TileEntityBlock, Contai
public Map<String,Tag> toTileEntityNBT()
throws DataException {
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];
if (item != null) {
Map<String,Tag> data = new HashMap<String,Tag>();

View File

@ -142,7 +142,7 @@ public class FurnaceBlock extends BaseBlock implements TileEntityBlock, Containe
public Map<String,Tag> toTileEntityNBT()
throws DataException {
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];
if (item != null) {
Map<String,Tag> data = new HashMap<String,Tag>();

View File

@ -76,7 +76,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
boolean found = false;
for (int slot = 0; slot < items.length; slot++) {
for (int slot = 0; slot < items.length; ++slot) {
ItemStack item = items[slot];
if (item == null) continue;
@ -123,7 +123,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
boolean found = false;
int freeSlot = -1;
for (int slot = 0; slot < items.length; slot++) {
for (int slot = 0; slot < items.length; ++slot) {
ItemStack item = items[slot];
// Delay using up a free slot until we know there are no stacks

View File

@ -94,6 +94,30 @@ public class BukkitWorld extends LocalWorld {
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.
*
@ -164,9 +188,9 @@ public class BukkitWorld extends LocalWorld {
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
// First save all the blocks inside
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 128; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 128; ++y) {
for (int z = 0; z < 16; ++z) {
Vector pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
history[index] = editSession.getBlock(pt);
@ -181,9 +205,9 @@ public class BukkitWorld extends LocalWorld {
}
// Then restore
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 128; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; ++x) {
for (int y = 0; y < 128; ++y) {
for (int z = 0; z < 16; ++z) {
Vector pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
@ -446,7 +470,7 @@ public class BukkitWorld extends LocalWorld {
if (radius == -1
|| origin.distanceSq(BukkitUtil.toVector(ent.getLocation())) <= radiusSq) {
ent.remove();
num++;
++num;
}
}
}
@ -475,32 +499,32 @@ public class BukkitWorld extends LocalWorld {
if (type == EntityType.ARROWS) {
if (ent instanceof Arrow) {
ent.remove();
num++;
++num;
}
} else if (type == EntityType.BOATS) {
if (ent instanceof Boat) {
ent.remove();
num++;
++num;
}
} else if (type == EntityType.ITEMS) {
if (ent instanceof Item) {
ent.remove();
num++;
++num;
}
} else if (type == EntityType.MINECARTS) {
if (ent instanceof Minecart) {
ent.remove();
num++;
++num;
}
} else if (type == EntityType.PAINTINGS) {
if (ent instanceof Painting) {
ent.remove();
num++;
++num;
}
} else if (type == EntityType.TNT) {
if (ent instanceof TNTPrimed) {
ent.remove();
num++;
++num;
}
}
}
@ -578,7 +602,7 @@ public class BukkitWorld extends LocalWorld {
int size = inven.getSize();
BaseItemStack[] contents = new BaseItemStack[size];
for (int i = 0; i < size; i++) {
for (int i = 0; i < size; ++i) {
ItemStack bukkitStack = inven.getItem(i);
if (bukkitStack.getTypeId() > 0) {
contents[i] = new BaseItemStack(
@ -612,7 +636,7 @@ public class BukkitWorld extends LocalWorld {
Inventory inven = chest.getInventory();
int size = inven.getSize();
for (int i = 0; i < size; i++) {
for (int i = 0; i < size; ++i) {
if (i >= contents.length) {
break;
}

View File

@ -187,7 +187,7 @@ public class GeneralCommands {
for (String alias : type.getAliases()) {
if (alias.contains(query)) {
player.print("#" + type.getID() + " (" + type.getName() + ")");
found++;
++found;
break;
}
}

View File

@ -44,7 +44,7 @@ public class HistoryCommands {
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));
if (undone != null) {
player.print("Undo successful.");
@ -70,7 +70,7 @@ public class HistoryCommands {
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));
if (redone != null) {
player.print("Redo successful.");

View File

@ -65,7 +65,7 @@ public class NavigationCommands {
}
int ascentLevels = 1;
while (player.ascendLevel() && levelsToAscend != ascentLevels) {
ascentLevels++;
++ascentLevels;
}
if (ascentLevels == 0) {
player.printError("No free spot above you found.");
@ -94,7 +94,7 @@ public class NavigationCommands {
}
int descentLevels = 1;
while (player.descendLevel() && levelsToDescend != descentLevels) {
descentLevels++;
++descentLevels;
}
if (descentLevels == 0) {
player.printError("No free spot above you found.");

View File

@ -63,7 +63,7 @@ public class SnapshotCommands {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true);
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());
}

View File

@ -34,7 +34,7 @@ public class ForwardSeekableInputStream extends InputStream {
@Override
public int read() throws IOException {
int ret = parent.read();
position++;
++position;
return ret;
}

View File

@ -129,7 +129,7 @@ public class DocumentationPrinter {
method.getAnnotation(CommandPermissions.class);
String[] permKeys = perms.value();
for (int i = 0; i < permKeys.length; i++) {
for (int i = 0; i < permKeys.length; ++i) {
if (i > 0) {
stream.print(", ");
}

View File

@ -46,8 +46,8 @@ public class GaussianKernel extends Kernel {
double sigma22 = 2 * sigma * sigma;
double constant = Math.PI * sigma22;
for (int y = -radius; y <= radius; y++) {
for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; ++y) {
for (int x = -radius; x <= radius; ++x) {
data[(y+radius) * diameter + x+radius] = (float) (Math.exp(-(x * x + y * y) / sigma22) / constant);
}
}

View File

@ -85,11 +85,11 @@ public class HeightMapFilter {
int kox = kernel.getXOrigin();
int koy = kernel.getYOrigin();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
float z = 0;
for (int ky = 0; ky < kh; ky++) {
for (int ky = 0; ky < kh; ++ky) {
int offsetY = y + ky - koy;
// Clamp coordinates inside data
if (offsetY < 0 || offsetY >= height)
@ -98,7 +98,7 @@ public class HeightMapFilter {
offsetY *= width;
int matrixOffset = ky * kw;
for (int kx = 0; kx < kw; kx++) {
for (int kx = 0; kx < kw; ++kx) {
float f = matrix[matrixOffset + kx];
if (f == 0) continue;

View File

@ -275,9 +275,9 @@ public class CuboidRegion implements Region {
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
Vector pt = new Vector(x, y, z);
chunks.add(ChunkStore.toChunk(pt));
}
@ -325,14 +325,11 @@ public class CuboidRegion implements Region {
public BlockVector next() {
if (!hasNext()) throw new java.util.NoSuchElementException();
BlockVector answer = new BlockVector(nextX, nextY, nextZ);
nextX++;
if (nextX > max.getBlockX()) {
if (++nextX > max.getBlockX()) {
nextX = min.getBlockX();
nextY++;
if (nextY > max.getBlockY()) {
if (++nextY > max.getBlockY()) {
nextY = min.getBlockY();
nextZ++;
if (nextZ > max.getBlockZ()) {
if (++nextZ > max.getBlockZ()) {
nextX = Integer.MIN_VALUE;
}
}

View File

@ -192,7 +192,7 @@ public class Polygonal2DRegion implements Region {
double area = 0;
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())
* (points.get(j).getBlockZ() - points.get(i).getBlockZ());
j = i;
@ -307,7 +307,7 @@ public class Polygonal2DRegion implements Region {
xOld = points.get(npoints - 1).getBlockX();
zOld = points.get(npoints - 1).getBlockZ();
for (i = 0; i < npoints; i++) {
for (i = 0; i < npoints; ++i) {
xNew = points.get(i).getBlockX();
zNew = points.get(i).getBlockZ();
//Check for corner
@ -348,9 +348,9 @@ public class Polygonal2DRegion implements Region {
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
Vector pt = new Vector(x, y, z);
if (contains(pt)) { // Not the best
chunks.add(ChunkStore.toChunk(pt));
@ -414,11 +414,11 @@ public class Polygonal2DRegion implements Region {
int minZ = getMinimumPoint().getBlockZ();
int maxZ = getMaximumPoint().getBlockZ();
for (pixelZ = minZ; pixelZ < maxZ; pixelZ++) {
for (pixelZ = minZ; pixelZ < maxZ; ++pixelZ) {
// Build a list of nodes
nodes = 0;
j = n - 1;
for (i = 0; i < n; i++) {
for (i = 0; i < n; ++i) {
if (points.get(i).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 + 1] = swap;
if (i > 0)
i--;
--i;
} else {
i++;
++i;
}
}
// Fill the pixels between node pairs
for (i = 0; i < nodes; i += 2) {
for (j = nodeX[i]; j < nodeX[i + 1]; j++) {
for (int y = minY; y >= maxY; y++) {
for (j = nodeX[i]; j < nodeX[i + 1]; ++j) {
for (int y = minY; y >= maxY; ++y) {
items.add(new BlockVector(j, y, pixelZ));
}
}
@ -504,10 +504,10 @@ public class Polygonal2DRegion implements Region {
}
if (next != null && curY <= maxY) {
curY++;
++curY;
next = new BlockVector(curX, curY, curZ);
if (curY > maxY) {
i++;
++i;
curY = minY;
} else {
return;
@ -522,7 +522,7 @@ public class Polygonal2DRegion implements Region {
next = pt;
return;
}
i++;
++i;
}
next = null;

View File

@ -79,7 +79,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory {
s.append(m);
s.append("(");
for (int i = 0; i < args.length; i++) {
for (int i = 0; i < args.length; ++i) {
s.append(args[i]);
if (i < args.length - 1) {
s.append(",");

View File

@ -82,9 +82,9 @@ public class SnapshotRestore {
// First, we need to group points by chunk so that we only need
// to keep one chunk in memory at any given moment
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
Vector pos = new Vector(x, y, z);
BlockVector2D chunkPos = ChunkStore.toChunk(pos);

View File

@ -59,9 +59,9 @@ public class AreaPickaxe implements BlockTool {
EditSession editSession = session.createEditSession(player);
try {
for (int x = ox - range; x <= ox + range; x++) {
for (int y = oy - range; y <= oy + range; y++) {
for (int z = oz - range; z <= oz + range; z++) {
for (int x = ox - range; x <= ox + range; ++x) {
for (int y = oy - range; y <= oy + range; ++y) {
for (int z = oz - range; z <= oz + range; ++z) {
Vector pos = new Vector(x, y, z);
if (world.getBlockType(pos) == initialType) {
if (config.superPickaxeManyDrop) {

View File

@ -119,9 +119,9 @@ public class FloatingTreeRemover implements BlockTool {
}
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
for (int k = -1; k <= 1; k++) {
for (int i = -1; i <= 1; ++i) {
for (int j = -1; j <= 1; ++j) {
for (int k = -1; k <= 1; ++k) {
if (Math.abs(i) + Math.abs(j) + Math.abs(k) == 1) {
if (!recurse(server, editSession, world, pos.add(i, j, k).toBlockVector(),
origin, size, visited, block)) {

View File

@ -181,7 +181,7 @@ public class TreeGenerator {
BaseBlock leavesBlock = new BaseBlock(18);
// 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)) {
return;
}
@ -191,7 +191,7 @@ public class TreeGenerator {
basePos = basePos.add(0, trunkHeight, 0);
// 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);
// Less leaves at these levels
@ -208,16 +208,16 @@ public class TreeGenerator {
editSession.setChanceBlockIfAir(basePos.add(-1, i, -1), leavesBlock, chance);
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);
}
for (int j = -2; j <= 2; j++) {
for (int j = -2; j <= 2; ++j) {
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);
}
for (int j = -2; j <= 2; j++) {
for (int j = -2; j <= 2; ++j) {
editSession.setChanceBlockIfAir(basePos.add(j, i, 2), leavesBlock, 0.6);
}
}