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

@ -47,11 +47,11 @@ final class ForgeAdapter {
}
public static Vector3 adapt(Vec3d vector) {
return new Vector3(vector.x, vector.y, vector.z);
return Vector3.at(vector.x, vector.y, vector.z);
}
public static Vector3 adapt(BlockPos pos) {
return new Vector3(pos.getX(), pos.getY(), pos.getZ());
return Vector3.at(pos.getX(), pos.getY(), pos.getZ());
}
public static Vec3d toVec3(BlockVector3 vector) {

View File

@ -66,7 +66,7 @@ class ForgeEntity implements Entity {
public Location getLocation() {
net.minecraft.entity.Entity entity = entityRef.get();
if (entity != null) {
Vector3 position = new Vector3(entity.posX, entity.posY, entity.posZ);
Vector3 position = Vector3.at(entity.posX, entity.posY, entity.posZ);
float yaw = entity.rotationYaw;
float pitch = entity.rotationPitch;

View File

@ -80,7 +80,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
public Location getLocation() {
Vector3 position = new Vector3(this.player.posX, this.player.posY, this.player.posZ);
Vector3 position = Vector3.at(this.player.posX, this.player.posY, this.player.posZ);
return new Location(
ForgeWorldEdit.inst.getWorld(this.player.world),
position,

View File

@ -449,7 +449,7 @@ public class ForgeWorld extends AbstractWorld {
public List<? extends Entity> getEntities(Region region) {
List<Entity> entities = new ArrayList<>();
for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) {
if (region.contains(new BlockVector3(entity.posX, entity.posY, entity.posZ))) {
if (region.contains(BlockVector3.at(entity.posX, entity.posY, entity.posZ))) {
entities.add(new ForgeEntity(entity));
}
}