Move vectors to static creators, for caching

This commit is contained in:
Kenzie Togami
2018-10-19 13:13:32 -07:00
committed by IronApollo
parent a9919d130c
commit 4d6045813c
138 changed files with 670 additions and 531 deletions

View File

@ -115,7 +115,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte free = 0;
while (y <= world.getMaximumPoint().getBlockY() + 2) {
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
++free;
} else {
free = 0;
@ -123,10 +123,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (free == 2) {
if (y - 1 != origY) {
final BlockVector3 pos = new BlockVector3(x, y - 2, z);
final BlockVector3 pos = BlockVector3.at(x, y - 2, z);
final BlockStateHolder state = world.getBlock(pos);
setPosition(new Vector3(x + 0.5, y - 2 + BlockType.centralTopLimit(state), z + 0.5));
// setPosition(new Vector3(x + 0.5, y - 2 + 1, z + 0.5));
setPosition(Vector3.at(x + 0.5, y - 2 + BlockType.centralTopLimit(state), z + 0.5));
// setPosition(Vector3.at(x + 0.5, y - 2 + 1, z + 0.5));
}
return;
@ -144,10 +144,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
int z = searchPos.getBlockZ();
while (y >= 0) {
final BlockVector3 pos = new BlockVector3(x, y, z);
final BlockVector3 pos = BlockVector3.at(x, y, z);
final BlockState id = world.getBlock(pos);
if (id.getBlockType().getMaterial().isMovementBlocker()) {
setPosition(new Vector3(x + 0.5, y + + BlockType.centralTopLimit(id), z + 0.5));
setPosition(Vector3.at(x + 0.5, y + + BlockType.centralTopLimit(id), z + 0.5));
return;
}
@ -171,7 +171,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
int maxY = world.getMaxY();
if (y >= maxY) return false;
BlockMaterial initialMaterial = world.getBlockType(new BlockVector3(x, y, z)).getMaterial();
BlockMaterial initialMaterial = world.getBlockType(BlockVector3.at(x, y, z)).getMaterial();
boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
@ -181,7 +181,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
for (int level = y + 1; level <= maxY + 2; level++) {
BlockState state;
if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState();
else state = world.getBlock(new BlockVector3(x, level, z));
else state = world.getBlock(BlockVector3.at(x, level, z));
BlockTypes type = state.getBlockType();
BlockMaterial material = type.getMaterial();
@ -196,7 +196,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
double bottomLimit = BlockType.centralBottomLimit(state);
double space = level + bottomLimit - freeStart;
if (space >= height) {
setPosition(new Vector3(x + 0.5, freeStart, z + 0.5));
setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5));
return true;
}
// Not enough room, reset the free position
@ -220,7 +220,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
final int z = pos.getBlockZ();
final Extent world = pos.getExtent();
BlockMaterial initialMaterial = world.getBlockType(new BlockVector3(x, y, z)).getMaterial();
BlockMaterial initialMaterial = world.getBlockType(BlockVector3.at(x, y, z)).getMaterial();
boolean lastState = initialMaterial.isMovementBlocker() && initialMaterial.isFullCube();
@ -233,7 +233,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
for (int level = y + 1; level > 0; level--) {
BlockState state;
if (level >= maxY) state = BlockTypes.VOID_AIR.getDefaultState();
else state = world.getBlock(new BlockVector3(x, level, z));
else state = world.getBlock(BlockVector3.at(x, level, z));
BlockTypes type = state.getBlockType();
BlockMaterial material = type.getMaterial();
@ -249,7 +249,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
double freeStart = level + topLimit;
double space = freeEnd - freeStart;
if (space >= height) {
setPosition(new Vector3(x + 0.5, freeStart, z + 0.5));
setPosition(Vector3.at(x + 0.5, freeStart, z + 0.5));
return true;
}
// Not enough room, reset the free position
@ -280,13 +280,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
Extent world = getLocation().getExtent();
// No free space above
if (!world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isAir()) {
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isAir()) {
return false;
}
while (y <= world.getMaximumPoint().getY()) {
// Found a ceiling!
if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
int platformY = Math.max(initialY, y - 3 - clearance);
floatAt(x, platformY + 1, z, alwaysGlass);
return true;
@ -314,7 +314,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
final Extent world = getLocation().getExtent();
while (y <= world.getMaximumPoint().getY() + 2) {
if (world.getBlock(new BlockVector3(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
if (world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
break; // Hit something
} else if (y > maxY + 1) {
break;
@ -332,14 +332,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
try {
BlockVector3 spot = new BlockVector3(x, y - 1, z);
BlockVector3 spot = BlockVector3.at(x, y - 1, z);
if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) {
getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState());
}
}catch (WorldEditException e) {
e.printStackTrace();
}
setPosition(new Vector3(x + 0.5, y, z + 0.5));
setPosition(Vector3.at(x + 0.5, y, z + 0.5));
}
@Override