mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-19 07:11:14 +00:00
improve fabric/forge getHeight impl
This commit is contained in:
@@ -70,7 +70,7 @@ public class TerraWorld {
|
|||||||
double noise = sampler.sample(fdX, y, fdZ);
|
double noise = sampler.sample(fdX, y, fdZ);
|
||||||
if(noise > 0) {
|
if(noise > 0) {
|
||||||
int level = 0;
|
int level = 0;
|
||||||
for(int yi = world.getMaxHeight(); yi > y; yi--) {
|
for(int yi = world.getMaxHeight()-1; yi > y; yi--) {
|
||||||
if(sampler.sample(fdX, yi, fdZ) > 0) level++;
|
if(sampler.sample(fdX, yi, fdZ) > 0) level++;
|
||||||
else level = 0;
|
else level = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-7
@@ -9,6 +9,7 @@ import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
|||||||
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
|
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
|
||||||
import com.dfsek.terra.config.pack.ConfigPack;
|
import com.dfsek.terra.config.pack.ConfigPack;
|
||||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||||
|
import com.dfsek.terra.fabric.block.FabricBlockData;
|
||||||
import com.dfsek.terra.fabric.util.FabricAdapter;
|
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||||
import com.dfsek.terra.world.TerraWorld;
|
import com.dfsek.terra.world.TerraWorld;
|
||||||
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
|
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
|
||||||
@@ -145,14 +146,10 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
@Override
|
@Override
|
||||||
public int getHeight(int x, int z, Heightmap.Type heightmapType) {
|
public int getHeight(int x, int z, Heightmap.Type heightmapType) {
|
||||||
TerraWorld world = TerraFabricPlugin.getInstance().getWorld(dimensionType);
|
TerraWorld world = TerraFabricPlugin.getInstance().getWorld(dimensionType);
|
||||||
Sampler sampler = world.getConfig().getSamplerCache().getChunk(FastMath.floorDiv(x, 16), FastMath.floorDiv(z, 16));
|
|
||||||
int cx = FastMath.floorMod(x, 16);
|
|
||||||
int cz = FastMath.floorMod(z, 16);
|
|
||||||
|
|
||||||
int height = world.getWorld().getMaxHeight();
|
int height = world.getWorld().getMaxHeight();
|
||||||
|
while(height >= 0 && !heightmapType.getBlockPredicate().test(((FabricBlockData) world.getUngeneratedBlock(x, height-1, z)).getHandle())) {
|
||||||
while(height >= 0 && sampler.sample(cx, height-1, cz) < 0) height--;
|
height--;
|
||||||
|
}
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-8
@@ -10,6 +10,7 @@ import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
|
|||||||
import com.dfsek.terra.config.pack.ConfigPack;
|
import com.dfsek.terra.config.pack.ConfigPack;
|
||||||
import com.dfsek.terra.forge.ForgeAdapter;
|
import com.dfsek.terra.forge.ForgeAdapter;
|
||||||
import com.dfsek.terra.forge.TerraForgePlugin;
|
import com.dfsek.terra.forge.TerraForgePlugin;
|
||||||
|
import com.dfsek.terra.forge.block.ForgeBlockData;
|
||||||
import com.dfsek.terra.world.TerraWorld;
|
import com.dfsek.terra.world.TerraWorld;
|
||||||
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
|
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
|
||||||
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
||||||
@@ -139,16 +140,12 @@ public class ForgeChunkGeneratorWrapper extends ChunkGenerator implements Genera
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBaseHeight(int x, int z, Heightmap.@NotNull Type p_222529_3_) {
|
public int getBaseHeight(int x, int z, Heightmap.@NotNull Type type) {
|
||||||
TerraWorld world = TerraForgePlugin.getInstance().getWorld(dimensionType);
|
TerraWorld world = TerraForgePlugin.getInstance().getWorld(dimensionType);
|
||||||
Sampler sampler = world.getConfig().getSamplerCache().getChunk(FastMath.floorDiv(x, 16), FastMath.floorDiv(z, 16));
|
|
||||||
int cx = FastMath.floorMod(x, 16);
|
|
||||||
int cz = FastMath.floorMod(z, 16);
|
|
||||||
|
|
||||||
int height = world.getWorld().getMaxHeight();
|
int height = world.getWorld().getMaxHeight();
|
||||||
|
while(height >= 0 && !type.isOpaque().test(((ForgeBlockData) world.getUngeneratedBlock(x, height-1, z)).getHandle())) {
|
||||||
while(height >= 0 && sampler.sample(cx, height - 1, cz) < 0) height--;
|
height--;
|
||||||
|
}
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user