worldaccess -> WritableWorld

This commit is contained in:
dfsek
2021-11-28 16:32:59 -07:00
parent 27f472dd57
commit 402ac166ff
23 changed files with 57 additions and 68 deletions
@@ -7,7 +7,7 @@
package com.dfsek.terra.addons.chunkgenerator.generation.generators; package com.dfsek.terra.addons.chunkgenerator.generation.generators;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import net.jafama.FastMath; import net.jafama.FastMath;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -49,7 +49,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
@Override @Override
@SuppressWarnings("try") @SuppressWarnings("try")
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldAccess world, public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
int chunkZ, int chunkZ,
int chunkX) { int chunkX) {
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) { try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {
@@ -13,8 +13,7 @@ import com.dfsek.terra.api.structure.feature.Distributor;
import com.dfsek.terra.api.structure.feature.Feature; import com.dfsek.terra.api.structure.feature.Feature;
import com.dfsek.terra.api.structure.feature.Locator; import com.dfsek.terra.api.structure.feature.Locator;
import com.dfsek.terra.api.util.collection.ProbabilityCollection; import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.world.access.World; import com.dfsek.terra.api.world.access.WritableWorld;
import com.dfsek.terra.api.world.access.WorldAccess;
public class ConfiguredFeature implements Feature { public class ConfiguredFeature implements Feature {
@@ -33,7 +32,7 @@ public class ConfiguredFeature implements Feature {
} }
@Override @Override
public Structure getStructure(WorldAccess world, int x, int y, int z) { public Structure getStructure(WritableWorld world, int x, int y, int z) {
return structures.get(structureSelector, x, y, z, world.getSeed()); return structures.get(structureSelector, x, y, z, world.getSeed());
} }
@@ -7,7 +7,7 @@
package com.dfsek.terra.addons.flora.flora.gen; package com.dfsek.terra.addons.flora.flora.gen;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import net.jafama.FastMath; import net.jafama.FastMath;
@@ -27,7 +27,6 @@ import com.dfsek.terra.api.util.collection.MaterialSet;
import com.dfsek.terra.api.util.collection.ProbabilityCollection; import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.chunk.Chunk; import com.dfsek.terra.api.world.chunk.Chunk;
import com.dfsek.terra.api.world.access.World;
public class TerraFlora implements Structure { public class TerraFlora implements Structure {
@@ -58,7 +57,7 @@ public class TerraFlora implements Structure {
}); });
} }
private void test(EnumSet<Direction> faces, Direction f, Vector3 b, WorldAccess world) { private void test(EnumSet<Direction> faces, Direction f, Vector3 b, WritableWorld world) {
if(testRotation.contains( if(testRotation.contains(
world.getBlockData(b.getBlockX() + f.getModX(), b.getBlockY() + f.getModY(), b.getBlockZ() + f.getModZ()).getBlockType())) world.getBlockData(b.getBlockX() + f.getModX(), b.getBlockY() + f.getModY(), b.getBlockZ() + f.getModZ()).getBlockType()))
faces.add(f); faces.add(f);
@@ -68,7 +67,7 @@ public class TerraFlora implements Structure {
return layers.get(FastMath.max(FastMath.min(layer, layers.size() - 1), 0)); return layers.get(FastMath.max(FastMath.min(layer, layers.size() - 1), 0));
} }
private EnumSet<Direction> getFaces(Vector3 b, WorldAccess world) { private EnumSet<Direction> getFaces(Vector3 b, WritableWorld world) {
EnumSet<Direction> faces = EnumSet.noneOf(Direction.class); EnumSet<Direction> faces = EnumSet.noneOf(Direction.class);
test(faces, Direction.NORTH, b, world); test(faces, Direction.NORTH, b, world);
test(faces, Direction.SOUTH, b, world); test(faces, Direction.SOUTH, b, world);
@@ -83,17 +82,17 @@ public class TerraFlora implements Structure {
} }
@Override @Override
public boolean generate(Vector3 location, WorldAccess world, Chunk chunk, Random random, Rotation rotation) { public boolean generate(Vector3 location, WritableWorld world, Chunk chunk, Random random, Rotation rotation) {
return generate(location, world, random, rotation); return generate(location, world, random, rotation);
} }
@Override @Override
public boolean generate(Buffer buffer, WorldAccess world, Random random, Rotation rotation, int recursions) { public boolean generate(Buffer buffer, WritableWorld world, Random random, Rotation rotation, int recursions) {
return generate(buffer.getOrigin(), world, random, rotation); return generate(buffer.getOrigin(), world, random, rotation);
} }
@Override @Override
public boolean generate(Vector3 location, WorldAccess world, Random random, Rotation rotation) { public boolean generate(Vector3 location, WritableWorld world, Random random, Rotation rotation) {
boolean doRotation = testRotation.size() > 0; boolean doRotation = testRotation.size() > 0;
int size = layers.size(); int size = layers.size();
int c = ceiling ? -1 : 1; int c = ceiling ? -1 : 1;
@@ -12,11 +12,10 @@ import java.util.function.IntConsumer;
import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.structure.feature.BinaryColumn; import com.dfsek.terra.api.structure.feature.BinaryColumn;
import com.dfsek.terra.api.world.access.Column; import com.dfsek.terra.api.world.access.Column;
import com.dfsek.terra.api.world.access.World; import com.dfsek.terra.api.world.access.WritableWorld;
import com.dfsek.terra.api.world.access.WorldAccess;
public class ColumnImpl<T extends WorldAccess> implements Column<T> { public class ColumnImpl<T extends WritableWorld> implements Column<T> {
private final int x; private final int x;
private final int z; private final int z;
private final T world; private final T world;
@@ -7,7 +7,7 @@
package com.dfsek.terra.addons.sponge; package com.dfsek.terra.addons.sponge;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import net.jafama.FastMath; import net.jafama.FastMath;
@@ -38,7 +38,7 @@ public class SpongeStructure implements Structure {
} }
@Override @Override
public boolean generate(Vector3 location, WorldAccess world, Chunk chunk, Random random, Rotation rotation) { public boolean generate(Vector3 location, WritableWorld world, Chunk chunk, Random random, Rotation rotation) {
int bX = location.getBlockX(); int bX = location.getBlockX();
int bY = location.getBlockY(); int bY = location.getBlockY();
int bZ = location.getBlockZ(); int bZ = location.getBlockZ();
@@ -61,7 +61,7 @@ public class SpongeStructure implements Structure {
} }
@Override @Override
public boolean generate(Buffer buffer, WorldAccess world, Random random, Rotation rotation, int recursions) { public boolean generate(Buffer buffer, WritableWorld world, Random random, Rotation rotation, int recursions) {
for(int x = 0; x < blocks.length; x++) { for(int x = 0; x < blocks.length; x++) {
for(int z = 0; z < blocks[x].length; z++) { for(int z = 0; z < blocks[x].length; z++) {
Vector2Int r = Vector2Int.of(x, z).rotate(rotation); Vector2Int r = Vector2Int.of(x, z).rotate(rotation);
@@ -78,7 +78,7 @@ public class SpongeStructure implements Structure {
} }
@Override @Override
public boolean generate(Vector3 location, WorldAccess world, Random random, Rotation rotation) { public boolean generate(Vector3 location, WritableWorld world, Random random, Rotation rotation) {
int bX = location.getBlockX(); int bX = location.getBlockX();
int bY = location.getBlockY(); int bY = location.getBlockY();
int bZ = location.getBlockZ(); int bZ = location.getBlockZ();
@@ -13,7 +13,7 @@ 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.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
public class BufferedEntity implements BufferedItem { public class BufferedEntity implements BufferedItem {
@@ -27,7 +27,7 @@ public class BufferedEntity implements BufferedItem {
} }
@Override @Override
public void paste(Vector3 origin, WorldAccess world) { public void paste(Vector3 origin, WritableWorld world) {
Entity entity = world.spawnEntity(origin.clone().add(0.5, 0, 0.5), type); Entity entity = world.spawnEntity(origin.clone().add(0.5, 0, 0.5), type);
platform.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getConfig().getPack(), entity)); platform.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getConfig().getPack(), entity));
} }
@@ -18,7 +18,7 @@ import com.dfsek.terra.api.structure.LootTable;
import com.dfsek.terra.api.structure.buffer.BufferedItem; import com.dfsek.terra.api.structure.buffer.BufferedItem;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -38,7 +38,7 @@ public class BufferedLootApplication implements BufferedItem {
} }
@Override @Override
public void paste(Vector3 origin, WorldAccess world) { public void paste(Vector3 origin, WritableWorld world) {
try { try {
BlockEntity data = world.getBlockState(origin); BlockEntity data = world.getBlockState(origin);
if(!(data instanceof Container container)) { if(!(data instanceof Container container)) {
@@ -10,7 +10,7 @@ package com.dfsek.terra.addons.terrascript.buffer.items;
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.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
public class BufferedPulledBlock implements BufferedItem { public class BufferedPulledBlock implements BufferedItem {
@@ -21,7 +21,7 @@ public class BufferedPulledBlock implements BufferedItem {
} }
@Override @Override
public void paste(Vector3 origin, WorldAccess world) { public void paste(Vector3 origin, WritableWorld world) {
Vector3 mutable = origin.clone(); Vector3 mutable = origin.clone();
while(mutable.getY() > world.getMinHeight()) { while(mutable.getY() > world.getMinHeight()) {
if(!world.getBlockData(mutable).isAir()) { if(!world.getBlockData(mutable).isAir()) {
@@ -11,7 +11,7 @@ import com.dfsek.terra.api.block.entity.BlockEntity;
import com.dfsek.terra.api.structure.buffer.BufferedItem; import com.dfsek.terra.api.structure.buffer.BufferedItem;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -27,7 +27,7 @@ public class BufferedStateManipulator implements BufferedItem {
} }
@Override @Override
public void paste(Vector3 origin, WorldAccess world) { public void paste(Vector3 origin, WritableWorld world) {
try { try {
BlockEntity state = world.getBlockState(origin); BlockEntity state = world.getBlockState(origin);
state.applyState(data); state.applyState(data);
@@ -7,7 +7,7 @@
package com.dfsek.terra.addons.terrascript.script; package com.dfsek.terra.addons.terrascript.script;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
@@ -138,7 +138,7 @@ public class StructureScript implements Structure {
@Override @Override
@SuppressWarnings("try") @SuppressWarnings("try")
public boolean generate(Vector3 location, WorldAccess world, Chunk chunk, Random random, Rotation rotation) { public boolean generate(Vector3 location, WritableWorld world, Chunk chunk, Random random, Rotation rotation) {
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_chunk:" + id)) { try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_chunk:" + id)) {
StructureBuffer buffer = computeBuffer(location, world, random, rotation); StructureBuffer buffer = computeBuffer(location, world, random, rotation);
buffer.paste(location, chunk); buffer.paste(location, chunk);
@@ -148,7 +148,7 @@ public class StructureScript implements Structure {
@Override @Override
@SuppressWarnings("try") @SuppressWarnings("try")
public boolean generate(Buffer buffer, WorldAccess world, Random random, Rotation rotation, int recursions) { public boolean generate(Buffer buffer, WritableWorld world, Random random, Rotation rotation, int recursions) {
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_recursive:" + id)) { try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_recursive:" + id)) {
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, recursions)); return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, recursions));
} }
@@ -156,7 +156,7 @@ public class StructureScript implements Structure {
@Override @Override
@SuppressWarnings("try") @SuppressWarnings("try")
public boolean generate(Vector3 location, WorldAccess world, Random random, Rotation rotation) { public boolean generate(Vector3 location, WritableWorld world, Random random, Rotation rotation) {
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_direct:" + id)) { try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_direct:" + id)) {
DirectBuffer buffer = new DirectBuffer(location, world); DirectBuffer buffer = new DirectBuffer(location, world);
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, 0)); return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, 0));
@@ -171,7 +171,7 @@ public class StructureScript implements Structure {
} }
} }
private StructureBuffer computeBuffer(Vector3 location, WorldAccess world, Random random, Rotation rotation) { private StructureBuffer computeBuffer(Vector3 location, WritableWorld 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);
@@ -12,19 +12,18 @@ import java.util.Random;
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments; import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
import com.dfsek.terra.api.structure.buffer.Buffer; import com.dfsek.terra.api.structure.buffer.Buffer;
import com.dfsek.terra.api.util.Rotation; import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.world.access.World; import com.dfsek.terra.api.world.access.WritableWorld;
import com.dfsek.terra.api.world.access.WorldAccess;
public class TerraImplementationArguments implements ImplementationArguments { 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 WorldAccess world; private final WritableWorld 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, WorldAccess world, int recursions) { public TerraImplementationArguments(Buffer buffer, Rotation rotation, Random random, WritableWorld world, int recursions) {
this.buffer = buffer; this.buffer = buffer;
this.rotation = rotation; this.rotation = rotation;
this.random = random; this.random = random;
@@ -56,7 +55,7 @@ public class TerraImplementationArguments implements ImplementationArguments {
this.waterlog = waterlog; this.waterlog = waterlog;
} }
public WorldAccess getWorld() { public WritableWorld getWorld() {
return world; return world;
} }
} }
@@ -7,7 +7,7 @@
package com.dfsek.terra.addons.terrascript.script.functions; package com.dfsek.terra.addons.terrascript.script.functions;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import net.jafama.FastMath; import net.jafama.FastMath;
@@ -23,7 +23,6 @@ import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.util.RotationUtil; import com.dfsek.terra.api.util.RotationUtil;
import com.dfsek.terra.api.util.vector.Vector2; import com.dfsek.terra.api.util.vector.Vector2;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.World;
import com.dfsek.terra.api.world.generator.SamplerCache; import com.dfsek.terra.api.world.generator.SamplerCache;
@@ -70,7 +69,7 @@ public class CheckFunction implements Function<String> {
return ReturnType.STRING; return ReturnType.STRING;
} }
private String apply(Vector3 vector, WorldAccess world) { private String apply(Vector3 vector, WritableWorld world) {
int y = vector.getBlockY(); int y = vector.getBlockY();
if(y >= world.getMaxHeight() || y < 0) return "AIR"; if(y >= world.getMaxHeight() || y < 0) return "AIR";
SamplerCache cache = world.getConfig().getSamplerCache(); SamplerCache cache = world.getConfig().getSamplerCache();
@@ -13,14 +13,14 @@ import com.dfsek.terra.api.structure.buffer.Buffer;
import com.dfsek.terra.api.util.Rotation; import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.util.StringIdentifiable; import com.dfsek.terra.api.util.StringIdentifiable;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import com.dfsek.terra.api.world.chunk.Chunk; import com.dfsek.terra.api.world.chunk.Chunk;
public interface Structure extends StringIdentifiable { public interface Structure extends StringIdentifiable {
boolean generate(Vector3 location, WorldAccess world, Chunk chunk, Random random, Rotation rotation); boolean generate(Vector3 location, WritableWorld world, Chunk chunk, Random random, Rotation rotation);
boolean generate(Buffer buffer, WorldAccess world, Random random, Rotation rotation, int recursions); boolean generate(Buffer buffer, WritableWorld world, Random random, Rotation rotation, int recursions);
boolean generate(Vector3 location, WorldAccess world, Random random, Rotation rotation); boolean generate(Vector3 location, WritableWorld world, Random random, Rotation rotation);
} }
@@ -9,12 +9,12 @@ package com.dfsek.terra.api.structure.buffer;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import org.jetbrains.annotations.ApiStatus.Experimental; import org.jetbrains.annotations.ApiStatus.Experimental;
@Experimental @Experimental
public interface BufferedItem { public interface BufferedItem {
void paste(Vector3 origin, WorldAccess world); void paste(Vector3 origin, WritableWorld world);
} }
@@ -13,7 +13,7 @@ import java.util.Map;
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.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import com.dfsek.terra.api.world.chunk.Chunk; import com.dfsek.terra.api.world.chunk.Chunk;
import com.dfsek.terra.api.world.access.World; import com.dfsek.terra.api.world.access.World;
@@ -26,10 +26,10 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
@Experimental @Experimental
public class DirectBuffer implements Buffer { public class DirectBuffer implements Buffer {
private final Vector3 origin; private final Vector3 origin;
private final WorldAccess target; private final WritableWorld target;
private final Map<Vector3, String> marks = new LinkedHashMap<>(); private final Map<Vector3, String> marks = new LinkedHashMap<>();
public DirectBuffer(Vector3 origin, WorldAccess target) { public DirectBuffer(Vector3 origin, WritableWorld target) {
this.origin = origin; this.origin = origin;
this.target = target; this.target = target;
} }
@@ -7,7 +7,7 @@
package com.dfsek.terra.api.structure.buffer.items; package com.dfsek.terra.api.structure.buffer.items;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import org.jetbrains.annotations.ApiStatus.Experimental; import org.jetbrains.annotations.ApiStatus.Experimental;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -37,7 +37,7 @@ public class BufferedBlock implements BufferedItem {
} }
@Override @Override
public void paste(Vector3 origin, WorldAccess world) { public void paste(Vector3 origin, WritableWorld world) {
try { try {
BlockState current = world.getBlockData(origin); BlockState current = world.getBlockData(origin);
if(overwrite || current.isAir()) { if(overwrite || current.isAir()) {
@@ -13,7 +13,7 @@ import java.util.List;
import com.dfsek.terra.api.structure.buffer.BufferedItem; import com.dfsek.terra.api.structure.buffer.BufferedItem;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import org.jetbrains.annotations.ApiStatus.Experimental; import org.jetbrains.annotations.ApiStatus.Experimental;
@@ -24,7 +24,7 @@ public class Cell implements BufferedItem {
private String mark; private String mark;
@Override @Override
public void paste(Vector3 origin, WorldAccess world) { public void paste(Vector3 origin, WritableWorld world) {
items.forEach(item -> item.paste(origin.clone(), world)); items.forEach(item -> item.paste(origin.clone(), world));
} }
@@ -8,12 +8,11 @@
package com.dfsek.terra.api.structure.feature; package com.dfsek.terra.api.structure.feature;
import com.dfsek.terra.api.structure.Structure; import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.world.access.World; import com.dfsek.terra.api.world.access.WritableWorld;
import com.dfsek.terra.api.world.access.WorldAccess;
public interface Feature { public interface Feature {
Structure getStructure(WorldAccess world, int x, int y, int z); Structure getStructure(WritableWorld world, int x, int y, int z);
Distributor getDistributor(); Distributor getDistributor();
@@ -16,7 +16,7 @@ import com.dfsek.terra.api.structure.feature.BinaryColumn;
/** /**
* A single vertical column of a world. * A single vertical column of a world.
*/ */
public interface Column<T extends WorldAccess> { public interface Column<T extends WritableWorld> {
int getX(); int getX();
int getZ(); int getZ();
@@ -7,16 +7,11 @@
package com.dfsek.terra.api.world.access; package com.dfsek.terra.api.world.access;
import com.dfsek.terra.api.config.WorldConfig;
import com.dfsek.terra.api.entity.Entity;
import com.dfsek.terra.api.entity.EntityType;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.api.world.chunk.Chunk; import com.dfsek.terra.api.world.chunk.Chunk;
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
public interface World extends WorldAccess { public interface World extends WritableWorld {
Chunk getChunkAt(int x, int z); Chunk getChunkAt(int x, int z);
default Chunk getChunkAt(Vector3 location) { default Chunk getChunkAt(Vector3 location) {
@@ -11,7 +11,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator; import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
public interface WorldAccess extends Handle { public interface WritableWorld extends Handle {
default void setBlockData(Vector3 position, BlockState data, boolean physics) { default void setBlockData(Vector3 position, BlockState data, boolean physics) {
setBlockData(position.getBlockX(), position.getBlockY(), position.getBlockZ(), data, physics); setBlockData(position.getBlockX(), position.getBlockY(), position.getBlockZ(), data, physics);
} }
@@ -9,7 +9,7 @@ package com.dfsek.terra.api.world.chunk.generation;
import com.dfsek.terra.api.util.vector.integer.Vector3Int; import com.dfsek.terra.api.util.vector.integer.Vector3Int;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage; import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -26,7 +26,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
public interface ChunkGenerator { public interface ChunkGenerator {
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldAccess world, void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
int chunkZ, int chunkX); int chunkZ, int chunkX);
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth); Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);
@@ -1,10 +1,10 @@
package com.dfsek.terra.api.world.chunk.generation; package com.dfsek.terra.api.world.chunk.generation;
import com.dfsek.terra.api.world.access.World; import com.dfsek.terra.api.world.access.World;
import com.dfsek.terra.api.world.access.WorldAccess; import com.dfsek.terra.api.world.access.WritableWorld;
public interface ProtoWorld extends WorldAccess { public interface ProtoWorld extends WritableWorld {
int centerChunkX(); int centerChunkX();
int centerChunkZ(); int centerChunkZ();