Location is gone.

This commit is contained in:
dfsek
2021-06-25 13:47:56 -07:00
parent 966e1eb2a6
commit d880d95637
13 changed files with 31 additions and 386 deletions

View File

@@ -1,198 +0,0 @@
package com.dfsek.terra.vector;
import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.api.vector.Vector3;
import com.dfsek.terra.api.world.World;
import java.util.Objects;
public class LocationImpl implements Location {
private World world;
private Vector3 vector;
private double pitch;
private double yaw;
public LocationImpl(World w, double x, double y, double z) {
this.world = w;
this.vector = new Vector3Impl(x, y, z);
}
public LocationImpl(World w, Vector3 vector) {
this.world = w;
this.vector = vector;
}
@Override
public void setWorld(World world) {
this.world = world;
}
@Override
public Vector3 getVector() {
return vector;
}
@Override
public void setVector(Vector3 vector) {
this.vector = vector;
}
@Override
public Location clone() {
try {
LocationImpl other = (LocationImpl) super.clone();
other.setVector(other.getVector().clone());
return other;
} catch(CloneNotSupportedException e) {
throw new Error(e);
}
}
@Override
public int getBlockX() {
return vector.getBlockX();
}
@Override
public int getBlockY() {
return vector.getBlockY();
}
@Override
public int getBlockZ() {
return vector.getBlockZ();
}
@Override
public double getY() {
return vector.getY();
}
@Override
public Location setY(double y) {
vector.setY(y);
return this;
}
@Override
public double getX() {
return vector.getX();
}
@Override
public Location setX(double x) {
vector.setX(x);
return this;
}
@Override
public double getZ() {
return vector.getZ();
}
@Override
public LocationImpl setZ(double z) {
vector.setZ(z);
return this;
}
@Override
public World getWorld() {
return world;
}
@Override
public Location add(double x, double y, double z) {
vector.add(x, y, z);
return this;
}
@Override
public Location subtract(int x, int y, int z) {
vector.subtract(x, y, z);
return this;
}
@Override
public Location add(Vector3 add) {
vector.add(add);
return this;
}
@Override
public Location add(Location add) {
vector.add(add.toVector());
return this;
}
@Override
public boolean equals(Object obj) {
if(!(obj instanceof LocationImpl)) {
return false;
}
final LocationImpl other = (LocationImpl) obj;
World world = this.world;
World otherWorld = other.world;
if(!Objects.equals(world, otherWorld)) {
return false;
}
if(Double.doubleToLongBits(this.vector.getX()) != Double.doubleToLongBits(other.vector.getX())) {
return false;
}
if(Double.doubleToLongBits(this.vector.getY()) != Double.doubleToLongBits(other.vector.getY())) {
return false;
}
return Double.doubleToLongBits(this.vector.getZ()) == Double.doubleToLongBits(other.vector.getZ());
}
@Override
public double getPitch() {
return pitch;
}
@Override
public void setPitch(double pitch) {
this.pitch = pitch;
}
@Override
public double getYaw() {
return yaw;
}
@Override
public void setYaw(double yaw) {
this.yaw = yaw;
}
@Override
public int hashCode() {
int hash = 3;
World world = (this.world == null) ? null : this.world;
hash = 19 * hash + (world != null ? world.hashCode() : 0);
hash = 19 * hash + (int) (Double.doubleToLongBits(this.vector.getX()) ^ (Double.doubleToLongBits(this.vector.getX()) >>> 32));
hash = 19 * hash + (int) (Double.doubleToLongBits(this.vector.getY()) ^ (Double.doubleToLongBits(this.vector.getY()) >>> 32));
hash = 19 * hash + (int) (Double.doubleToLongBits(this.vector.getZ()) ^ (Double.doubleToLongBits(this.vector.getZ()) >>> 32));
hash = 19 * hash + (int) (Double.doubleToLongBits(this.pitch) ^ Double.doubleToLongBits(this.pitch) >>> 32);
hash = 19 * hash + (int) (Double.doubleToLongBits(this.yaw) ^ Double.doubleToLongBits(this.yaw) >>> 32);
return hash;
}
@Override
public Vector3 toVector() {
return vector.clone();
}
@Override
public String toString() {
return "[" + world + ": (" + getX() + ", " + getY() + ", " + getZ() + ")]";
}
@Override
public LocationImpl multiply(double v) {
vector.multiply(v);
return this;
}
}

View File

@@ -1,10 +1,8 @@
package com.dfsek.terra.vector;
import com.dfsek.terra.api.util.MathUtil;
import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.api.vector.Vector2;
import com.dfsek.terra.api.vector.Vector3;
import com.dfsek.terra.api.world.World;
import net.jafama.FastMath;
import org.jetbrains.annotations.NotNull;
@@ -207,11 +205,6 @@ public class Vector3Impl implements Vector3 {
return x * other.getX() + y * other.getY() + z * other.getZ();
}
@Override
public Location toLocation(World world) {
return new LocationImpl(world, this.clone());
}
@Override
public Vector3 normalize() {
return this.multiply(this.inverseLength());

View File

@@ -4,7 +4,6 @@ import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.block.BlockData;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.event.events.world.TerraWorldLoadEvent;
import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.api.vector.Vector3;
import com.dfsek.terra.api.world.TerraWorld;
import com.dfsek.terra.api.world.World;
@@ -76,11 +75,6 @@ public class TerraWorldImpl implements TerraWorld {
} else return air;
}
@Override
public BlockData getUngeneratedBlock(Location l) {
return getUngeneratedBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ());
}
@Override
public BlockData getUngeneratedBlock(Vector3 v) {
return getUngeneratedBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());