Move vectors to static creators, for caching

This commit is contained in:
Kenzie Togami
2018-10-19 13:13:32 -07:00
parent 399e0ad5fa
commit 2c8b2fe089
69 changed files with 366 additions and 334 deletions

View File

@ -116,12 +116,12 @@ public class MCEditSchematicReader extends NBTSchematicReader {
int originX = requireTag(schematic, "WEOriginX", IntTag.class).getValue();
int originY = requireTag(schematic, "WEOriginY", IntTag.class).getValue();
int originZ = requireTag(schematic, "WEOriginZ", IntTag.class).getValue();
BlockVector3 min = new BlockVector3(originX, originY, originZ);
BlockVector3 min = BlockVector3.at(originX, originY, originZ);
int offsetX = requireTag(schematic, "WEOffsetX", IntTag.class).getValue();
int offsetY = requireTag(schematic, "WEOffsetY", IntTag.class).getValue();
int offsetZ = requireTag(schematic, "WEOffsetZ", IntTag.class).getValue();
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ);
origin = min.subtract(offset);
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
@ -205,7 +205,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
}
}
BlockVector3 vec = new BlockVector3(x, y, z);
BlockVector3 vec = BlockVector3.at(x, y, z);
tileEntitiesMap.put(vec, values);
}
@ -219,7 +219,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
for (int y = 0; y < height; ++y) {
for (int z = 0; z < length; ++z) {
int index = y * width * length + z * width + x;
BlockVector3 pt = new BlockVector3(x, y, z);
BlockVector3 pt = BlockVector3.at(x, y, z);
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(blocks[index], blockData[index]);
try {

View File

@ -109,14 +109,14 @@ public class SpongeSchematicReader extends NBTSchematicReader {
throw new IOException("Invalid offset specified in schematic.");
}
BlockVector3 min = new BlockVector3(offsetParts[0], offsetParts[1], offsetParts[2]);
BlockVector3 min = BlockVector3.at(offsetParts[0], offsetParts[1], offsetParts[2]);
if (metadata.containsKey("WEOffsetX")) {
// We appear to have WorldEdit Metadata
int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
BlockVector3 offset = new BlockVector3(offsetX, offsetY, offsetZ);
BlockVector3 offset = BlockVector3.at(offsetX, offsetY, offsetZ);
origin = min.subtract(offset);
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
} else {
@ -159,7 +159,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
for (Map<String, Tag> tileEntity : tileEntityTags) {
int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
tileEntitiesMap.put(new BlockVector3(pos[0], pos[1], pos[2]), tileEntity);
tileEntitiesMap.put(BlockVector3.at(pos[0], pos[1], pos[2]), tileEntity);
}
} catch (Exception e) {
throw new IOException("Failed to load Tile Entities: " + e.getMessage());
@ -192,7 +192,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
int z = (index % (width * length)) / width;
int x = (index % (width * length)) % width;
BlockState state = palette.get(value);
BlockVector3 pt = new BlockVector3(x, y, z);
BlockVector3 pt = BlockVector3.at(x, y, z);
try {
if (tileEntitiesMap.containsKey(pt)) {
Map<String, Tag> values = Maps.newHashMap(tileEntitiesMap.get(pt));

View File

@ -126,7 +126,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
int z0 = min.getBlockZ() + z;
for (int x = 0; x < width; x++) {
int x0 = min.getBlockX() + x;
BlockVector3 point = new BlockVector3(x0, y0, z0);
BlockVector3 point = BlockVector3.at(x0, y0, z0);
BaseBlock block = clipboard.getFullBlock(point);
if (block.getNbtData() != null) {
Map<String, Tag> values = new HashMap<>();