mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 06:11:24 +00:00
use caching provider in getBlock
This commit is contained in:
+3
-4
@@ -108,10 +108,9 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(WorldProperties world, int x, int y, int z) {
|
public BlockState getBlock(WorldProperties world, int x, int y, int z, BiomeProvider biomeProvider) {
|
||||||
BiomeProvider provider = configPack.getBiomeProvider();
|
Biome biome = biomeProvider.getBiome(x, z, world.getSeed());
|
||||||
Biome biome = provider.getBiome(x, z, world.getSeed());
|
Sampler3D sampler = samplerCache.get(x, z, world, biomeProvider);
|
||||||
Sampler3D sampler = samplerCache.get(x, z, world, configPack.getBiomeProvider());
|
|
||||||
|
|
||||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -22,13 +22,13 @@ public interface ChunkGenerator {
|
|||||||
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world, @NotNull BiomeProvider biomeProvider,
|
void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world, @NotNull BiomeProvider biomeProvider,
|
||||||
int chunkX, int chunkZ);
|
int chunkX, int chunkZ);
|
||||||
|
|
||||||
BlockState getBlock(WorldProperties world, int x, int y, int z);
|
BlockState getBlock(WorldProperties world, int x, int y, int z, BiomeProvider biomeProvider);
|
||||||
|
|
||||||
default BlockState getBlock(WorldProperties world, Vector3 vector3) {
|
default BlockState getBlock(WorldProperties world, Vector3 vector3, BiomeProvider biomeProvider) {
|
||||||
return getBlock(world, vector3.getBlockX(), vector3.getBlockY(), vector3.getBlockZ());
|
return getBlock(world, vector3.getBlockX(), vector3.getBlockY(), vector3.getBlockZ(), biomeProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
default BlockState getBlock(WorldProperties world, Vector3Int vector3) {
|
default BlockState getBlock(WorldProperties world, Vector3Int vector3, BiomeProvider biomeProvider) {
|
||||||
return getBlock(world, vector3.getX(), vector3.getY(), vector3.getZ());
|
return getBlock(world, vector3.getX(), vector3.getY(), vector3.getZ(), biomeProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -18,6 +18,7 @@
|
|||||||
package com.dfsek.terra.fabric.generation;
|
package com.dfsek.terra.fabric.generation;
|
||||||
|
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
import com.dfsek.terra.api.world.chunk.generation.ProtoChunk;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||||
@@ -188,8 +189,9 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
@Override
|
@Override
|
||||||
public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView height) {
|
public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView height) {
|
||||||
int y = height.getTopY();
|
int y = height.getTopY();
|
||||||
|
BiomeProvider biomeProvider = pack.getBiomeProvider().caching();
|
||||||
while(y >= getMinimumY() && !heightmap.getBlockPredicate().test(
|
while(y >= getMinimumY() && !heightmap.getBlockPredicate().test(
|
||||||
(BlockState) delegate.getBlock(FabricAdapter.adapt(height, seed), x, y - 1, z))) {
|
(BlockState) delegate.getBlock(FabricAdapter.adapt(height, seed), x, y - 1, z, biomeProvider))) {
|
||||||
y--;
|
y--;
|
||||||
}
|
}
|
||||||
return y;
|
return y;
|
||||||
@@ -198,8 +200,9 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
@Override
|
@Override
|
||||||
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView height) {
|
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView height) {
|
||||||
BlockState[] array = new BlockState[height.getHeight()];
|
BlockState[] array = new BlockState[height.getHeight()];
|
||||||
|
BiomeProvider biomeProvider = pack.getBiomeProvider().caching();
|
||||||
for(int y = height.getTopY() - 1; y >= height.getBottomY(); y--) {
|
for(int y = height.getTopY() - 1; y >= height.getBottomY(); y--) {
|
||||||
array[y - height.getBottomY()] = (BlockState) delegate.getBlock(FabricAdapter.adapt(height, seed), x, y, z);
|
array[y - height.getBottomY()] = (BlockState) delegate.getBlock(FabricAdapter.adapt(height, seed), x, y, z, biomeProvider);
|
||||||
}
|
}
|
||||||
return new VerticalBlockSample(height.getBottomY(), array);
|
return new VerticalBlockSample(height.getBottomY(), array);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user