mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
make getBlock accept WorldProperties
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -20,7 +22,6 @@ import com.dfsek.terra.api.Platform;
|
||||
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.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@@ -38,9 +39,11 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
|
||||
private final int carverHorizontalResolution;
|
||||
private final int carverVerticalResolution;
|
||||
private final ConfigPack configPack;
|
||||
|
||||
public NoiseChunkGenerator3D(ConfigPack c, Platform platform, int elevationBlend, int carverHorizontalResolution,
|
||||
int carverVerticalResolution) {
|
||||
this.configPack = c;
|
||||
this.platform = platform;
|
||||
this.air = platform.getWorldHandle().air();
|
||||
this.carverHorizontalResolution = carverHorizontalResolution;
|
||||
@@ -107,8 +110,8 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(ServerWorld world, int x, int y, int z) {
|
||||
BiomeProvider provider = world.getBiomeProvider();
|
||||
public BlockState getBlock(WorldProperties world, int x, int y, int z) {
|
||||
BiomeProvider provider = configPack.getBiomeProvider();
|
||||
Biome biome = provider.getBiome(x, z, world.getSeed());
|
||||
Sampler3D sampler = samplerCache.get(x, z, world);
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@@ -45,13 +47,13 @@ public class SamplerProvider {
|
||||
});
|
||||
}
|
||||
|
||||
public Sampler3D get(int x, int z, World world) {
|
||||
public Sampler3D get(int x, int z, WorldProperties world) {
|
||||
int cx = FastMath.floorDiv(x, 16);
|
||||
int cz = FastMath.floorDiv(z, 16);
|
||||
return getChunk(cx, cz, world);
|
||||
}
|
||||
|
||||
public Sampler3D getChunk(int cx, int cz, World world) {
|
||||
public Sampler3D getChunk(int cx, int cz, WorldProperties world) {
|
||||
return cache.getUnchecked(new WorldContext(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight()));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
|
||||
package com.dfsek.terra.api.world.chunk.generation;
|
||||
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
@@ -20,13 +21,13 @@ public interface ChunkGenerator {
|
||||
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WritableWorld world,
|
||||
int chunkX, int chunkZ);
|
||||
|
||||
BlockState getBlock(ServerWorld world, int x, int y, int z);
|
||||
BlockState getBlock(WorldProperties world, int x, int y, int z);
|
||||
|
||||
default BlockState getBlock(ServerWorld world, Vector3 vector3) {
|
||||
default BlockState getBlock(WorldProperties world, Vector3 vector3) {
|
||||
return getBlock(world, vector3.getBlockX(), vector3.getBlockY(), vector3.getBlockZ());
|
||||
}
|
||||
|
||||
default BlockState getBlock(ServerWorld world, Vector3Int vector3) {
|
||||
default BlockState getBlock(WorldProperties world, Vector3Int vector3) {
|
||||
return getBlock(world, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user