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

View File

@@ -7,7 +7,7 @@
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 org.jetbrains.annotations.NotNull;
@@ -49,7 +49,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
@Override
@SuppressWarnings("try")
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldAccess world,
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
int chunkZ,
int chunkX) {
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {

View File

@@ -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.Locator;
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
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 class ConfiguredFeature implements Feature {
@@ -33,7 +32,7 @@ public class ConfiguredFeature implements Feature {
}
@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());
}

View File

@@ -7,7 +7,7 @@
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;
@@ -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.vector.Vector3;
import com.dfsek.terra.api.world.chunk.Chunk;
import com.dfsek.terra.api.world.access.World;
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(
world.getBlockData(b.getBlockX() + f.getModX(), b.getBlockY() + f.getModY(), b.getBlockZ() + f.getModZ()).getBlockType()))
faces.add(f);
@@ -68,7 +67,7 @@ public class TerraFlora implements Structure {
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);
test(faces, Direction.NORTH, b, world);
test(faces, Direction.SOUTH, b, world);
@@ -83,17 +82,17 @@ public class TerraFlora implements Structure {
}
@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);
}
@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);
}
@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;
int size = layers.size();
int c = ceiling ? -1 : 1;

View File

@@ -12,11 +12,10 @@ import java.util.function.IntConsumer;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.structure.feature.BinaryColumn;
import com.dfsek.terra.api.world.access.Column;
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 class ColumnImpl<T extends WorldAccess> implements Column<T> {
public class ColumnImpl<T extends WritableWorld> implements Column<T> {
private final int x;
private final int z;
private final T world;

View File

@@ -7,7 +7,7 @@
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;
@@ -38,7 +38,7 @@ public class SpongeStructure implements Structure {
}
@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 bY = location.getBlockY();
int bZ = location.getBlockZ();
@@ -61,7 +61,7 @@ public class SpongeStructure implements Structure {
}
@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 z = 0; z < blocks[x].length; z++) {
Vector2Int r = Vector2Int.of(x, z).rotate(rotation);
@@ -78,7 +78,7 @@ public class SpongeStructure implements Structure {
}
@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 bY = location.getBlockY();
int bZ = location.getBlockZ();

View File

@@ -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.structure.buffer.BufferedItem;
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 {
@@ -27,7 +27,7 @@ public class BufferedEntity implements BufferedItem {
}
@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);
platform.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getConfig().getPack(), entity));
}

View File

