mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-16 13:23:07 +00:00
sort of working fabric implementation
This commit is contained in:
@@ -4,6 +4,7 @@ import com.dfsek.terra.api.structure.buffer.Buffer;
|
|||||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.api.world.Chunk;
|
import com.dfsek.terra.api.world.Chunk;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ public interface Structure {
|
|||||||
boolean test(Location location, Random random, Rotation rotation);
|
boolean test(Location location, Random random, Rotation rotation);
|
||||||
|
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
boolean generate(Buffer buffer, Random random, Rotation rotation, int recursions);
|
boolean generate(Buffer buffer, World world, Random random, Rotation rotation, int recursions);
|
||||||
|
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
boolean generateDirect(Location location, Random random, Rotation rotation);
|
boolean generateDirect(Location location, Random random, Rotation rotation);
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
package com.dfsek.terra.api.structure.buffer;
|
package com.dfsek.terra.api.structure.buffer;
|
||||||
|
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.Chunk;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public interface Buffer {
|
public interface Buffer {
|
||||||
Buffer addItem(BufferedItem item, Location location);
|
void paste(Vector3 origin, Chunk chunk);
|
||||||
|
|
||||||
Location getOrigin();
|
void paste(Vector3 origin, World world);
|
||||||
|
|
||||||
String getMark(Location location);
|
Buffer addItem(BufferedItem item, Vector3 location);
|
||||||
|
|
||||||
Buffer setMark(String mark, Location location);
|
Vector3 getOrigin();
|
||||||
|
|
||||||
|
String getMark(Vector3 location);
|
||||||
|
|
||||||
|
Buffer setMark(String mark, Vector3 location);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
package com.dfsek.terra.api.structure.buffer;
|
package com.dfsek.terra.api.structure.buffer;
|
||||||
|
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.api.world.Chunk;
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public interface BufferedItem {
|
public interface BufferedItem {
|
||||||
void paste(Location origin);
|
void paste(Vector3 origin, World world);
|
||||||
|
|
||||||
default void paste(Chunk chunk, Location origin) {
|
|
||||||
origin.setWorld(chunk.getWorld()); // Fabric weirdness
|
|
||||||
paste(origin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ import com.dfsek.terra.api.structures.script.builders.ZeroArgFunctionBuilder;
|
|||||||
import com.dfsek.terra.api.structures.structure.buffer.DirectBuffer;
|
import com.dfsek.terra.api.structures.structure.buffer.DirectBuffer;
|
||||||
import com.dfsek.terra.api.structures.structure.buffer.StructureBuffer;
|
import com.dfsek.terra.api.structures.structure.buffer.StructureBuffer;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.api.world.Chunk;
|
import com.dfsek.terra.api.world.Chunk;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
@@ -48,7 +50,7 @@ import java.util.concurrent.ExecutionException;
|
|||||||
public class StructureScript implements Structure {
|
public class StructureScript implements Structure {
|
||||||
private final Block block;
|
private final Block block;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Cache<Location, StructureBuffer> cache;
|
private final Cache<Vector3, StructureBuffer> cache;
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
private String tempID;
|
private String tempID;
|
||||||
|
|
||||||
@@ -115,9 +117,9 @@ public class StructureScript implements Structure {
|
|||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
public boolean generate(Location location, Random random, Rotation rotation) {
|
public boolean generate(Location location, Random random, Rotation rotation) {
|
||||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript:" + id)) {
|
try(ProfileFrame ignore = main.getProfiler().profile("terrascript:" + id)) {
|
||||||
StructureBuffer buffer = new StructureBuffer(location);
|
StructureBuffer buffer = new StructureBuffer(location.toVector());
|
||||||
boolean level = applyBlock(new TerraImplementationArguments(buffer, rotation, random, 0));
|
boolean level = applyBlock(new TerraImplementationArguments(buffer, rotation, random, location.getWorld(), 0));
|
||||||
buffer.paste();
|
buffer.paste(location.toVector(), location.getWorld());
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,8 +128,8 @@ public class StructureScript implements Structure {
|
|||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
public boolean generate(Location location, Chunk chunk, Random random, Rotation rotation) {
|
public boolean generate(Location location, Chunk chunk, Random random, Rotation rotation) {
|
||||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_chunk:" + id)) {
|
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_chunk:" + id)) {
|
||||||
StructureBuffer buffer = computeBuffer(location, random, rotation);
|
StructureBuffer buffer = computeBuffer(location.toVector(), location.getWorld(), random, rotation);
|
||||||
buffer.paste(chunk);
|
buffer.paste(location.toVector(), chunk);
|
||||||
return buffer.succeeded();
|
return buffer.succeeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,16 +138,16 @@ public class StructureScript implements Structure {
|
|||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
public boolean test(Location location, Random random, Rotation rotation) {
|
public boolean test(Location location, Random random, Rotation rotation) {
|
||||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_test:" + id)) {
|
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_test:" + id)) {
|
||||||
StructureBuffer buffer = computeBuffer(location, random, rotation);
|
StructureBuffer buffer = computeBuffer(location.toVector(), location.getWorld(), random, rotation);
|
||||||
return buffer.succeeded();
|
return buffer.succeeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private StructureBuffer computeBuffer(Location location, Random random, Rotation rotation) {
|
private StructureBuffer computeBuffer(Vector3 location, World world, Random random, Rotation rotation) {
|
||||||
try {
|
try {
|
||||||
return cache.get(location, () -> {
|
return cache.get(location, () -> {
|
||||||
StructureBuffer buf = new StructureBuffer(location);
|
StructureBuffer buf = new StructureBuffer(location);
|
||||||
buf.setSucceeded(applyBlock(new TerraImplementationArguments(buf, rotation, random, 0)));
|
buf.setSucceeded(applyBlock(new TerraImplementationArguments(buf, rotation, random, world, 0)));
|
||||||
return buf;
|
return buf;
|
||||||
});
|
});
|
||||||
} catch(ExecutionException e) {
|
} catch(ExecutionException e) {
|
||||||
@@ -155,9 +157,9 @@ public class StructureScript implements Structure {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
public boolean generate(Buffer buffer, Random random, Rotation rotation, int recursions) {
|
public boolean generate(Buffer buffer, World world, Random random, Rotation rotation, int recursions) {
|
||||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_recursive:" + id)) {
|
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_recursive:" + id)) {
|
||||||
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, recursions));
|
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, recursions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,8 +167,8 @@ public class StructureScript implements Structure {
|
|||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
public boolean generateDirect(Location location, Random random, Rotation rotation) {
|
public boolean generateDirect(Location location, Random random, Rotation rotation) {
|
||||||
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_direct:" + id)) {
|
try(ProfileFrame ignore = main.getProfiler().profile("terrascript_direct:" + id)) {
|
||||||
DirectBuffer buffer = new DirectBuffer(location);
|
DirectBuffer buffer = new DirectBuffer(location.toVector(), location.getWorld());
|
||||||
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, 0));
|
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, location.getWorld(), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.api.structures.script;
|
|||||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -10,13 +11,15 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
|||||||
private final Buffer buffer;
|
private final Buffer buffer;
|
||||||
private final Rotation rotation;
|
private final Rotation rotation;
|
||||||
private final Random random;
|
private final Random random;
|
||||||
|
private final World world;
|
||||||
private final int recursions;
|
private final int recursions;
|
||||||
private boolean waterlog = false;
|
private boolean waterlog = false;
|
||||||
|
|
||||||
public TerraImplementationArguments(Buffer buffer, Rotation rotation, Random random, int recursions) {
|
public TerraImplementationArguments(Buffer buffer, Rotation rotation, Random random, World world, int recursions) {
|
||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
this.random = random;
|
this.random = random;
|
||||||
|
this.world = world;
|
||||||
this.recursions = recursions;
|
this.recursions = recursions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,4 +46,8 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
|||||||
public void setWaterlog(boolean waterlog) {
|
public void setWaterlog(boolean waterlog) {
|
||||||
this.waterlog = waterlog;
|
this.waterlog = waterlog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public abstract class AbstractBlockFunction implements Function<Void> {
|
|||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
|
|
||||||
RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
||||||
arguments.getBuffer().addItem(new BufferedBlock(rot, overwrite.apply(implementationArguments, variableMap), main, arguments.isWaterlog()), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())).toLocation(arguments.getBuffer().getOrigin().getWorld()));
|
arguments.getBuffer().addItem(new BufferedBlock(rot, overwrite.apply(implementationArguments, variableMap), main, arguments.isWaterlog()), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class BiomeFunction implements Function<String> {
|
|||||||
|
|
||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
|
|
||||||
BiomeProvider grid = main.getWorld(arguments.getBuffer().getOrigin().getWorld()).getBiomeProvider();
|
BiomeProvider grid = main.getWorld(arguments.getWorld()).getBiomeProvider();
|
||||||
|
|
||||||
return ((UserDefinedBiome) grid.getBiome(arguments.getBuffer().getOrigin().clone().add(new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ()))))).getID();
|
return ((UserDefinedBiome) grid.getBiome(arguments.getBuffer().getOrigin().clone().add(new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ()))))).getID();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class CheckBlockFunction implements Function<String> {
|
|||||||
|
|
||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
|
|
||||||
String data = arguments.getBuffer().getOrigin().getWorld().getBlockData(arguments.getBuffer().getOrigin().clone().add(new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ()))).getVector()).getAsString();
|
String data = arguments.getWorld().getBlockData(arguments.getBuffer().getOrigin().clone().add(new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())))).getAsString();
|
||||||
if(data.contains("[")) return data.substring(0, data.indexOf('[')); // Strip properties
|
if(data.contains("[")) return data.substring(0, data.indexOf('[')); // Strip properties
|
||||||
else return data;
|
else return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
|
|||||||
import com.dfsek.terra.api.util.RotationUtil;
|
import com.dfsek.terra.api.util.RotationUtil;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.api.vector.Vector2;
|
import com.dfsek.terra.api.vector.Vector2;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.api.world.TerraWorld;
|
import com.dfsek.terra.api.world.TerraWorld;
|
||||||
import com.dfsek.terra.api.world.World;
|
import com.dfsek.terra.api.world.World;
|
||||||
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||||
@@ -47,12 +48,12 @@ public class CheckFunction implements Function<String> {
|
|||||||
|
|
||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
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())));
|
Vector3 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());
|
return apply(location, arguments.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String apply(Location vector, World world) {
|
private String apply(Vector3 vector, World world) {
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
SamplerCache cache = tw.getConfig().getSamplerCache();
|
SamplerCache cache = tw.getConfig().getSamplerCache();
|
||||||
double comp = sample(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), cache);
|
double comp = sample(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), cache);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class EntityFunction implements Function<Void> {
|
|||||||
|
|
||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
|
|
||||||
arguments.getBuffer().addItem(new BufferedEntity(data, main), new Vector3Impl(xz.getX(), y.apply(implementationArguments, variableMap).doubleValue(), xz.getZ()).toLocation(arguments.getBuffer().getOrigin().getWorld()));
|
arguments.getBuffer().addItem(new BufferedEntity(data, main), new Vector3Impl(xz.getX(), y.apply(implementationArguments, variableMap).doubleValue(), xz.getZ()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class GetMarkFunction implements Function<String> {
|
|||||||
Vector2 xz = new Vector2Impl(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
Vector2 xz = new Vector2Impl(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||||
|
|
||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
String mark = arguments.getBuffer().getMark(new Vector3Impl(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(y.apply(implementationArguments, variableMap).doubleValue()), FastMath.floorToInt(xz.getZ())).toLocation(arguments.getBuffer().getOrigin().getWorld()));
|
String mark = arguments.getBuffer().getMark(new Vector3Impl(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(y.apply(implementationArguments, variableMap).doubleValue()), FastMath.floorToInt(xz.getZ())));
|
||||||
return mark == null ? "" : mark;
|
return mark == null ? "" : mark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class LootFunction implements Function<Void> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
arguments.getBuffer().addItem(new BufferedLootApplication(table, main, script), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())).toLocation(arguments.getBuffer().getOrigin().getWorld()));
|
arguments.getBuffer().addItem(new BufferedLootApplication(table, main, script), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class PullFunction implements Function<Void> {
|
|||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
BlockData rot = data.clone();
|
BlockData rot = data.clone();
|
||||||
RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
||||||
arguments.getBuffer().addItem(new BufferedPulledBlock(rot), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())).toLocation(arguments.getBuffer().getOrigin().getWorld()));
|
arguments.getBuffer().addItem(new BufferedPulledBlock(rot), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class SetMarkFunction implements Function<Void> {
|
|||||||
|
|
||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
|
|
||||||
arguments.getBuffer().setMark(mark.apply(implementationArguments, variableMap), new Vector3Impl(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(y.apply(implementationArguments, variableMap).doubleValue()), FastMath.floorToInt(xz.getZ())).toLocation(arguments.getBuffer().getOrigin().getWorld()));
|
arguments.getBuffer().setMark(mark.apply(implementationArguments, variableMap), new Vector3Impl(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(y.apply(implementationArguments, variableMap).doubleValue()), FastMath.floorToInt(xz.getZ())));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class StateFunction implements Function<Void> {
|
|||||||
Vector2 xz = new Vector2Impl(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
Vector2 xz = new Vector2Impl(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||||
|
|
||||||
arguments.getBuffer().addItem(new BufferedStateManipulator(main, data.apply(implementationArguments, variableMap)), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())).toLocation(arguments.getBuffer().getOrigin().getWorld()));
|
arguments.getBuffer().addItem(new BufferedStateManipulator(main, data.apply(implementationArguments, variableMap)), new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class StructureFunction implements Function<Boolean> {
|
|||||||
|
|
||||||
Vector3 offset = new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ()));
|
Vector3 offset = new Vector3Impl(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ()));
|
||||||
|
|
||||||
return script.generate(new IntermediateBuffer(arguments.getBuffer(), offset), arguments.getRandom(), arguments.getRotation().rotate(rotation1), arguments.getRecursions() + 1);
|
return script.generate(new IntermediateBuffer(arguments.getBuffer(), offset), arguments.getWorld(), arguments.getRandom(), arguments.getRotation().rotate(rotation1), arguments.getRecursions() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.dfsek.terra.api.structures.structure.buffer;
|
|||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.util.GlueList;
|
import com.dfsek.terra.api.util.GlueList;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -10,10 +12,9 @@ public class Cell implements BufferedItem {
|
|||||||
private final List<BufferedItem> items = new GlueList<>();
|
private final List<BufferedItem> items = new GlueList<>();
|
||||||
private String mark = null;
|
private String mark = null;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paste(Location origin) {
|
public void paste(Vector3 origin, World world) {
|
||||||
items.forEach(item -> item.paste(origin));
|
items.forEach(item -> item.paste(origin, world));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(BufferedItem item) {
|
public void add(BufferedItem item) {
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package com.dfsek.terra.api.structures.structure.buffer;
|
|||||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.Chunk;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -11,31 +14,43 @@ import java.util.Map;
|
|||||||
* Buffer implementation that directly pastes to the world.
|
* Buffer implementation that directly pastes to the world.
|
||||||
*/
|
*/
|
||||||
public class DirectBuffer implements Buffer {
|
public class DirectBuffer implements Buffer {
|
||||||
private final Location origin;
|
private final Vector3 origin;
|
||||||
private final Map<Location, String> marks = new LinkedHashMap<>();
|
private final World target;
|
||||||
|
private final Map<Vector3, String> marks = new LinkedHashMap<>();
|
||||||
|
|
||||||
public DirectBuffer(Location origin) {
|
public DirectBuffer(Vector3 origin, World target) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Buffer addItem(BufferedItem item, Location location) {
|
public void paste(Vector3 origin, Chunk chunk) {
|
||||||
item.paste(origin.clone().add(location));
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paste(Vector3 origin, World world) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Buffer addItem(BufferedItem item, Vector3 location) {
|
||||||
|
item.paste(origin.clone().add(location), target);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getOrigin() {
|
public Vector3 getOrigin() {
|
||||||
return origin;
|
return origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMark(Location location) {
|
public String getMark(Vector3 location) {
|
||||||
return marks.get(location);
|
return marks.get(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Buffer setMark(String mark, Location location) {
|
public Buffer setMark(String mark, Vector3 location) {
|
||||||
marks.put(location, mark);
|
marks.put(location, mark);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.dfsek.terra.api.structure.buffer.Buffer;
|
|||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.api.vector.Vector3;
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.Chunk;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public class IntermediateBuffer implements Buffer {
|
public class IntermediateBuffer implements Buffer {
|
||||||
private final Buffer original;
|
private final Buffer original;
|
||||||
@@ -15,22 +17,32 @@ public class IntermediateBuffer implements Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Buffer addItem(BufferedItem item, Location location) {
|
public void paste(Vector3 origin, Chunk chunk) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paste(Vector3 origin, World world) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Buffer addItem(BufferedItem item, Vector3 location) {
|
||||||
return original.addItem(item, location.add(offset));
|
return original.addItem(item, location.add(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getOrigin() {
|
public Vector3 getOrigin() {
|
||||||
return original.getOrigin().clone().add(offset);
|
return original.getOrigin().clone().add(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMark(Location location) {
|
public String getMark(Vector3 location) {
|
||||||
return original.getMark(location.add(offset));
|
return original.getMark(location.add(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Buffer setMark(String mark, Location location) {
|
public Buffer setMark(String mark, Vector3 location) {
|
||||||
original.setMark(mark, location.add(offset));
|
original.setMark(mark, location.add(offset));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,42 +3,44 @@ package com.dfsek.terra.api.structures.structure.buffer;
|
|||||||
import com.dfsek.terra.api.structure.buffer.Buffer;
|
import com.dfsek.terra.api.structure.buffer.Buffer;
|
||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.api.world.Chunk;
|
import com.dfsek.terra.api.world.Chunk;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class StructureBuffer implements Buffer {
|
public class StructureBuffer implements Buffer {
|
||||||
private final Map<Location, Cell> bufferedItemMap = new LinkedHashMap<>();
|
private final Map<Vector3, Cell> bufferedItemMap = new LinkedHashMap<>();
|
||||||
private final Location origin;
|
private final Vector3 origin;
|
||||||
private boolean succeeded;
|
private boolean succeeded;
|
||||||
|
|
||||||
public StructureBuffer(Location origin) {
|
public StructureBuffer(Vector3 origin) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paste() {
|
public void paste(Vector3 origin, World world) {
|
||||||
bufferedItemMap.forEach(((vector3, item) -> item.paste(origin.clone().add(vector3))));
|
bufferedItemMap.forEach(((vector3, item) -> item.paste(origin.clone().add(vector3), world)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paste(Chunk chunk) {
|
public void paste(Vector3 origin, Chunk chunk) {
|
||||||
bufferedItemMap.forEach(((location, item) -> {
|
bufferedItemMap.forEach(((location, item) -> {
|
||||||
Location current = origin.clone().add(location);
|
Vector3 current = origin.clone().add(location);
|
||||||
if(FastMath.floorDiv(current.getBlockX(), 16) != chunk.getX() || FastMath.floorDiv(current.getBlockZ(), 16) != chunk.getZ())
|
if(FastMath.floorDiv(current.getBlockX(), 16) != chunk.getX() || FastMath.floorDiv(current.getBlockZ(), 16) != chunk.getZ())
|
||||||
return;
|
return;
|
||||||
item.paste(chunk, current);
|
item.paste(current, chunk.getWorld());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Buffer addItem(BufferedItem item, Location location) {
|
public Buffer addItem(BufferedItem item, Vector3 location) {
|
||||||
bufferedItemMap.computeIfAbsent(location, l -> new Cell()).add(item);
|
bufferedItemMap.computeIfAbsent(location, l -> new Cell()).add(item);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMark(Location location) {
|
public String getMark(Vector3 location) {
|
||||||
Cell cell = bufferedItemMap.get(location);
|
Cell cell = bufferedItemMap.get(location);
|
||||||
if(cell != null) {
|
if(cell != null) {
|
||||||
return cell.getMark();
|
return cell.getMark();
|
||||||
@@ -47,7 +49,7 @@ public class StructureBuffer implements Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Buffer setMark(String mark, Location location) {
|
public Buffer setMark(String mark, Vector3 location) {
|
||||||
bufferedItemMap.computeIfAbsent(location, l -> new Cell()).setMark(mark);
|
bufferedItemMap.computeIfAbsent(location, l -> new Cell()).setMark(mark);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -61,7 +63,7 @@ public class StructureBuffer implements Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getOrigin() {
|
public Vector3 getOrigin() {
|
||||||
return origin.clone();
|
return origin.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import com.dfsek.terra.api.TerraPlugin;
|
|||||||
import com.dfsek.terra.api.block.BlockData;
|
import com.dfsek.terra.api.block.BlockData;
|
||||||
import com.dfsek.terra.api.block.data.Waterlogged;
|
import com.dfsek.terra.api.block.data.Waterlogged;
|
||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public class BufferedBlock implements BufferedItem {
|
public class BufferedBlock implements BufferedItem {
|
||||||
private final BlockData data;
|
private final BlockData data;
|
||||||
@@ -20,13 +21,13 @@ public class BufferedBlock implements BufferedItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paste(Location origin) {
|
public void paste(Vector3 origin, World world) {
|
||||||
try {
|
try {
|
||||||
BlockData data = origin.getWorld().getBlockData(origin.toVector());
|
BlockData current = world.getBlockData(origin);
|
||||||
if(overwrite || data.isAir()) {
|
if(overwrite || current.isAir()) {
|
||||||
if(waterlog && data instanceof Waterlogged && data.getBlockType().isWater())
|
if(waterlog && current instanceof Waterlogged && current.getBlockType().isWater())
|
||||||
((Waterlogged) data).setWaterlogged(true);
|
((Waterlogged) current).setWaterlogged(true);
|
||||||
origin.getWorld().setBlockData(origin.getVector(), data);
|
world.setBlockData(origin, data);
|
||||||
}
|
}
|
||||||
} catch(RuntimeException e) {
|
} catch(RuntimeException e) {
|
||||||
main.logger().severe("Failed to place block at location " + origin + ": " + e.getMessage());
|
main.logger().severe("Failed to place block at location " + origin + ": " + e.getMessage());
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.dfsek.terra.api.entity.EntityType;
|
|||||||
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public class BufferedEntity implements BufferedItem {
|
public class BufferedEntity implements BufferedItem {
|
||||||
|
|
||||||
@@ -18,8 +20,8 @@ public class BufferedEntity implements BufferedItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paste(Location origin) {
|
public void paste(Vector3 origin, World world) {
|
||||||
Entity entity = origin.clone().add(0.5, 0, 0.5).getWorld().spawnEntity(origin, type);
|
Entity entity = world.spawnEntity(origin.clone().add(0.5, 0, 0.5).toLocation(world), type);
|
||||||
main.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getTerraGenerator().getConfigPack(), entity));
|
main.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getTerraGenerator().getConfigPack(), entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
|||||||
import com.dfsek.terra.api.structures.script.StructureScript;
|
import com.dfsek.terra.api.structures.script.StructureScript;
|
||||||
import com.dfsek.terra.api.util.FastRandom;
|
import com.dfsek.terra.api.util.FastRandom;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public class BufferedLootApplication implements BufferedItem {
|
public class BufferedLootApplication implements BufferedItem {
|
||||||
private final LootTable table;
|
private final LootTable table;
|
||||||
@@ -22,16 +24,16 @@ public class BufferedLootApplication implements BufferedItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paste(Location origin) {
|
public void paste(Vector3 origin, World world) {
|
||||||
try {
|
try {
|
||||||
BlockState data = origin.getWorld().getBlockState(origin.getVector());
|
BlockState data = world.getBlockState(origin);
|
||||||
if(!(data instanceof Container)) {
|
if(!(data instanceof Container)) {
|
||||||
main.logger().severe("Failed to place loot at " + origin + "; block " + data + " is not container.");
|
main.logger().severe("Failed to place loot at " + origin + "; block " + data + " is not container.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Container container = (Container) data;
|
Container container = (Container) data;
|
||||||
|
|
||||||
LootPopulateEvent event = new LootPopulateEvent(container, table, origin.getWorld().getTerraGenerator().getConfigPack(), structure);
|
LootPopulateEvent event = new LootPopulateEvent(container, table, world.getTerraGenerator().getConfigPack(), structure);
|
||||||
main.getEventManager().callEvent(event);
|
main.getEventManager().callEvent(event);
|
||||||
if(event.isCancelled()) return;
|
if(event.isCancelled()) return;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.dfsek.terra.api.block.BlockData;
|
|||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.api.vector.Vector3;
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public class BufferedPulledBlock implements BufferedItem {
|
public class BufferedPulledBlock implements BufferedItem {
|
||||||
private final BlockData data;
|
private final BlockData data;
|
||||||
@@ -13,11 +14,11 @@ public class BufferedPulledBlock implements BufferedItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paste(Location origin) {
|
public void paste(Vector3 origin, World world) {
|
||||||
Vector3 mutable = origin.toVector();
|
Vector3 mutable = origin.clone();
|
||||||
while(mutable.getY() > origin.getWorld().getMinHeight()) {
|
while(mutable.getY() > world.getMinHeight()) {
|
||||||
if(!origin.getWorld().getBlockData(mutable).isAir()) {
|
if(!world.getBlockData(mutable).isAir()) {
|
||||||
origin.getWorld().setBlockData(mutable, data);
|
world.setBlockData(mutable, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mutable.subtract(0, 1, 0);
|
mutable.subtract(0, 1, 0);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.dfsek.terra.api.TerraPlugin;
|
|||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public class BufferedStateManipulator implements BufferedItem {
|
public class BufferedStateManipulator implements BufferedItem {
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
@@ -15,9 +17,9 @@ public class BufferedStateManipulator implements BufferedItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paste(Location origin) {
|
public void paste(Vector3 origin, World world) {
|
||||||
try {
|
try {
|
||||||
BlockState state = origin.getWorld().getBlockState(origin.getVector());
|
BlockState state = world.getBlockState(origin);
|
||||||
state.applyState(data);
|
state.applyState(data);
|
||||||
state.update(false);
|
state.update(false);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
|
|||||||
import com.dfsek.terra.api.util.FastRandom;
|
import com.dfsek.terra.api.util.FastRandom;
|
||||||
import com.dfsek.terra.api.vector.Vector3;
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
import com.dfsek.terra.vector.LocationImpl;
|
||||||
|
import com.dfsek.terra.vector.Vector3Impl;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -41,8 +42,8 @@ public class SpawnCommand implements CommandTemplate {
|
|||||||
Position dummy = new Position(0, 0);
|
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(
|
String check = new CheckFunction(main, new NumericConstant(0, dummy), new NumericConstant(0, dummy), new NumericConstant(0, dummy), dummy).apply(new TerraImplementationArguments(new StructureBuffer(
|
||||||
new LocationImpl(player.world(), x, y, z)
|
new Vector3Impl(x, y, z)
|
||||||
), Rotation.NONE, new FastRandom(), 0), new HashMap<>());
|
), Rotation.NONE, new FastRandom(), player.world(), 0), new HashMap<>());
|
||||||
|
|
||||||
sender.sendMessage("Found: " + check);
|
sender.sendMessage("Found: " + check);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.dfsek.terra.world.population.items.tree;
|
package com.dfsek.terra.world.population.items.tree;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.BlockFace;
|
|
||||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
import com.dfsek.terra.api.util.PopulationUtil;
|
import com.dfsek.terra.api.util.PopulationUtil;
|
||||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||||
@@ -19,12 +18,14 @@ public class TreeLayer extends PlaceableLayer<Tree> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void place(Chunk chunk, Vector2 coords) {
|
public void place(Chunk chunk, Vector2 coords) {
|
||||||
Tree item = layer.get(noise, coords.getX(), coords.getZ());
|
int cx = chunk.getX() << 4;
|
||||||
|
int cz = chunk.getZ() << 4;
|
||||||
|
Tree item = layer.get(noise, coords.getX() + cx, coords.getZ() + cz);
|
||||||
Vector3 running = coords.extrude(level.getMax());
|
Vector3 running = coords.extrude(level.getMax());
|
||||||
for(int ignored : level) {
|
for(int ignored : level) {
|
||||||
running.subtract(0,1,0);
|
running.subtract(0,1,0);
|
||||||
if(item.getSpawnable().contains(chunk.getBlockData(running.getBlockX(), running.getBlockY(), running.getBlockZ()).getBlockType())) {
|
if(item.getSpawnable().contains(chunk.getBlockData(running.getBlockX(), running.getBlockY(), running.getBlockZ()).getBlockType())) {
|
||||||
item.plant(running.toLocation(chunk.getWorld()).add(0, 1, 0), PopulationUtil.getRandom(chunk, coords.hashCode()));
|
item.plant(running.toLocation(chunk.getWorld()).add(cx, 1, cz), PopulationUtil.getRandom(chunk, coords.hashCode()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user