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;
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")) {
@@ -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());
}
@@ -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;
@@ -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;
@@ -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();
@@ -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));
}
@@ -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)) {
@@ -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()) {
@@ -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);
@@ -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);
@@ -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;
}
}
@@ -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();