mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-10 01:36:19 +00:00
Location is gone.
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
package com.dfsek.terra.api.vector;
|
||||
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public interface Location extends Cloneable {
|
||||
void setWorld(World world);
|
||||
|
||||
Vector3 getVector();
|
||||
|
||||
void setVector(Vector3 vector);
|
||||
|
||||
Location clone();
|
||||
|
||||
int getBlockX();
|
||||
|
||||
int getBlockY();
|
||||
|
||||
int getBlockZ();
|
||||
|
||||
double getY();
|
||||
|
||||
Location setY(double y);
|
||||
|
||||
double getX();
|
||||
|
||||
Location setX(double x);
|
||||
|
||||
double getZ();
|
||||
|
||||
Location setZ(double z);
|
||||
|
||||
World getWorld();
|
||||
|
||||
Location add(double x, double y, double z);
|
||||
|
||||
Location subtract(int x, int y, int z);
|
||||
|
||||
Location add(Vector3 add);
|
||||
|
||||
Location add(Location add);
|
||||
|
||||
double getPitch();
|
||||
|
||||
void setPitch(double pitch);
|
||||
|
||||
double getYaw();
|
||||
|
||||
void setYaw(double yaw);
|
||||
|
||||
Vector3 toVector();
|
||||
|
||||
Location multiply(double v);
|
||||
}
|
||||
@@ -155,8 +155,6 @@ public interface Vector3 extends Cloneable {
|
||||
*/
|
||||
double dot(@NotNull Vector3 other);
|
||||
|
||||
Location toLocation(World world);
|
||||
|
||||
Vector3 normalize();
|
||||
|
||||
Vector3 subtract(int x, int y, int z);
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
|
||||
@@ -25,7 +24,5 @@ public interface TerraWorld {
|
||||
*/
|
||||
BlockData getUngeneratedBlock(int x, int y, int z);
|
||||
|
||||
BlockData getUngeneratedBlock(Location l);
|
||||
|
||||
BlockData getUngeneratedBlock(Vector3 v);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.dfsek.terra.bukkit.world.block.BukkitBlockTypeAndItem;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockData;
|
||||
import com.dfsek.terra.bukkit.world.inventory.BukkitItemStack;
|
||||
import com.dfsek.terra.bukkit.world.inventory.meta.BukkitEnchantment;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -338,12 +337,8 @@ public final class BukkitAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public static Location adapt(com.dfsek.terra.api.vector.Location location) {
|
||||
return new Location(((BukkitWorld) location.getWorld()).getHandle(), location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public static LocationImpl adapt(Location location) {
|
||||
return new LocationImpl(adapt(location.getWorld()), location.getX(), location.getY(), location.getZ());
|
||||
public static Vector3 adapt(Location location) {
|
||||
return new Vector3Impl(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public static Vector adapt(Vector3 vector3) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.lang.Language;
|
||||
import com.dfsek.terra.api.profiler.Profiler;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.LockedRegistry;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.util.logging.DebugLogger;
|
||||
import com.dfsek.terra.api.util.logging.JavaLogger;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
@@ -26,6 +26,8 @@ import com.dfsek.terra.config.lang.LanguageImpl;
|
||||
import com.dfsek.terra.platform.RawBiome;
|
||||
import com.dfsek.terra.platform.RawWorldHandle;
|
||||
import com.dfsek.terra.profiler.ProfilerImpl;
|
||||
import com.dfsek.terra.registry.CheckedRegistryImpl;
|
||||
import com.dfsek.terra.registry.LockedRegistryImpl;
|
||||
import com.dfsek.terra.registry.master.AddonRegistry;
|
||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||
import com.dfsek.terra.world.TerraWorldImpl;
|
||||
@@ -38,7 +40,7 @@ public class StandalonePlugin implements TerraPlugin {
|
||||
private final ConfigRegistry registry = new ConfigRegistry();
|
||||
private final AddonRegistry addonRegistry = new AddonRegistry(this);
|
||||
|
||||
private final LockedRegistry<TerraAddon> addonLockedRegistry = new LockedRegistry<>(addonRegistry);
|
||||
private final Registry<TerraAddon> addonLockedRegistry = new LockedRegistryImpl<>(addonRegistry);
|
||||
|
||||
private final PluginConfig config = new PluginConfigImpl();
|
||||
private final RawWorldHandle worldHandle = new RawWorldHandle();
|
||||
@@ -82,11 +84,11 @@ public class StandalonePlugin implements TerraPlugin {
|
||||
|
||||
@Override
|
||||
public CheckedRegistry<ConfigPack> getConfigRegistry() {
|
||||
return new CheckedRegistry<>(registry);
|
||||
return new CheckedRegistryImpl<>(registry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LockedRegistry<TerraAddon> getAddons() {
|
||||
public Registry<TerraAddon> getAddons() {
|
||||
return addonLockedRegistry;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
public class DirectBlock implements Block {
|
||||
private final DirectWorld world;
|
||||
private final Vector3 pos;
|
||||
|
||||
public DirectBlock(DirectWorld world, Vector3 pos) {
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(BlockData data, boolean physics) {
|
||||
synchronized(world) {
|
||||
world.compute(FastMath.floorDiv(pos.getBlockX(), 16), FastMath.floorDiv(pos.getBlockZ(), 16)).setBlockStateAt(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), ((Data) data).getHandle(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
return new Data(world.getData(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getState() {
|
||||
return new DirectBlockState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getRelative(BlockFace face) {
|
||||
return world.getBlockAt(pos.getBlockX() + face.getModX(), pos.getBlockY() + face.getModY(), pos.getBlockZ() + face.getModZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getRelative(BlockFace face, int len) {
|
||||
return world.getBlockAt(pos.getBlockX() + face.getModX() * len, pos.getBlockY() + face.getModY() * len, pos.getBlockZ() + face.getModZ() * len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return getBlockData().getAsString().equals("minecraft:air");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocationImpl getLocation() {
|
||||
return pos.toLocation(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getType() {
|
||||
return new Data(world.getData(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return pos.getBlockX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return pos.getBlockY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return pos.getBlockY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getHandle() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
public class DirectBlockState implements BlockState {
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
public Vector3 getPosition() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import net.querz.mca.Chunk;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -44,6 +42,11 @@ public class DirectChunkData implements ChunkData, com.dfsek.terra.api.world.Chu
|
||||
return new Data(tag.getString("Name"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, BlockData data, boolean physics) {
|
||||
setBlock(x, y, z, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
@@ -59,8 +62,4 @@ public class DirectChunkData implements ChunkData, com.dfsek.terra.api.world.Chu
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
return new DirectBlock(world, new Vector3Impl(x + (this.x << 4), y, z + (this.z << 4)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.DirectUtils;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import net.jafama.FastMath;
|
||||
import net.querz.mca.MCAFile;
|
||||
import net.querz.mca.MCAUtil;
|
||||
@@ -57,12 +57,22 @@ public class DirectWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlockAt(int x, int y, int z) {
|
||||
return new DirectBlock(this, new Vector3Impl(x, y, z));
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(LocationImpl location, EntityType entityType) {
|
||||
public void setBlockData(int x, int y, int z, BlockData data, boolean physics) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Vector3 location, EntityType entityType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.dfsek.terra.region;
|
||||
|
||||
public class RegionWriter {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user