mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-22 08:10:40 +00:00
location garbage
This commit is contained in:
@@ -8,6 +8,7 @@ import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.profiler.Profiler;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.terra.api.LoaderRegistrar;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
public interface ConfigPack extends LoaderRegistrar {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface WorldConfig {
|
||||
@SuppressWarnings("unchecked")
|
||||
<T> Registry<T> getRegistry(Class<T> clazz);
|
||||
|
||||
TerraWorld getWorld();
|
||||
|
||||
SamplerCache getSamplerCache();
|
||||
|
||||
Set<UserDefinedCarver> getCarvers();
|
||||
|
||||
BiomeProvider getProvider();
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.dfsek.terra.api.event.events.world;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.api.handle;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
|
||||
/**
|
||||
* Interface to be implemented for world manipulation.
|
||||
|
||||
@@ -3,177 +3,55 @@ package com.dfsek.terra.api.vector;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Deprecated
|
||||
public class Location implements Cloneable {
|
||||
private World world;
|
||||
private Vector3 vector;
|
||||
private double pitch;
|
||||
private double yaw;
|
||||
public interface Location extends Cloneable {
|
||||
void setWorld(World world);
|
||||
|
||||
public Location(World w, double x, double y, double z) {
|
||||
this.world = w;
|
||||
this.vector = new Vector3Impl(x, y, z);
|
||||
}
|
||||
Vector3 getVector();
|
||||
|
||||
public Location(World w, Vector3 vector) {
|
||||
this.world = w;
|
||||
this.vector = vector;
|
||||
}
|
||||
void setVector(Vector3 vector);
|
||||
|
||||
public void setWorld(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
Location clone();
|
||||
|
||||
public Vector3 getVector() {
|
||||
return vector;
|
||||
}
|
||||
int getBlockX();
|
||||
|
||||
public void setVector(Vector3 vector) {
|
||||
this.vector = vector;
|
||||
}
|
||||
int getBlockY();
|
||||
|
||||
@Override
|
||||
public Location clone() {
|
||||
try {
|
||||
Location other = (Location) super.clone();
|
||||
other.setVector(other.getVector().clone());
|
||||
return other;
|
||||
} catch(CloneNotSupportedException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
int getBlockZ();
|
||||
|
||||
public int getBlockX() {
|
||||
return vector.getBlockX();
|
||||
}
|
||||
double getY();
|
||||
|
||||
public int getBlockY() {
|
||||
return vector.getBlockY();
|
||||
}
|
||||
Location setY(double y);
|
||||
|
||||
public int getBlockZ() {
|
||||
return vector.getBlockZ();
|
||||
}
|
||||
double getX();
|
||||
|
||||
public double getY() {
|
||||
return vector.getY();
|
||||
}
|
||||
Location setX(double x);
|
||||
|
||||
public Location setY(double y) {
|
||||
vector.setY(y);
|
||||
return this;
|
||||
}
|
||||
double getZ();
|
||||
|
||||
public double getX() {
|
||||
return vector.getX();
|
||||
}
|
||||
Location setZ(double z);
|
||||
|
||||
public Location setX(double x) {
|
||||
vector.setX(x);
|
||||
return this;
|
||||
}
|
||||
World getWorld();
|
||||
|
||||
public double getZ() {
|
||||
return vector.getZ();
|
||||
}
|
||||
Location add(double x, double y, double z);
|
||||
|
||||
public Location setZ(double z) {
|
||||
vector.setZ(z);
|
||||
return this;
|
||||
}
|
||||
Block getBlock();
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
Location subtract(int x, int y, int z);
|
||||
|
||||
public Location add(double x, double y, double z) {
|
||||
vector.add(x, y, z);
|
||||
return this;
|
||||
}
|
||||
Location add(Vector3 add);
|
||||
|
||||
public Block getBlock() {
|
||||
return world.getBlockAt(this);
|
||||
}
|
||||
Location add(Location add);
|
||||
|
||||
public Location subtract(int x, int y, int z) {
|
||||
vector.subtract(x, y, z);
|
||||
return this;
|
||||
}
|
||||
double getPitch();
|
||||
|
||||
public Location add(Vector3 add) {
|
||||
vector.add(add);
|
||||
return this;
|
||||
}
|
||||
void setPitch(double pitch);
|
||||
|
||||
public Location add(Location add) {
|
||||
vector.add(add.toVector());
|
||||
return this;
|
||||
}
|
||||
double getYaw();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Location)) {
|
||||
return false;
|
||||
}
|
||||
final Location other = (Location) obj;
|
||||
void setYaw(double yaw);
|
||||
|
||||
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());
|
||||
}
|
||||
Vector3 toVector();
|
||||
|
||||
public double getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public void setPitch(double pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public double getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Vector3 toVector() {
|
||||
return vector.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + world + ": (" + getX() + ", " + getY() + ", " + getZ() + ")]";
|
||||
}
|
||||
|
||||
public Location multiply(double v) {
|
||||
vector.multiply(v);
|
||||
return this;
|
||||
}
|
||||
Location multiply(double v);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
public interface TerraWorld {
|
||||
World getWorld();
|
||||
|
||||
BiomeProvider getBiomeProvider();
|
||||
|
||||
WorldConfig getConfig();
|
||||
|
||||
boolean isSafe();
|
||||
|
||||
/**
|
||||
* Get a block at an ungenerated location
|
||||
*
|
||||
* @param x X coordinate
|
||||
* @param y Y coordinate
|
||||
* @param z Z coordinate
|
||||
* @return BlockData
|
||||
*/
|
||||
BlockData getUngeneratedBlock(int x, int y, int z);
|
||||
|
||||
BlockData getUngeneratedBlock(Location l);
|
||||
|
||||
BlockData getUngeneratedBlock(Vector3 v);
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.LocationImpl;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public interface Tree {
|
||||
boolean plant(Location l, Random r);
|
||||
boolean plant(LocationImpl l, Random r);
|
||||
|
||||
MaterialSet getSpawnable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user