@@ -18,7 +18,7 @@ import com.dfsek.terra.api.structure.LootTable;
import com.dfsek.terra.api.structure.buffer.BufferedItem;
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.LoggerFactory;
@@ -38,7 +38,7 @@ public class BufferedLootApplication implements BufferedItem {
}
@Override
public void paste(Vector3 origin, WorldAccess world) {
public void paste(Vector3 origin, WritableWorld world) {
try {
BlockEntity data = world.getBlockState(origin);
if(!(data instanceof Container container)) {

View File

@@ -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.structure.buffer.BufferedItem;
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 {
@@ -21,7 +21,7 @@ public class BufferedPulledBlock implements BufferedItem {
}
@Override
public void paste(Vector3 origin, WorldAccess world) {
public void paste(Vector3 origin, WritableWorld world) {
Vector3 mutable = origin.clone();
while(mutable.getY() > world.getMinHeight()) {
if(!world.getBlockData(mutable).isAir()) {

View File

@@ -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.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.LoggerFactory;
@@ -27,7 +27,7 @@ public class BufferedStateManipulator implements BufferedItem {
}
@Override
public void paste(Vector3 origin, WorldAccess world) {
public void paste(Vector3 origin, WritableWorld world) {
try {
BlockEntity state = world.getBlockState(origin);
state.applyState(data);

View File

@@ -7,7 +7,7 @@
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.CacheBuilder;
@@ -138,7 +138,7 @@ public class StructureScript implements Structure {
@Override
@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)) {
StructureBuffer buffer = computeBuffer(location, world, random, rotation);
buffer.paste(location, chunk);
@@ -148,7 +148,7 @@ public class StructureScript implements Structure {
@Override
@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)) {
return applyBlock(new TerraImplementationArguments(buffer, rotation, random, world, recursions));
}
@@ -156,7 +156,7 @@ public class StructureScript implements Structure {
@Override
@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)) {
DirectBuffer buffer = new DirectBuffer(location, world);
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 {
return cache.get(location, () -> {
StructureBuffer buf = new StructureBuffer(location);

View File

@@ -12,19 +12,18 @@ import java.util.Random;
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
import com.dfsek.terra.api.structure.buffer.Buffer;
import com.dfsek.terra.api.util.Rotation;
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 class TerraImplementationArguments implements ImplementationArguments {
private final Buffer buffer;
private final Rotation rotation;
private final Random random;
private final WorldAccess world;
private final WritableWorld world;
private final int recursions;
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.rotation = rotation;
this.random = random;
@@ -56,7 +55,7 @@ public class TerraImplementationArguments implements ImplementationArguments {
this.waterlog = waterlog;
}
public WorldAccess getWorld() {
public WritableWorld getWorld() {
return world;
}
}

View File

@@ -7,7 +7,7 @@
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;
@@ -23,7 +23,6 @@ import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.util.RotationUtil;
import com.dfsek.terra.api.util.vector.Vector2;
import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.access.World;
import com.dfsek.terra.api.world.generator.SamplerCache;
@@ -70,7 +69,7 @@ public class CheckFunction implements Function<String> {
return ReturnType.STRING;
}
private String apply(Vector3 vector, WorldAccess world) {
private String apply(Vector3 vector, WritableWorld world) {
int y = vector.getBlockY();
if(y >= world.getMaxHeight() || y < 0) return "AIR";
SamplerCache cache = world.getConfig().getSamplerCache();

View File

@@ -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.StringIdentifiable;
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;
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);
}

View File

@@ -9,12 +9,12 @@ package com.dfsek.terra.api.structure.buffer;
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;
@Experimental
public interface BufferedItem {
void paste(Vector3 origin, WorldAccess world);
void paste(Vector3 origin, WritableWorld world);
}

View File

@@ -13,7 +13,7 @@ import java.util.Map;
import com.dfsek.terra.api.structure.buffer.Buffer;
import com.dfsek.terra.api.structure.buffer.BufferedItem;
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.access.World;
@@ -26,10 +26,10 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
@Experimental
public class DirectBuffer implements Buffer {
private final Vector3 origin;
private final WorldAccess target;
private final WritableWorld target;
private final Map<Vector3, String> marks = new LinkedHashMap<>();
public DirectBuffer(Vector3 origin, WorldAccess target) {
public DirectBuffer(Vector3 origin, WritableWorld target) {
this.origin = origin;
this.target = target;
}

View File

@@ -7,7 +7,7 @@
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.slf4j.Logger;
@@ -37,7 +37,7 @@ public class BufferedBlock implements BufferedItem {
}
@Override
public void paste(Vector3 origin, WorldAccess world) {
public void paste(Vector3 origin, WritableWorld world) {
try {
BlockState current = world.getBlockData(origin);
if(overwrite || current.isAir()) {

View File

@@ -13,7 +13,7 @@ import java.util.List;
import com.dfsek.terra.api.structure.buffer.BufferedItem;
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;
@@ -24,7 +24,7 @@ public class Cell implements BufferedItem {
private String mark;
@Override
public void paste(Vector3 origin, WorldAccess world) {
public void paste(Vector3 origin, WritableWorld world) {
items.forEach(item -> item.paste(origin.clone(), world));
}

View File

@@ -8,12 +8,11 @@
package com.dfsek.terra.api.structure.feature;
import com.dfsek.terra.api.structure.Structure;
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 Feature {
Structure getStructure(WorldAccess world, int x, int y, int z);
Structure getStructure(WritableWorld world, int x, int y, int z);
Distributor getDistributor();

View File

@@ -16,7 +16,7 @@ import com.dfsek.terra.api.structure.feature.BinaryColumn;
/**
* A single vertical column of a world.
*/
public interface Column<T extends WorldAccess> {
public interface Column<T extends WritableWorld> {
int getX();
int getZ();

View File

@@ -7,16 +7,11 @@
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.world.biome.generation.BiomeProvider;
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);
default Chunk getChunkAt(Vector3 location) {

View File

@@ -11,7 +11,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
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) {
setBlockData(position.getBlockX(), position.getBlockY(), position.getBlockZ(), data, physics);
}

View File

@@ -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.world.access.WorldAccess;
import com.dfsek.terra.api.world.access.WritableWorld;
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
import org.jetbrains.annotations.NotNull;
@@ -26,7 +26,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
public interface ChunkGenerator {
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldAccess world,
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
int chunkZ, int chunkX);
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);

View File

@@ -1,10 +1,10 @@
package com.dfsek.terra.api.world.chunk.generation;
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 centerChunkZ();