mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-19 14:50:30 +00:00
World -> ServerWorld
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.generators;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.access.WritableWorld;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
@@ -23,7 +24,6 @@ import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.util.math.Sampler;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@@ -99,7 +99,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth) {
|
||||
public Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, ServerWorld world, int elevationSmooth) {
|
||||
return new Sampler3D(chunkX, chunkZ, provider, world, elevationSmooth);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(World world, int x, int y, int z) {
|
||||
public BlockState getBlock(ServerWorld world, int x, int y, int z) {
|
||||
BiomeProvider provider = world.getBiomeProvider();
|
||||
TerraBiome biome = provider.getBiome(x, z, world.getSeed());
|
||||
Sampler sampler = world.getConfig().getSamplerCache().get(x, z);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -15,7 +16,6 @@ import java.util.function.BiFunction;
|
||||
|
||||
import com.dfsek.terra.api.util.mutable.MutableInteger;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.ChunkInterpolator;
|
||||
@@ -36,7 +36,7 @@ public class ChunkInterpolator2D implements ChunkInterpolator {
|
||||
* @param chunkZ Z coordinate of the chunk.
|
||||
* @param provider Biome Provider to use for biome fetching.
|
||||
*/
|
||||
public ChunkInterpolator2D(World w, int chunkX, int chunkZ, BiomeProvider provider,
|
||||
public ChunkInterpolator2D(ServerWorld w, int chunkX, int chunkZ, BiomeProvider provider,
|
||||
BiFunction<GenerationSettings, Vector3, Double> noiseGetter) {
|
||||
this.noiseGetter = noiseGetter;
|
||||
int xOrigin = chunkX << 4;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -15,7 +16,6 @@ import java.util.function.BiFunction;
|
||||
|
||||
import com.dfsek.terra.api.util.mutable.MutableInteger;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.ChunkInterpolator;
|
||||
@@ -39,7 +39,7 @@ public class ChunkInterpolator3D implements ChunkInterpolator {
|
||||
* @param chunkZ Z coordinate of the chunk.
|
||||
* @param provider Biome Provider to use for biome fetching.
|
||||
*/
|
||||
public ChunkInterpolator3D(World w, int chunkX, int chunkZ, BiomeProvider provider,
|
||||
public ChunkInterpolator3D(ServerWorld w, int chunkX, int chunkZ, BiomeProvider provider,
|
||||
BiFunction<GenerationSettings, Vector3, Double> noiseGetter) {
|
||||
this.noiseGetter = noiseGetter;
|
||||
int xOrigin = chunkX << 4;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
public class ElevationInterpolator {
|
||||
private final double[][] values = new double[18][18];
|
||||
|
||||
public ElevationInterpolator(World world, int chunkX, int chunkZ, BiomeProvider provider, int smooth) {
|
||||
public ElevationInterpolator(ServerWorld world, int chunkX, int chunkZ, BiomeProvider provider, int smooth) {
|
||||
int xOrigin = chunkX << 4;
|
||||
int zOrigin = chunkZ << 4;
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.ChunkInterpolator3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.ElevationInterpolator;
|
||||
import com.dfsek.terra.api.util.math.Sampler;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Sampler3D implements Sampler {
|
||||
private final ChunkInterpolator3D interpolator;
|
||||
private final ElevationInterpolator elevationInterpolator;
|
||||
|
||||
public Sampler3D(int x, int z, BiomeProvider provider, World world, int elevationSmooth) {
|
||||
public Sampler3D(int x, int z, BiomeProvider provider, ServerWorld world, int elevationSmooth) {
|
||||
this.interpolator = new ChunkInterpolator3D(world, x, z, provider, (generator, coord) -> generator.getBaseSampler()
|
||||
.noise(coord,
|
||||
world.getSeed()));
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.command.biome;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
@@ -29,12 +30,12 @@ public class AsyncBiomeFinder implements Runnable {
|
||||
protected final int maxRadius;
|
||||
protected final int centerX;
|
||||
protected final int centerZ;
|
||||
protected final World world;
|
||||
protected final ServerWorld world;
|
||||
protected final Platform platform;
|
||||
private final Consumer<Vector3> callback;
|
||||
protected int searchSize = 1;
|
||||
|
||||
public AsyncBiomeFinder(BiomeProvider provider, TerraBiome target, @NotNull Vector3 origin, World world, int startRadius, int maxRadius,
|
||||
public AsyncBiomeFinder(BiomeProvider provider, TerraBiome target, @NotNull Vector3 origin, ServerWorld world, int startRadius, int maxRadius,
|
||||
Consumer<Vector3> callback, Platform platform) {
|
||||
this.provider = provider;
|
||||
this.target = target;
|
||||
@@ -105,7 +106,7 @@ public class AsyncBiomeFinder implements Runnable {
|
||||
return target;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
public ServerWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.structure.command;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -14,7 +16,6 @@ import java.util.function.Consumer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@@ -25,12 +26,12 @@ public class AsyncStructureFinder implements Runnable {
|
||||
protected final int maxRadius;
|
||||
protected final int centerX;
|
||||
protected final int centerZ;
|
||||
protected final World world;
|
||||
protected final ServerWorld world;
|
||||
protected final Platform platform;
|
||||
private final Consumer<Vector3> callback;
|
||||
protected int searchSize = 1;
|
||||
|
||||
public AsyncStructureFinder(BiomeProvider provider, ConfiguredStructure target, @NotNull Vector3 origin, World world, int startRadius,
|
||||
public AsyncStructureFinder(BiomeProvider provider, ConfiguredStructure target, @NotNull Vector3 origin, ServerWorld world, int startRadius,
|
||||
int maxRadius, Consumer<Vector3> callback, Platform platform) {
|
||||
//setSearchSize(target.getSpawn().getWidth() + 2 * target.getSpawn().getSeparation());
|
||||
this.provider = provider;
|
||||
@@ -99,7 +100,7 @@ public class AsyncStructureFinder implements Runnable {
|
||||
return target;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
public ServerWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ package com.dfsek.terra.addons.terrascript.buffer;
|
||||
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.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
|
||||
|
||||
public class IntermediateBuffer implements Buffer {
|
||||
@@ -29,7 +29,7 @@ public class IntermediateBuffer implements Buffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
public void paste(Vector3 origin, ServerWorld world) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.access.WritableWorld;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
@@ -53,7 +54,6 @@ import com.dfsek.terra.api.structure.buffer.buffers.StructureBuffer;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -164,7 +164,7 @@ public class StructureScript implements Structure {
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
public boolean test(Vector3 location, World world, Random random, Rotation rotation) {
|
||||
public boolean test(Vector3 location, ServerWorld world, Random random, Rotation rotation) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("terrascript_test:" + id)) {
|
||||
StructureBuffer buffer = computeBuffer(location, world, random, rotation);
|
||||
return buffer.succeeded();
|
||||
|
||||
@@ -21,14 +21,14 @@ import com.dfsek.terra.api.tectonic.LoaderHolder;
|
||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||
|
||||
|
||||
public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolder, StringIdentifiable {
|
||||
WorldConfig toWorldConfig(World world);
|
||||
WorldConfig toWorldConfig(ServerWorld world);
|
||||
|
||||
void registerConfigType(ConfigType<?, ?> type, String id, int priority);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.SamplerCache;
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface WorldConfig extends StringIdentifiable {
|
||||
|
||||
<T> Registry<T> getRegistry(Class<T> clazz);
|
||||
|
||||
World getWorld();
|
||||
ServerWorld getWorld();
|
||||
|
||||
SamplerCache getSamplerCache();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
package com.dfsek.terra.api.entity;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
|
||||
public interface Entity extends CommandSender {
|
||||
@@ -16,7 +16,7 @@ public interface Entity extends CommandSender {
|
||||
|
||||
void position(Vector3 position);
|
||||
|
||||
void world(World world);
|
||||
void world(ServerWorld world);
|
||||
|
||||
World world();
|
||||
ServerWorld world();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ package com.dfsek.terra.api.structure.buffer;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
public interface Buffer {
|
||||
void paste(Vector3 origin, Chunk chunk);
|
||||
|
||||
void paste(Vector3 origin, World world);
|
||||
void paste(Vector3 origin, ServerWorld world);
|
||||
|
||||
Buffer addItem(BufferedItem item, Vector3 location);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DirectBuffer implements Buffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paste(Vector3 origin, World world) {
|
||||
public void paste(Vector3 origin, ServerWorld world) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.api.structure.buffer.buffers;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -17,7 +19,6 @@ import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||
import com.dfsek.terra.api.structure.buffer.items.Cell;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
@@ -41,7 +42,7 @@ public class StructureBuffer implements Buffer {
|
||||
}));
|
||||
}
|
||||
|
||||
public void paste(Vector3 origin, World world) {
|
||||
public void paste(Vector3 origin, ServerWorld world) {
|
||||
bufferedItemMap.forEach(((vector3, item) -> item.paste(origin.clone().add(vector3), world)));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.ChunkAccess;
|
||||
|
||||
|
||||
public interface Carver {
|
||||
void carve(World world, int chunkX, int chunkZ, ChunkAccess chunk);
|
||||
void carve(ServerWorld world, int chunkX, int chunkZ, ChunkAccess chunk);
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
|
||||
public interface Flora {
|
||||
boolean plant(Vector3 l, World world);
|
||||
boolean plant(Vector3 l, ServerWorld world);
|
||||
|
||||
List<Vector3> getValidSpawnsAt(Chunk chunk, int x, int z, Range check);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
|
||||
public interface World extends WritableWorld {
|
||||
public interface ServerWorld extends WritableWorld {
|
||||
Chunk getChunkAt(int x, int z);
|
||||
|
||||
default Chunk getChunkAt(Vector3 location) {
|
||||
@@ -9,7 +9,7 @@ package com.dfsek.terra.api.world.chunk;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -27,5 +27,5 @@ public interface Chunk extends ChunkAccess {
|
||||
|
||||
int getZ();
|
||||
|
||||
World getWorld();
|
||||
ServerWorld getWorld();
|
||||
}
|
||||
|
||||
@@ -9,6 +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.ServerWorld;
|
||||
import com.dfsek.terra.api.world.access.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
|
||||
@@ -21,14 +22,13 @@ import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.util.math.Sampler;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public interface ChunkGenerator {
|
||||
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
|
||||
int chunkZ, int chunkX);
|
||||
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);
|
||||
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, ServerWorld world, int elevationSmooth);
|
||||
|
||||
ConfigPack getConfigPack();
|
||||
|
||||
@@ -36,13 +36,13 @@ public interface ChunkGenerator {
|
||||
|
||||
List<GenerationStage> getGenerationStages();
|
||||
|
||||
BlockState getBlock(World world, int x, int y, int z);
|
||||
BlockState getBlock(ServerWorld world, int x, int y, int z);
|
||||
|
||||
default BlockState getBlock(World world, Vector3 vector3) {
|
||||
default BlockState getBlock(ServerWorld world, Vector3 vector3) {
|
||||
return getBlock(world, vector3.getBlockX(), vector3.getBlockY(), vector3.getBlockZ());
|
||||
}
|
||||
|
||||
default BlockState getBlock(World world, Vector3Int vector3) {
|
||||
default BlockState getBlock(ServerWorld world, Vector3Int vector3) {
|
||||
return getBlock(world, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.world.chunk.generation;
|
||||
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.access.WritableWorld;
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ public interface ProtoWorld extends WritableWorld {
|
||||
* <b>Do not read from/write to this world!</b>
|
||||
* @return The world
|
||||
*/
|
||||
World getWorld();
|
||||
ServerWorld getWorld();
|
||||
}
|
||||
|
||||
@@ -22,14 +22,13 @@ import com.dfsek.terra.api.block.state.BlockState;
|
||||
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.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
|
||||
|
||||
public class DummyWorld implements World {
|
||||
public class DummyServerWorld implements ServerWorld {
|
||||
@Override
|
||||
public Entity spawnEntity(double x, double y, double z, EntityType entityType) {
|
||||
throw new UnsupportedOperationException("Cannot spawn entity in DummyWorld");
|
||||
@@ -30,6 +30,9 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.tectonic.loading.TypeRegistry;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.tectonic.yaml.YamlConfiguration;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -73,11 +76,10 @@ import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
import com.dfsek.terra.api.registry.meta.RegistryFactory;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||
import com.dfsek.terra.config.dummy.DummyWorld;
|
||||
import com.dfsek.terra.config.dummy.DummyServerWorld;
|
||||
import com.dfsek.terra.config.fileloaders.FolderLoader;
|
||||
import com.dfsek.terra.config.fileloaders.ZIPLoader;
|
||||
import com.dfsek.terra.config.loaders.GenericTemplateSupplierLoader;
|
||||
@@ -164,7 +166,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
logger.error("Failed to load config pack from folder \"{}\"", folder.getAbsolutePath(), e);
|
||||
throw e;
|
||||
}
|
||||
toWorldConfig(new DummyWorld()); // Build now to catch any errors immediately.
|
||||
toWorldConfig(new DummyServerWorld()); // Build now to catch any errors immediately.
|
||||
}
|
||||
|
||||
public ConfigPackImpl(ZipFile file, Platform platform) throws ConfigException {
|
||||
@@ -218,7 +220,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
throw e;
|
||||
}
|
||||
|
||||
toWorldConfig(new DummyWorld()); // Build now to catch any errors immediately.
|
||||
toWorldConfig(new DummyServerWorld()); // Build now to catch any errors immediately.
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,7 +246,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldConfigImpl toWorldConfig(World world) {
|
||||
public WorldConfigImpl toWorldConfig(ServerWorld world) {
|
||||
return new WorldConfigImpl(world, this, platform);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.generator.SamplerCache;
|
||||
import com.dfsek.terra.registry.LockedRegistryImpl;
|
||||
@@ -37,12 +37,12 @@ public class WorldConfigImpl implements WorldConfig {
|
||||
|
||||
private final BiomeProvider provider;
|
||||
|
||||
private final World world;
|
||||
private final ServerWorld world;
|
||||
private final ConfigPackImpl pack;
|
||||
|
||||
private final Map<Type, Registry<?>> registryMap = new HashMap<>();
|
||||
|
||||
public WorldConfigImpl(World world, ConfigPackImpl pack, Platform platform) {
|
||||
public WorldConfigImpl(ServerWorld world, ConfigPackImpl pack, Platform platform) {
|
||||
this.world = world;
|
||||
this.pack = pack;
|
||||
this.samplerCache = new SamplerCacheImpl(platform, world);
|
||||
@@ -89,7 +89,7 @@ public class WorldConfigImpl implements WorldConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
public ServerWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.dfsek.terra.world;
|
||||
|
||||
import com.dfsek.terra.api.world.access.ServerWorld;
|
||||
import com.dfsek.terra.api.world.generator.SamplerCache;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
@@ -28,13 +29,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.util.math.Sampler;
|
||||
import com.dfsek.terra.api.world.access.World;
|
||||
|
||||
|
||||
public class SamplerCacheImpl implements SamplerCache {
|
||||
private final LoadingCache<Long, Sampler> cache;
|
||||
|
||||
public SamplerCacheImpl(Platform platform, World world) {
|
||||
public SamplerCacheImpl(Platform platform, ServerWorld world) {
|
||||
cache = CacheBuilder.newBuilder().maximumSize(platform.getTerraConfig().getSamplerCache())
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user