mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-18 22:30:00 +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();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.script;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structures.loot.LootTable;
|
||||
@@ -47,7 +47,7 @@ import java.util.concurrent.ExecutionException;
|
||||
public class StructureScript {
|
||||
private final Block block;
|
||||
private final String id;
|
||||
private final Cache<Location, StructureBuffer> cache;
|
||||
private final Cache<LocationImpl, StructureBuffer> cache;
|
||||
private final TerraPlugin main;
|
||||
private String tempID;
|
||||
|
||||
@@ -118,7 +118,7 @@ public class StructureScript {
|
||||
* @return Whether generation was successful
|
||||
*/
|
||||
@SuppressWarnings("try")
|
||||
public boolean execute(Location location, Random random, Rotation rotation) {
|
||||
public boolean execute(LocationImpl location, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript:" + id)) {
|
||||
StructureBuffer buffer = new StructureBuffer(location);
|
||||
boolean level = applyBlock(new TerraImplementationArguments(buffer, rotation, random, 0));
|
||||
@@ -128,7 +128,7 @@ public class StructureScript {
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
public boolean execute(Location location, Chunk chunk, Random random, Rotation rotation) {
|
||||
public boolean execute(LocationImpl location, Chunk chunk, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_chunk:" + id)) {
|
||||
StructureBuffer buffer = computeBuffer(location, random, rotation);
|
||||
buffer.paste(chunk);
|
||||
@@ -137,14 +137,14 @@ public class StructureScript {
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
public boolean test(Location location, Random random, Rotation rotation) {
|
||||
public boolean test(LocationImpl location, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_test:" + id)) {
|
||||
StructureBuffer buffer = computeBuffer(location, random, rotation);
|
||||
return buffer.succeeded();
|
||||
}
|
||||
}
|
||||
|
||||
private StructureBuffer computeBuffer(Location location, Random random, Rotation rotation) {
|
||||
private StructureBuffer computeBuffer(LocationImpl location, Random random, Rotation rotation) {
|
||||
try {
|
||||
return cache.get(location, () -> {
|
||||
StructureBuffer buf = new StructureBuffer(location);
|
||||
@@ -164,7 +164,7 @@ public class StructureScript {
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
public boolean executeDirect(Location location, Random random, Rotation rotation) {
|
||||
public boolean executeDirect(LocationImpl location, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_direct:" + id)) {
|
||||
DirectBuffer buffer = new DirectBuffer(location);
|
||||
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, 0));
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.api.structures.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.vector.Vector2Impl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -16,7 +17,6 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.generation.math.SamplerCache;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
@@ -47,12 +47,12 @@ public class CheckFunction implements Function<String> {
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
Location location = arguments.getBuffer().getOrigin().clone().add(new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())));
|
||||
LocationImpl location = arguments.getBuffer().getOrigin().clone().add(new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())));
|
||||
|
||||
return apply(location, arguments.getBuffer().getOrigin().getWorld());
|
||||
}
|
||||
|
||||
private String apply(Location vector, World world) {
|
||||
private String apply(LocationImpl vector, World world) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
SamplerCache cache = tw.getConfig().getSamplerCache();
|
||||
double comp = sample(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), cache);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Cell implements BufferedItem {
|
||||
|
||||
|
||||
@Override
|
||||
public void paste(Location origin) {
|
||||
public void paste(LocationImpl origin) {
|
||||
items.forEach(item -> item.paste(origin));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -11,31 +11,31 @@ import java.util.Map;
|
||||
* Buffer implementation that directly pastes to the world.
|
||||
*/
|
||||
public class DirectBuffer implements Buffer {
|
||||
private final Location origin;
|
||||
private final Map<Location, String> marks = new LinkedHashMap<>();
|
||||
private final LocationImpl origin;
|
||||
private final Map<LocationImpl, String> marks = new LinkedHashMap<>();
|
||||
|
||||
public DirectBuffer(Location origin) {
|
||||
public DirectBuffer(LocationImpl origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer addItem(BufferedItem item, Location location) {
|
||||
public Buffer addItem(BufferedItem item, LocationImpl location) {
|
||||
item.paste(origin.clone().add(location));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getOrigin() {
|
||||
public LocationImpl getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark(Location location) {
|
||||
public String getMark(LocationImpl location) {
|
||||
return marks.get(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer setMark(String mark, Location location) {
|
||||
public Buffer setMark(String mark, LocationImpl location) {
|
||||
marks.put(location, mark);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
|
||||
@@ -15,22 +15,22 @@ public class IntermediateBuffer implements Buffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer addItem(BufferedItem item, Location location) {
|
||||
public Buffer addItem(BufferedItem item, LocationImpl location) {
|
||||
return original.addItem(item, location.add(offset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getOrigin() {
|
||||
public LocationImpl getOrigin() {
|
||||
return original.getOrigin().clone().add(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark(Location location) {
|
||||
public String getMark(LocationImpl location) {
|
||||
return original.getMark(location.add(offset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer setMark(String mark, Location location) {
|
||||
public Buffer setMark(String mark, LocationImpl location) {
|
||||
original.setMark(mark, location.add(offset));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import net.jafama.FastMath;
|
||||
@@ -10,11 +10,11 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StructureBuffer implements Buffer {
|
||||
private final Map<Location, Cell> bufferedItemMap = new LinkedHashMap<>();
|
||||
private final Location origin;
|
||||
private final Map<LocationImpl, Cell> bufferedItemMap = new LinkedHashMap<>();
|
||||
private final LocationImpl origin;
|
||||
private boolean succeeded;
|
||||
|
||||
public StructureBuffer(Location origin) {
|
||||
public StructureBuffer(LocationImpl origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class StructureBuffer implements Buffer {
|
||||
|
||||
public void paste(Chunk chunk) {
|
||||
bufferedItemMap.forEach(((location, item) -> {
|
||||
Location current = origin.clone().add(location);
|
||||
LocationImpl current = origin.clone().add(location);
|
||||
if(FastMath.floorDiv(current.getBlockX(), 16) != chunk.getX() || FastMath.floorDiv(current.getBlockZ(), 16) != chunk.getZ())
|
||||
return;
|
||||
item.paste(chunk, current);
|
||||
@@ -32,13 +32,13 @@ public class StructureBuffer implements Buffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer addItem(BufferedItem item, Location location) {
|
||||
public Buffer addItem(BufferedItem item, LocationImpl location) {
|
||||
bufferedItemMap.computeIfAbsent(location, l -> new Cell()).add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMark(Location location) {
|
||||
public String getMark(LocationImpl location) {
|
||||
Cell cell = bufferedItemMap.get(location);
|
||||
if(cell != null) {
|
||||
return cell.getMark();
|
||||
@@ -47,7 +47,7 @@ public class StructureBuffer implements Buffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buffer setMark(String mark, Location location) {
|
||||
public Buffer setMark(String mark, LocationImpl location) {
|
||||
bufferedItemMap.computeIfAbsent(location, l -> new Cell()).setMark(mark);
|
||||
return this;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class StructureBuffer implements Buffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getOrigin() {
|
||||
public LocationImpl getOrigin() {
|
||||
return origin.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.data.Waterlogged;
|
||||
@@ -21,7 +21,7 @@ public class BufferedBlock implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Location origin) {
|
||||
public void paste(LocationImpl origin) {
|
||||
Block block = origin.getBlock();
|
||||
try {
|
||||
if(overwrite || block.isEmpty()) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class BufferedEntity implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Location origin) {
|
||||
public void paste(LocationImpl origin) {
|
||||
Entity entity = origin.clone().add(0.5, 0, 0.5).getWorld().spawnEntity(origin, type);
|
||||
main.getEventManager().callEvent(new EntitySpawnEvent(entity.getWorld().getTerraGenerator().getConfigPack(), entity, entity.getLocation()));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.Container;
|
||||
@@ -23,7 +23,7 @@ public class BufferedLootApplication implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Location origin) {
|
||||
public void paste(LocationImpl origin) {
|
||||
try {
|
||||
Block block = origin.getBlock();
|
||||
BlockState data = block.getState();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
@@ -14,7 +14,7 @@ public class BufferedPulledBlock implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Location origin) {
|
||||
public void paste(LocationImpl origin) {
|
||||
Block pos = origin.getBlock();
|
||||
while(pos.getY() > origin.getWorld().getMinHeight()) {
|
||||
if(!pos.isEmpty()) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
|
||||
public class BufferedStateManipulator implements BufferedItem {
|
||||
@@ -15,7 +15,7 @@ public class BufferedStateManipulator implements BufferedItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Location origin) {
|
||||
public void paste(LocationImpl origin) {
|
||||
try {
|
||||
BlockState state = origin.getBlock().getState();
|
||||
state.applyState(data);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.world.locate;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@@ -14,7 +14,7 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
public class AsyncBiomeFinder extends AsyncFeatureFinder<TerraBiome> {
|
||||
|
||||
public AsyncBiomeFinder(BiomeProvider provider, TerraBiome target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
|
||||
public AsyncBiomeFinder(BiomeProvider provider, TerraBiome target, @NotNull LocationImpl origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
|
||||
super(provider, target, origin, startRadius, maxRadius, callback, main);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.world.locate;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -22,7 +22,7 @@ public abstract class AsyncFeatureFinder<T> implements Runnable {
|
||||
protected int searchSize = 1;
|
||||
protected final TerraPlugin main;
|
||||
|
||||
public AsyncFeatureFinder(BiomeProvider provider, T target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
|
||||
public AsyncFeatureFinder(BiomeProvider provider, T target, @NotNull LocationImpl origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
|
||||
this.provider = provider;
|
||||
this.target = target;
|
||||
this.main = main;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.api.world.locate;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
@@ -16,7 +16,7 @@ import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
|
||||
public AsyncStructureFinder(BiomeProvider provider, TerraStructure target, @NotNull Location origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
|
||||
public AsyncStructureFinder(BiomeProvider provider, TerraStructure target, @NotNull LocationImpl origin, int startRadius, int maxRadius, Consumer<Vector3> callback, TerraPlugin main) {
|
||||
super(provider, target, origin, startRadius, maxRadius, callback, main);
|
||||
setSearchSize(target.getSpawn().getWidth() + 2 * target.getSpawn().getSeparation());
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class AsyncStructureFinder extends AsyncFeatureFinder<TerraStructure> {
|
||||
|
||||
@Override
|
||||
public boolean isValid(int x, int z, TerraStructure target) {
|
||||
Location spawn = target.getSpawn().getChunkSpawn(x, z, world.getSeed()).toLocation(world);
|
||||
LocationImpl spawn = target.getSpawn().getChunkSpawn(x, z, world.getSeed()).toLocation(world);
|
||||
if(!((UserDefinedBiome) provider.getBiome(spawn)).getConfig().getStructures().contains(target)) return false;
|
||||
Random random = new FastRandom(MathUtil.getCarverChunkSeed(FastMath.floorDiv(spawn.getBlockX(), 16), FastMath.floorDiv(spawn.getBlockZ(), 16), world.getSeed()));
|
||||
return target.getStructure().get(random).test(spawn.setY(target.getSpawnStart().get(random)), random, Rotation.fromDegrees(90 * random.nextInt(4)));
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
|
||||
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
|
||||
import com.dfsek.terra.api.command.arg.IntegerArgumentParser;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -69,7 +69,7 @@ public class BiomeLocateCommand implements CommandTemplate {
|
||||
if(location != null) {
|
||||
sender.sendMessage(String.format("The nearest %s is at [%d, ~, %d] (%.1f blocks away)", biome.getID().toLowerCase(Locale.ROOT), location.getBlockX(), location.getBlockZ(), location.add(new Vector3Impl(0, player.getLocation().getY(), 0)).distance(player.getLocation().toVector())));
|
||||
if(teleport) {
|
||||
main.runPossiblyUnsafeTask(() -> player.setLocation(new Location(player.getWorld(), location.getX(), player.getLocation().getY(), location.getZ())));
|
||||
main.runPossiblyUnsafeTask(() -> player.setLocation(new LocationImpl(player.getWorld(), location.getX(), player.getLocation().getY(), location.getZ())));
|
||||
}
|
||||
} else LangUtil.send("command.biome.unable-to-locate", sender);
|
||||
}, main), "Biome Location Thread").start();
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.terra.api.command.annotation.type.DebugCommand;
|
||||
import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
|
||||
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.structures.parser.lang.constants.NumericConstant;
|
||||
@@ -33,14 +33,14 @@ public class SpawnCommand implements CommandTemplate {
|
||||
@Override
|
||||
public void execute(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
Location p = player.getLocation();
|
||||
LocationImpl p = player.getLocation();
|
||||
int x = p.getBlockX();
|
||||
int y = p.getBlockY();
|
||||
int z = p.getBlockZ();
|
||||
Position dummy = new Position(0, 0);
|
||||
|
||||
String check = new CheckFunction(main, new NumericConstant(0, dummy), new NumericConstant(0, dummy), new NumericConstant(0, dummy), dummy).apply(new TerraImplementationArguments(new StructureBuffer(
|
||||
new Location(player.getWorld(), x, y, z)
|
||||
new LocationImpl(player.getWorld(), x, y, z)
|
||||
), Rotation.NONE, new FastRandom(), 0), new HashMap<>());
|
||||
|
||||
sender.sendMessage("Found: " + check);
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.dfsek.terra.api.command.annotation.type.DebugCommand;
|
||||
import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
|
||||
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
@@ -45,10 +45,10 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
public void execute(CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
Pair<Location, Location> l = main.getWorldHandle().getSelectedLocation(player);
|
||||
Pair<LocationImpl, LocationImpl> l = main.getWorldHandle().getSelectedLocation(player);
|
||||
|
||||
Location l1 = l.getLeft();
|
||||
Location l2 = l.getRight();
|
||||
LocationImpl l1 = l.getLeft();
|
||||
LocationImpl l2 = l.getRight();
|
||||
|
||||
StringBuilder scriptBuilder = new StringBuilder("id \"" + id + "\";\nnum y = 0;\n");
|
||||
|
||||
@@ -59,7 +59,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
for(int x = l1.getBlockX(); x <= l2.getBlockX(); x++) {
|
||||
for(int y = l1.getBlockY(); y <= l2.getBlockY(); y++) {
|
||||
for(int z = l1.getBlockZ(); z <= l2.getBlockZ(); z++) {
|
||||
Block block = new Location(l1.getWorld(), x, y, z).getBlock();
|
||||
Block block = new LocationImpl(l1.getWorld(), x, y, z).getBlock();
|
||||
BlockState state = block.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
@@ -77,7 +77,7 @@ public class StructureExportCommand implements CommandTemplate {
|
||||
for(int y = l1.getBlockY(); y <= l2.getBlockY(); y++) {
|
||||
for(int z = l1.getBlockZ(); z <= l2.getBlockZ(); z++) {
|
||||
|
||||
Block block = new Location(l1.getWorld(), x, y, z).getBlock();
|
||||
Block block = new LocationImpl(l1.getWorld(), x, y, z).getBlock();
|
||||
BlockData data = block.getBlockData();
|
||||
if(block.getBlockData().isStructureVoid()) continue;
|
||||
BlockState state = block.getState();
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
|
||||
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
|
||||
import com.dfsek.terra.api.command.arg.IntegerArgumentParser;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -67,7 +67,7 @@ public class StructureLocateCommand implements CommandTemplate {
|
||||
if(location != null) {
|
||||
sender.sendMessage(String.format("The nearest %s is at [%d, ~, %d] (%.1f blocks away)", structure.getTemplate().getID().toLowerCase(Locale.ROOT), location.getBlockX(), location.getBlockZ(), location.add(new Vector3Impl(0, player.getLocation().getY(), 0)).distance(player.getLocation().toVector())));
|
||||
if(teleport) {
|
||||
main.runPossiblyUnsafeTask(() -> player.setLocation(new Location(player.getWorld(), location.getX(), player.getLocation().getY(), location.getZ())));
|
||||
main.runPossiblyUnsafeTask(() -> player.setLocation(new LocationImpl(player.getWorld(), location.getX(), player.getLocation().getY(), location.getZ())));
|
||||
}
|
||||
} else LangUtil.send("command.biome.unable-to-locate", sender);
|
||||
}, main), "Biome Location Thread").start();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.config.dummy;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -41,7 +41,7 @@ public class DummyWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
public Entity spawnEntity(LocationImpl location, EntityType entityType) {
|
||||
throw new UnsupportedOperationException("Cannot spawn entity in DummyWorld");
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.dfsek.terra.api.structures.script.StructureScript;
|
||||
import com.dfsek.terra.api.util.generic.pair.ImmutablePair;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseProvider;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.config.builder.BiomeBuilder;
|
||||
import com.dfsek.terra.config.dummy.DummyWorld;
|
||||
@@ -40,7 +41,7 @@ import com.dfsek.terra.registry.config.FunctionRegistry;
|
||||
import com.dfsek.terra.registry.config.LootRegistry;
|
||||
import com.dfsek.terra.registry.config.NoiseRegistry;
|
||||
import com.dfsek.terra.registry.config.ScriptRegistry;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.TerraWorldImpl;
|
||||
import com.dfsek.terra.world.population.items.TerraStructure;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.json.simple.parser.ParseException;
|
||||
@@ -123,7 +124,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
main.logger().severe("Failed to load config pack from folder \"" + folder.getAbsolutePath() + "\"");
|
||||
throw e;
|
||||
}
|
||||
toWorldConfig(new TerraWorld(new DummyWorld(), this, main)); // Build now to catch any errors immediately.
|
||||
toWorldConfig(new TerraWorldImpl(new DummyWorld(), this, main)); // Build now to catch any errors immediately.
|
||||
}
|
||||
|
||||
public ConfigPackImpl(ZipFile file, TerraPlugin main) throws ConfigException {
|
||||
@@ -171,7 +172,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
throw e;
|
||||
}
|
||||
|
||||
toWorldConfig(new TerraWorld(new DummyWorld(), this, main)); // Build now to catch any errors immediately.
|
||||
toWorldConfig(new TerraWorldImpl(new DummyWorld(), this, main)); // Build now to catch any errors immediately.
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@@ -298,8 +299,8 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
|
||||
|
||||
@Override
|
||||
public WorldConfig toWorldConfig(TerraWorld world) {
|
||||
return new WorldConfig(world, this, main);
|
||||
public WorldConfigImpl toWorldConfig(TerraWorld world) {
|
||||
return new WorldConfigImpl(world, this, main);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.dfsek.terra.config.pack;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.registry.LockedRegistry;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.builder.BiomeBuilder;
|
||||
import com.dfsek.terra.registry.OpenRegistry;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.registry.LockedRegistryImpl;
|
||||
import com.dfsek.terra.registry.OpenRegistryImpl;
|
||||
import com.dfsek.terra.world.generation.math.SamplerCache;
|
||||
import com.dfsek.terra.world.population.items.TerraStructure;
|
||||
|
||||
@@ -16,7 +18,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class WorldConfig {
|
||||
public class WorldConfigImpl implements com.dfsek.terra.api.config.WorldConfig {
|
||||
private final SamplerCache samplerCache;
|
||||
|
||||
private final BiomeProvider provider;
|
||||
@@ -24,39 +26,44 @@ public class WorldConfig {
|
||||
private final TerraWorld world;
|
||||
private final ConfigPackImpl pack;
|
||||
|
||||
private final Map<Class<?>, LockedRegistry<?>> registryMap = new HashMap<>();
|
||||
private final Map<Class<?>, Registry<?>> registryMap = new HashMap<>();
|
||||
|
||||
public WorldConfig(TerraWorld world, ConfigPackImpl pack, TerraPlugin main) {
|
||||
public WorldConfigImpl(TerraWorld world, ConfigPackImpl pack, TerraPlugin main) {
|
||||
this.world = world;
|
||||
this.pack = pack;
|
||||
this.samplerCache = new SamplerCache(main, world);
|
||||
|
||||
pack.getRegistryMap().forEach((clazz, pair) -> registryMap.put(clazz, new LockedRegistry<>(pair.getLeft())));
|
||||
pack.getRegistryMap().forEach((clazz, pair) -> registryMap.put(clazz, new LockedRegistryImpl<>(pair.getLeft())));
|
||||
|
||||
OpenRegistry<TerraBiome> biomeOpenRegistry = new OpenRegistry<>();
|
||||
OpenRegistry<TerraBiome> biomeOpenRegistry = new OpenRegistryImpl<>();
|
||||
pack.getRegistry(BiomeBuilder.class).forEach((id, biome) -> biomeOpenRegistry.add(id, biome.apply(world.getWorld().getSeed())));
|
||||
registryMap.put(TerraBiome.class, new LockedRegistry<>(biomeOpenRegistry));
|
||||
registryMap.put(TerraBiome.class, new LockedRegistryImpl<>(biomeOpenRegistry));
|
||||
|
||||
this.provider = pack.getBiomeProviderBuilder().build(world.getWorld().getSeed());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> LockedRegistry<T> getRegistry(Class<T> clazz) {
|
||||
return (LockedRegistry<T>) registryMap.get(clazz);
|
||||
public <T> Registry<T> getRegistry(Class<T> clazz) {
|
||||
return (LockedRegistryImpl<T>) registryMap.get(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SamplerCache getSamplerCache() {
|
||||
return samplerCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UserDefinedCarver> getCarvers() {
|
||||
return new HashSet<>(getRegistry(UserDefinedCarver.class).entries());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.dfsek.terra.vector;
|
||||
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
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;
|
||||
|
||||
@Deprecated
|
||||
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 Block getBlock() {
|
||||
return world.getBlockAt(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;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.dfsek.terra.vector;
|
||||
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import net.jafama.FastMath;
|
||||
@@ -208,8 +207,8 @@ public class Vector3Impl implements Vector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location toLocation(World world) {
|
||||
return new Location(world, this.clone());
|
||||
public LocationImpl toLocation(World world) {
|
||||
return new LocationImpl(world, this.clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.world;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.event.events.world.TerraWorldLoadEvent;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -10,19 +10,19 @@ import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
import com.dfsek.terra.config.pack.ConfigPackImpl;
|
||||
import com.dfsek.terra.config.pack.WorldConfig;
|
||||
import com.dfsek.terra.config.pack.WorldConfigImpl;
|
||||
import com.dfsek.terra.api.world.generator.Sampler;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
public class TerraWorld {
|
||||
public class TerraWorldImpl implements com.dfsek.terra.api.world.TerraWorld {
|
||||
private final BiomeProvider provider;
|
||||
private final WorldConfig config;
|
||||
private final WorldConfigImpl config;
|
||||
private final boolean safe;
|
||||
private final World world;
|
||||
private final BlockData air;
|
||||
|
||||
|
||||
public TerraWorld(World w, ConfigPackImpl c, TerraPlugin main) {
|
||||
public TerraWorldImpl(World w, ConfigPackImpl c, TerraPlugin main) {
|
||||
if(!w.isTerraWorld()) throw new IllegalArgumentException("World " + w + " is not a Terra World!");
|
||||
this.world = w;
|
||||
config = c.toWorldConfig(this);
|
||||
@@ -33,32 +33,29 @@ public class TerraWorld {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
public WorldConfig getConfig() {
|
||||
@Override
|
||||
public WorldConfigImpl getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafe() {
|
||||
return safe;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a block at an ungenerated location
|
||||
*
|
||||
* @param x X coordinate
|
||||
* @param y Y coordinate
|
||||
* @param z Z coordinate
|
||||
* @return BlockData
|
||||
*/
|
||||
@Override
|
||||
public BlockData getUngeneratedBlock(int x, int y, int z) {
|
||||
UserDefinedBiome biome = (UserDefinedBiome) provider.getBiome(x, z);
|
||||
Palette palette = biome.getGenerator(world).getPalette(y);
|
||||
@@ -78,10 +75,12 @@ public class TerraWorld {
|
||||
} else return air;
|
||||
}
|
||||
|
||||
public BlockData getUngeneratedBlock(Location l) {
|
||||
@Override
|
||||
public BlockData getUngeneratedBlock(LocationImpl l) {
|
||||
return getUngeneratedBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getUngeneratedBlock(Vector3 v) {
|
||||
return getUngeneratedBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.math.range.ConstantRange;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.api.util.world.PaletteUtil;
|
||||
@@ -17,7 +18,6 @@ import com.dfsek.terra.config.pack.ConfigPackImpl;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.world.Carver;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.carving.NoiseCarver;
|
||||
import com.dfsek.terra.world.generation.math.SamplerCache;
|
||||
import com.dfsek.terra.api.world.generator.Sampler;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.world.generation.generators;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.math.range.ConstantRange;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
import com.dfsek.terra.config.pack.ConfigPackImpl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
@@ -26,7 +27,6 @@ import com.dfsek.terra.api.world.palette.PaletteImpl;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.world.Carver;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.carving.NoiseCarver;
|
||||
import com.dfsek.terra.api.world.generator.Sampler;
|
||||
import com.dfsek.terra.world.generation.math.samplers.Sampler3D;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.world.generation.math;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.generator.Sampler;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.dfsek.terra.world.population;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.util.world.PopulationUtil;
|
||||
import com.dfsek.terra.api.world.generator.Chunkified;
|
||||
import com.dfsek.terra.api.world.generator.TerraBlockPopulator;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.pack.WorldConfig;
|
||||
import com.dfsek.terra.config.pack.WorldConfigImpl;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -41,12 +41,12 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("carving")) {
|
||||
Random random = PopulationUtil.getRandom(chunk);
|
||||
if(!tw.isSafe()) return;
|
||||
WorldConfig config = tw.getConfig();
|
||||
WorldConfigImpl config = tw.getConfig();
|
||||
if(config.getTemplate().disableCarvers()) return;
|
||||
|
||||
for(UserDefinedCarver c : config.getCarvers()) {
|
||||
CarverTemplate template = c.getConfig();
|
||||
Map<Location, BlockData> shiftCandidate = new HashMap<>();
|
||||
Map<LocationImpl, BlockData> shiftCandidate = new HashMap<>();
|
||||
Set<Block> updateNeeded = new HashSet<>();
|
||||
c.carve(chunk.getX(), chunk.getZ(), world, (v, type) -> {
|
||||
try(ProfileFrame ignored = main.getProfiler().profile("carving:" + c.getConfig().getID())) {
|
||||
@@ -85,9 +85,9 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||
}
|
||||
}
|
||||
});
|
||||
for(Map.Entry<Location, BlockData> entry : shiftCandidate.entrySet()) {
|
||||
Location l = entry.getKey();
|
||||
Location mut = l.clone();
|
||||
for(Map.Entry<LocationImpl, BlockData> entry : shiftCandidate.entrySet()) {
|
||||
LocationImpl l = entry.getKey();
|
||||
LocationImpl mut = l.clone();
|
||||
BlockData orig = l.getBlock().getBlockData();
|
||||
do mut.subtract(0, 1, 0);
|
||||
while(mut.getY() > world.getMinHeight() && mut.getBlock().getBlockData().matches(orig));
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dfsek.terra.world.population;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.vector.Vector2Impl;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -10,7 +11,6 @@ import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.TerraBlockPopulator;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.population.items.flora.FloraLayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dfsek.terra.world.population;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -11,7 +12,6 @@ import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.world.generator.TerraBlockPopulator;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.dfsek.terra.world.population;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
@@ -11,9 +12,8 @@ import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.Chunkified;
|
||||
import com.dfsek.terra.api.world.generator.TerraBlockPopulator;
|
||||
import com.dfsek.terra.config.pack.WorldConfig;
|
||||
import com.dfsek.terra.config.pack.WorldConfigImpl;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.population.items.TerraStructure;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,9 +38,9 @@ public class StructurePopulator implements TerraBlockPopulator, Chunkified {
|
||||
int cz = (chunk.getZ() << 4);
|
||||
if(!tw.isSafe()) return;
|
||||
BiomeProvider provider = tw.getBiomeProvider();
|
||||
WorldConfig config = tw.getConfig();
|
||||
WorldConfigImpl config = tw.getConfig();
|
||||
for(TerraStructure conf : config.getStructures()) {
|
||||
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
||||
LocationImpl spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
||||
|
||||
if(!((UserDefinedBiome) provider.getBiome(spawn)).getConfig().getStructures().contains(conf))
|
||||
continue;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.world.population;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.vector.Vector2Impl;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
@@ -9,7 +10,6 @@ import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.TerraBlockPopulator;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.population.items.tree.TreeLayer;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.population.items.flora;
|
||||
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
@@ -37,7 +37,7 @@ public class BlockFlora implements Flora {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plant(Location location) {
|
||||
public boolean plant(LocationImpl location) {
|
||||
location.add(0, 1, 0).getBlock().setBlockData(data, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.world.population.items.flora;
|
||||
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
@@ -43,7 +43,7 @@ public class ConstantFlora implements Flora {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plant(Location l) {
|
||||
public boolean plant(LocationImpl l) {
|
||||
for(int i = 1; i < data.size() + 1; i++) {
|
||||
l.clone().add(0, i, 0).getBlock().setBlockData(data.get(i - 1), false);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,13 @@ package com.dfsek.terra.world.population.items.flora;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
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.data.Directional;
|
||||
import com.dfsek.terra.api.block.data.MultipleFacing;
|
||||
import com.dfsek.terra.api.block.data.Rotatable;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
@@ -93,7 +92,7 @@ public class TerraFlora implements Flora {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean plant(Location location) {
|
||||
public boolean plant(LocationImpl location) {
|
||||
boolean doRotation = testRotation.size() > 0;
|
||||
int size = floraPalette.getSize();
|
||||
int c = ceiling ? -1 : 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.world.population.items.tree;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.structures.script.StructureScript;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
@@ -21,7 +21,7 @@ public class TerraTree implements Tree {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean plant(Location location, Random random) {
|
||||
public synchronized boolean plant(LocationImpl location, Random random) {
|
||||
return structure.get(random).executeDirect(location.clone().add(0, yOffset, 0), random, Rotation.fromDegrees(90 * random.nextInt(4)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
@@ -18,12 +18,12 @@ public class BukkitEntity implements Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
public LocationImpl getLocation() {
|
||||
return BukkitAdapter.adapt(entity.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(Location location) {
|
||||
public void setLocation(LocationImpl location) {
|
||||
entity.teleport(BukkitAdapter.adapt(location));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
@@ -18,13 +18,13 @@ public class BukkitPlayer implements Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
public LocationImpl getLocation() {
|
||||
org.bukkit.Location bukkit = delegate.getLocation();
|
||||
return new Location(BukkitAdapter.adapt(bukkit.getWorld()), bukkit.getX(), bukkit.getY(), bukkit.getZ());
|
||||
return new LocationImpl(BukkitAdapter.adapt(bukkit.getWorld()), bukkit.getX(), bukkit.getY(), bukkit.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(Location location) {
|
||||
public void setLocation(LocationImpl location) {
|
||||
delegate.teleport(BukkitAdapter.adapt(location));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.dfsek.terra.api.event.EventManagerImpl;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
@@ -45,7 +46,7 @@ import com.dfsek.terra.api.profiler.Profiler;
|
||||
import com.dfsek.terra.profiler.ProfilerImpl;
|
||||
import com.dfsek.terra.registry.master.AddonRegistry;
|
||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.TerraWorldImpl;
|
||||
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
@@ -105,7 +106,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
worldMap.forEach((world, tw) -> {
|
||||
tw.getConfig().getSamplerCache().clear();
|
||||
String packID = tw.getConfig().getTemplate().getID();
|
||||
newMap.put(world, new TerraWorld(world, registry.get(packID), this));
|
||||
newMap.put(world, new TerraWorldImpl(world, registry.get(packID), this));
|
||||
});
|
||||
worldMap.clear();
|
||||
worldMap.putAll(newMap);
|
||||
@@ -272,9 +273,9 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
throw new IllegalArgumentException("Not a Terra world! " + w.getGenerator());
|
||||
if(!worlds.containsKey(w.getName())) {
|
||||
getLogger().warning("Unexpected world load detected: \"" + w.getName() + "\"");
|
||||
return new TerraWorld(w, ((TerraChunkGenerator) w.getGenerator().getHandle()).getConfigPack(), this);
|
||||
return new TerraWorldImpl(w, ((TerraChunkGenerator) w.getGenerator().getHandle()).getConfigPack(), this);
|
||||
}
|
||||
return worldMap.computeIfAbsent(w, w2 -> new TerraWorld(w, worlds.get(w.getName()), this));
|
||||
return worldMap.computeIfAbsent(w, w2 -> new TerraWorldImpl(w, worlds.get(w.getName()), this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.handles;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
@@ -26,7 +26,7 @@ public class BukkitWorldHandle implements WorldHandle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Location, Location> getSelectedLocation(Player player) {
|
||||
public Pair<LocationImpl, LocationImpl> getSelectedLocation(Player player) {
|
||||
org.bukkit.Location[] locations = WorldEditUtil.getSelectionLocations(BukkitAdapter.adapt(player));
|
||||
return Pair.of(BukkitAdapter.adapt(locations[0]), BukkitAdapter.adapt(locations[1]));
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.dfsek.terra.bukkit.listeners;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.transform.MapTransform;
|
||||
import com.dfsek.terra.api.transform.TransformerImpl;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.config.pack.WorldConfig;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.config.pack.WorldConfigImpl;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -46,7 +46,7 @@ public class CommonListener implements Listener {
|
||||
World bukkit = BukkitAdapter.adapt(e.getWorld());
|
||||
if(!bukkit.isTerraWorld()) return;
|
||||
TerraWorld tw = main.getWorld(bukkit);
|
||||
WorldConfig c = tw.getConfig();
|
||||
WorldConfigImpl c = tw.getConfig();
|
||||
if(c.getTemplate().isDisableSaplings()) return;
|
||||
e.setCancelled(true);
|
||||
Block block = e.getLocation().getBlock();
|
||||
@@ -54,6 +54,6 @@ public class CommonListener implements Listener {
|
||||
block.setType(Material.AIR);
|
||||
Tree tree = c.getRegistry(Tree.class).get(TREE_TYPE_STRING_TRANSFORMER.translate(e.getSpecies()));
|
||||
org.bukkit.Location location = e.getLocation();
|
||||
if(!tree.plant(new Location(bukkit, location.getX(), location.getY(), location.getZ()), new FastRandom())) block.setBlockData(data);
|
||||
if(!tree.plant(new LocationImpl(bukkit, location.getX(), location.getY(), location.getZ()), new FastRandom())) block.setBlockData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.bukkit.listeners;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.population.items.TerraStructure;
|
||||
import io.papermc.paper.event.world.StructureLocateEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.bukkit.listeners;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.population.items.TerraStructure;
|
||||
import org.bukkit.entity.EnderSignal;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
@@ -337,12 +338,12 @@ public final class BukkitAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public static Location adapt(com.dfsek.terra.api.vector.Location location) {
|
||||
public static Location adapt(LocationImpl location) {
|
||||
return new Location(((BukkitWorld) location.getWorld()).getHandle(), location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public static com.dfsek.terra.api.vector.Location adapt(Location location) {
|
||||
return new com.dfsek.terra.api.vector.Location(adapt(location.getWorld()), 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 Vector adapt(Vector3 vector3) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
@@ -43,7 +43,7 @@ public class BukkitTree implements Tree {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean plant(Location l, Random r) {
|
||||
public boolean plant(LocationImpl l, Random r) {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("bukkit_tree:" + delegate.toString().toLowerCase(Locale.ROOT))) {
|
||||
return ((BukkitWorld) l.getWorld()).getHandle().generateTree(BukkitAdapter.adapt(l), delegate);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -64,7 +64,7 @@ public class BukkitWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
public Entity spawnEntity(LocationImpl location, EntityType entityType) {
|
||||
return new BukkitEntity(delegate.spawnEntity(BukkitAdapter.adapt(location), ((BukkitEntityType) entityType).getHandle()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.world.block;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
@@ -48,7 +48,7 @@ public class BukkitBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
public LocationImpl getLocation() {
|
||||
return BukkitAdapter.adapt(delegate.getLocation());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
@@ -53,7 +54,7 @@ import com.dfsek.terra.profiler.ProfilerImpl;
|
||||
import com.dfsek.terra.api.registry.DuplicateEntryException;
|
||||
import com.dfsek.terra.registry.master.AddonRegistry;
|
||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.TerraWorldImpl;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -204,7 +205,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
worldMap.forEach((seed, pair) -> {
|
||||
pair.getRight().getConfig().getSamplerCache().clear();
|
||||
String packID = pair.getRight().getConfig().getTemplate().getID();
|
||||
pair.setRight(new TerraWorld(pair.getRight().getWorld(), configRegistry.get(packID), this));
|
||||
pair.setRight(new TerraWorldImpl(pair.getRight().getWorld(), configRegistry.get(packID), this));
|
||||
});
|
||||
return succeed;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.block;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.block.BlockFace;
|
||||
@@ -49,7 +49,7 @@ public class FabricBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
public LocationImpl getLocation() {
|
||||
return FabricAdapter.adapt(delegate.position).toLocation((World) delegate.worldAccess);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.fabric.generation;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
||||
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
||||
@@ -13,7 +14,6 @@ import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.mixin.StructureAccessorAccessor;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
|
||||
import com.dfsek.terra.world.population.items.TerraStructure;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.handle;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
@@ -39,7 +39,7 @@ public class FabricWorldHandle implements WorldHandle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Location, Location> getSelectedLocation(Player player) {
|
||||
public Pair<LocationImpl, LocationImpl> getSelectedLocation(Player player) {
|
||||
try {
|
||||
Class.forName("com.sk89q.worldedit.WorldEdit");
|
||||
} catch(ClassNotFoundException e) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.fabric.mixin;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.TerraWorldImpl;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldGenerationProgressListener;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -27,7 +27,7 @@ public abstract class ServerWorldMixin {
|
||||
@Inject(method = "<init>", at = @At(value = "RETURN"))
|
||||
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey<World> registryKey, DimensionType dimensionType, WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<Spawner> list, boolean bl, CallbackInfo ci) {
|
||||
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
||||
TerraFabricPlugin.getInstance().getWorldMap().put(dimensionType, Pair.of((ServerWorld) (Object) this, new TerraWorld((com.dfsek.terra.api.world.World) this, ((FabricChunkGeneratorWrapper) chunkGenerator).getPack(), TerraFabricPlugin.getInstance())));
|
||||
TerraFabricPlugin.getInstance().getWorldMap().put(dimensionType, Pair.of((ServerWorld) (Object) this, new TerraWorldImpl((com.dfsek.terra.api.world.World) this, ((FabricChunkGeneratorWrapper) chunkGenerator).getPack(), TerraFabricPlugin.getInstance())));
|
||||
((FabricChunkGeneratorWrapper) chunkGenerator).setDimensionType(dimensionType);
|
||||
TerraFabricPlugin.getInstance().logger().info("Registered world " + this + " to dimension type " + dimensionType);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
@@ -25,7 +25,7 @@ public abstract class ConfiguredFeatureMixin {
|
||||
public abstract boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos);
|
||||
|
||||
@SuppressWarnings({"ConstantConditions", "try"})
|
||||
public boolean terra$plant(Location l, Random r) {
|
||||
public boolean terra$plant(LocationImpl l, Random r) {
|
||||
String id = BuiltinRegistries.CONFIGURED_FEATURE.getId((ConfiguredFeature<?, ?>) (Object) this).toString();
|
||||
try(ProfileFrame ignore = TerraFabricPlugin.getInstance().getProfiler().profile("fabric_tree:" + id.toLowerCase(Locale.ROOT))) {
|
||||
StructureWorldAccess fabricWorldAccess = ((StructureWorldAccess) l.getWorld());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.entity;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -35,11 +35,11 @@ public abstract class EntityMixin {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Location terra$getLocation() {
|
||||
return new Location((World) world, FabricAdapter.adapt(blockPos));
|
||||
public LocationImpl terra$getLocation() {
|
||||
return new LocationImpl((World) world, FabricAdapter.adapt(blockPos));
|
||||
}
|
||||
|
||||
public void terra$setLocation(Location location) {
|
||||
public void terra$setLocation(LocationImpl location) {
|
||||
teleport(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.world;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -51,7 +51,7 @@ public abstract class ChunkRegionMixin {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Entity terra$spawnEntity(Location location, EntityType entityType) {
|
||||
public Entity terra$spawnEntity(LocationImpl location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ChunkRegion) (Object) this).toServerWorld());
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
((ChunkRegion) (Object) this).spawnEntity(entity);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations.world;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -42,7 +42,7 @@ public abstract class ServerWorldMixin {
|
||||
return new FabricBlock(new BlockPos(x, y, z), ((ServerWorld) (Object) this));
|
||||
}
|
||||
|
||||
public Entity terra$spawnEntity(Location location, EntityType entityType) {
|
||||
public Entity terra$spawnEntity(LocationImpl location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ServerWorld) (Object) this));
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
((ServerWorld) (Object) this).spawnEntity(entity);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.fabric.util;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public final class WorldEditUtil {
|
||||
public static Pair<Location, Location> getSelection(Player player) {
|
||||
public static Pair<LocationImpl, LocationImpl> getSelection(Player player) {
|
||||
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||
try {
|
||||
Region selection = worldEdit.getSessionManager()
|
||||
@@ -19,8 +19,8 @@ public final class WorldEditUtil {
|
||||
.getSelection(com.sk89q.worldedit.fabric.FabricAdapter.adapt((World) player.getWorld()));
|
||||
BlockVector3 min = selection.getMinimumPoint();
|
||||
BlockVector3 max = selection.getMaximumPoint();
|
||||
Location l1 = new Location(player.getWorld(), min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
||||
Location l2 = new Location(player.getWorld(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
||||
LocationImpl l1 = new LocationImpl(player.getWorld(), min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
||||
LocationImpl l2 = new LocationImpl(player.getWorld(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
||||
return Pair.of(l1, l2);
|
||||
} catch(IncompleteRegionException e) {
|
||||
throw new IllegalStateException("No selection has been made", e);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.dfsek.terra.api.event.EventManagerImpl;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
@@ -25,7 +26,7 @@ import com.dfsek.terra.api.profiler.Profiler;
|
||||
import com.dfsek.terra.profiler.ProfilerImpl;
|
||||
import com.dfsek.terra.registry.master.AddonRegistry;
|
||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.dfsek.terra.world.TerraWorldImpl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -50,7 +51,7 @@ public class StandalonePlugin implements TerraPlugin {
|
||||
|
||||
@Override
|
||||
public TerraWorld getWorld(World world) {
|
||||
return new TerraWorld(world, registry.get("DEFAULT"), this);
|
||||
return new TerraWorldImpl(world, registry.get("DEFAULT"), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
@@ -51,7 +51,7 @@ public class DirectBlock implements Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
public LocationImpl getLocation() {
|
||||
return pos.toLocation(world);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.DirectUtils;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
@@ -62,7 +62,7 @@ public class DirectWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
public Entity spawnEntity(LocationImpl location, EntityType entityType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Random;
|
||||
|
||||
public class RawTree implements Tree { // TODO: implement
|
||||
@Override
|
||||
public boolean plant(Location l, Random r) {
|
||||
public boolean plant(LocationImpl l, Random r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.dfsek.terra.api.event.EventManager;
|
||||
import com.dfsek.terra.api.event.EventManagerImpl;
|
||||
import com.dfsek.terra.api.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.LockedRegistry;
|
||||
@@ -18,7 +19,6 @@ import com.dfsek.terra.api.profiler.Profiler;
|
||||
import com.dfsek.terra.registry.master.AddonRegistry;
|
||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||
import com.dfsek.terra.sponge.world.SpongeWorldHandle;
|
||||
import com.dfsek.terra.world.TerraWorld;
|
||||
import com.google.inject.Inject;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.config.ConfigDir;
|
||||
|
||||
Reference in New Issue
Block a user