mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-20 15:20:25 +00:00
optimize biome pipeline cache for 3 dimensions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
version = version("1.0.0")
|
||||
version = version("1.0.1")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.util.function.IntIntObjConsumer;
|
||||
import com.dfsek.terra.api.util.function.IntObjConsumer;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
class BiomePipelineColumn implements Column<Biome> {
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final Biome biome;
|
||||
|
||||
protected BiomePipelineColumn(BiomeProvider biomeProvider, int min, int max, int x, int z, long seed) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.biome = biomeProvider.getBiome(x, 0, z, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinY() {
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome get(int y) {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forRanges(IntIntObjConsumer<Biome> consumer) {
|
||||
consumer.accept(min, max, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<Biome> consumer) {
|
||||
for(int y = min; y < max; y++) {
|
||||
consumer.accept(biome);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(IntObjConsumer<Biome> consumer) {
|
||||
for(int y = min; y < max; y++) {
|
||||
consumer.accept(y, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import net.jafama.FastMath;
|
||||
@@ -92,6 +95,11 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Column<Biome> getColumn(int x, int z, WorldProperties properties) {
|
||||
return new BiomePipelineColumn(this, properties.getMinHeight(), properties.getMaxHeight(), x, z, properties.getSeed());
|
||||
}
|
||||
|
||||
private record SeededVector(int x, int z, long seed) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user