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

@ -240,7 +240,7 @@ public class BukkitAdapter {
*/
public static Vector3 asVector(org.bukkit.Location location) {
checkNotNull(location);
return new Vector3(location.getX(), location.getY(), location.getZ());
return Vector3.at(location.getX(), location.getY(), location.getZ());
}
/**
@ -251,7 +251,7 @@ public class BukkitAdapter {
*/
public static BlockVector3 asBlockVector(org.bukkit.Location location) {
checkNotNull(location);
return new BlockVector3(location.getX(), location.getY(), location.getZ());
return BlockVector3.at(location.getX(), location.getY(), location.getZ());
}
/**

View File

@ -175,7 +175,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
return;
}
setPosition(new Vector3(x + 0.5, y, z + 0.5));
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
player.setFlying(true);
}

View File

@ -169,7 +169,7 @@ public class BukkitWorld extends AbstractWorld {
BlockStateHolder[] history = new BlockStateHolder[16 * 16 * (getMaxY() + 1)];
for (BlockVector2 chunk : region.getChunks()) {
BlockVector3 min = new BlockVector3(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
// First save all the blocks inside
for (int x = 0; x < 16; ++x) {

View File

@ -40,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
@Override
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
try {
editSession.setBlock(new BlockVector3(x, y, z), BukkitAdapter.adapt(blockData));
editSession.setBlock(BlockVector3.at(x, y, z), BukkitAdapter.adapt(blockData));
} catch (MaxChangedBlocksException e) {
return false;
}
@ -49,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
@Override
public BlockData getBlockData(int x, int y, int z) {
return BukkitAdapter.adapt(editSession.getBlock(new BlockVector3(x, y, z)));
return BukkitAdapter.adapt(editSession.getBlock(BlockVector3.at(x, y, z)));
}
@Override
@ -59,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
@Override
public boolean isEmpty(int x, int y, int z) {
return editSession.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir();
return editSession.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir();
}
}