Optimize schematics

This commit is contained in:
boy0001 2015-07-16 13:09:10 +10:00
parent 3000aa371f
commit ad85749c38
2 changed files with 137 additions and 22 deletions

View File

@ -98,12 +98,125 @@ public class BukkitSchematicHandler extends SchematicHandler {
World worldObj = Bukkit.getWorld(world);
for (int x = 0; x < width; x++) {
for (int z = 0; z < length; z++) {
for (int y = 0; y < height; y++) {
final int index = (y * width * length) + (z * width) + x;
int i1 = (y * width * length);
for (int z = 0; z < length; z++) {
int i2 = i1 + (z * width);
for (int x = 0; x < width; x++) {
final int index = i2 + x;
Block block = worldObj.getBlockAt(sx + x, sy + y, sz + z);
int id = block.getTypeId();
switch(id) {
case 0:
case 2:
case 4:
case 13:
case 14:
case 15:
case 20:
case 21:
case 22:
case 24:
case 30:
case 32:
case 37:
case 39:
case 40:
case 41:
case 42:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 55:
case 56:
case 57:
case 58:
case 60:
case 7:
case 8:
case 9:
case 10:
case 11:
case 73:
case 74:
case 75:
case 76:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 85:
case 87:
case 88:
case 101:
case 102:
case 103:
case 110:
case 112:
case 113:
case 121:
case 122:
case 129:
case 133:
case 165:
case 166:
case 169:
case 170:
case 172:
case 173:
case 174:
case 181:
case 182:
case 188:
case 189:
case 190:
case 191:
case 192: {
break;
}
case 54:
case 130:
case 142:
case 27:
case 137:
case 52:
case 154:
case 84:
case 25:
case 144:
case 138:
case 176:
case 177:
case 63:
case 68:
case 323:
case 117:
case 116:
case 28:
case 66:
case 157:
case 61:
case 62:
case 140:
case 146:
case 149:
case 150:
case 158:
case 23:
case 123:
case 124:
case 29:
case 33:
case 151:
case 178: {
// TODO implement fully
BlockState state = block.getState();
if (state != null) {
StateWrapper wrapper = new StateWrapper(state);
@ -121,8 +234,11 @@ public class BukkitSchematicHandler extends SchematicHandler {
tileEntities.add(tileEntityTag);
}
}
int id = block.getTypeId();
byte data = block.getData();
}
default: {
blockData[index] = block.getData();
}
}
if (id > 255) {
if (addBlocks == null) {
addBlocks = new byte[(blocks.length >> 1) + 1];
@ -130,7 +246,6 @@ public class BukkitSchematicHandler extends SchematicHandler {
addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? (addBlocks[index >> 1] & 0xF0) | ((id >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((id >> 8) & 0xF) << 4));
}
blocks[index] = (byte) id;
blockData[index] = data;
}
}
}

View File

@ -512,7 +512,7 @@ public abstract class SchematicHandler {
*
* @author Citymonstret
*/
public class Dimension {
public static class Dimension {
private final int x;
private final int y;
private final int z;