3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-10 05:20:04 +01:00

Improved overall performance by using EditSession.getBlockType() instead of EditSession.getBlock().getType().

Dieser Commit ist enthalten in:
sk89q 2011-01-30 23:42:18 -08:00
Ursprung 88d7128135
Commit 2630226052
2 geänderte Dateien mit 19 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -278,13 +278,13 @@ 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 getBlock(pt).getType() != block.getType(); return getBlockType(pt) != block.getType();
// Destroy torches, etc. first // Destroy torches, etc. first
} else if (BlockType.shouldPlaceLast(getBlock(pt).getType())) { } 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 getBlock(pt).getType() != block.getType(); return getBlockType(pt) != block.getType();
} }
} }
@ -911,7 +911,7 @@ public class EditSession {
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 = getBlock(pt).getType(); int curBlockType = getBlockType(pt);
if ((fromBlockTypes == null && curBlockType != 0) if ((fromBlockTypes == null && curBlockType != 0)
|| (fromBlockTypes != null && fromBlockTypes || (fromBlockTypes != null && fromBlockTypes
@ -925,7 +925,7 @@ public class EditSession {
} }
} else { } else {
for (Vector pt : region) { for (Vector pt : region) {
int curBlockType = getBlock(pt).getType(); int curBlockType = getBlockType(pt);
if (fromBlockTypes == null && curBlockType != 0 if (fromBlockTypes == null && curBlockType != 0
|| fromBlockTypes.contains(curBlockType)) { || fromBlockTypes.contains(curBlockType)) {
@ -969,7 +969,7 @@ public class EditSession {
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 = getBlock(pt).getType(); int curBlockType = getBlockType(pt);
if ((fromBlockTypes == null && curBlockType != 0) if ((fromBlockTypes == null && curBlockType != 0)
|| (fromBlockTypes != null && fromBlockTypes || (fromBlockTypes != null && fromBlockTypes
@ -983,7 +983,7 @@ public class EditSession {
} }
} else { } else {
for (Vector pt : region) { for (Vector pt : region) {
int curBlockType = getBlock(pt).getType(); int curBlockType = getBlockType(pt);
if (fromBlockTypes == null && curBlockType != 0 if (fromBlockTypes == null && curBlockType != 0
|| fromBlockTypes.contains(curBlockType)) { || fromBlockTypes.contains(curBlockType)) {
@ -1331,7 +1331,7 @@ public class EditSession {
while (!queue.empty()) { while (!queue.empty()) {
BlockVector cur = queue.pop(); BlockVector cur = queue.pop();
int type = getBlock(cur).getType(); int type = getBlockType(cur);
// Check block type // Check block type
if (type != 8 && type != 9 && type != 10 && type != 11) { if (type != 8 && type != 9 && type != 10 && type != 11) {
@ -1403,7 +1403,7 @@ public class EditSession {
while (!queue.empty()) { while (!queue.empty()) {
BlockVector cur = queue.pop(); BlockVector cur = queue.pop();
int type = getBlock(cur).getType(); int type = getBlockType(cur);
// Check block type // Check block type
if (type != moving && type != stationary && type != 0) { if (type != moving && type != stationary && type != 0) {
@ -1698,7 +1698,7 @@ public class EditSession {
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 = getBlock(pt).getType(); int id = getBlockType(pt);
if (id == BlockID.ICE) { // Ice if (id == BlockID.ICE) { // Ice
if (setBlock(pt, water)) { if (setBlock(pt, water)) {
@ -1746,7 +1746,7 @@ public class EditSession {
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 = getBlock(pt).getType(); int id = getBlockType(pt);
// Snow should not cover these blocks // Snow should not cover these blocks
if (id == 6 // Saplings if (id == 6 // Saplings
@ -1847,12 +1847,12 @@ public class EditSession {
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
if (pos.distance(basePos) > 4) if (pos.distance(basePos) > 4)
return; return;
if (getBlock(pos).getType() != 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 (getBlock(testPos).getType() == 0) { if (getBlockType(testPos) == 0) {
pos = testPos; pos = testPos;
} else { } else {
break; break;
@ -2000,7 +2000,7 @@ public class EditSession {
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(getBlock(pt).getType())) { if (searchIDs.contains(getBlockType(pt))) {
count++; count++;
} }
} }
@ -2008,7 +2008,7 @@ public class EditSession {
} }
} else { } else {
for (Vector pt : region) { for (Vector pt : region) {
if (searchIDs.contains(getBlock(pt).getType())) { if (searchIDs.contains(getBlockType(pt))) {
count++; count++;
} }
} }
@ -2044,7 +2044,7 @@ public class EditSession {
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 = getBlock(pt).getType(); int id = getBlockType(pt);
if (map.containsKey(id)) { if (map.containsKey(id)) {
map.get(id).increment(); map.get(id).increment();
@ -2058,7 +2058,7 @@ public class EditSession {
} }
} else { } else {
for (Vector pt : region) { for (Vector pt : region) {
int id = getBlock(pt).getType(); int id = getBlockType(pt);
if (map.containsKey(id)) { if (map.containsKey(id)) {
map.get(id).increment(); map.get(id).increment();
@ -2091,7 +2091,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 = getBlock(pt).getType(); int id = getBlockType(pt);
if (id == 1 // stone if (id == 1 // stone
|| id == 2 // grass || id == 2 // grass

Datei anzeigen

@ -54,6 +54,6 @@ public class EditSessionBlockChangeDegate implements BlockChangeDelegate {
} }
public int getTypeId(int x, int y, int z) { public int getTypeId(int x, int y, int z) {
return editSession.getBlock(new Vector(x, y, z)).getType(); return editSession.getBlockType(new Vector(x, y, z));
} }
} }