mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-09 17:26:07 +00:00
location garbage
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user