mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 23:01:03 +00:00
fix getHeight
This commit is contained in:
+11
-8
@@ -11,9 +11,11 @@ import com.dfsek.terra.fabric.TerraFabricPlugin;
|
|||||||
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;
|
||||||
|
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
||||||
import com.dfsek.terra.world.population.items.TerraStructure;
|
import com.dfsek.terra.world.population.items.TerraStructure;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import net.jafama.FastMath;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
@@ -30,6 +32,7 @@ import net.minecraft.world.WorldAccess;
|
|||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.biome.source.BiomeAccess;
|
import net.minecraft.world.biome.source.BiomeAccess;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraft.world.gen.ChunkRandom;
|
import net.minecraft.world.gen.ChunkRandom;
|
||||||
import net.minecraft.world.gen.GenerationStep;
|
import net.minecraft.world.gen.GenerationStep;
|
||||||
import net.minecraft.world.gen.StructureAccessor;
|
import net.minecraft.world.gen.StructureAccessor;
|
||||||
@@ -56,6 +59,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
PACK_CODEC.fieldOf("pack").stable().forGetter(generator -> generator.pack))
|
PACK_CODEC.fieldOf("pack").stable().forGetter(generator -> generator.pack))
|
||||||
.apply(instance, instance.stable(FabricChunkGeneratorWrapper::new)));
|
.apply(instance, instance.stable(FabricChunkGeneratorWrapper::new)));
|
||||||
private final ConfigPack pack;
|
private final ConfigPack pack;
|
||||||
|
private DimensionType dimensionType;
|
||||||
|
|
||||||
public ConfigPack getPack() {
|
public ConfigPack getPack() {
|
||||||
return pack;
|
return pack;
|
||||||
@@ -88,6 +92,10 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDimensionType(DimensionType dimensionType) {
|
||||||
|
this.dimensionType = dimensionType;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockPos locateStructure(ServerWorld world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks) {
|
public BlockPos locateStructure(ServerWorld world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks) {
|
||||||
@@ -135,22 +143,17 @@ 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(seed);
|
|
||||||
Sampler sampler = world.getConfig().getSamplerCache().getChunk(FastMath.floorDiv(x, 16), FastMath.floorDiv(z, 16));
|
Sampler sampler = world.getConfig().getSamplerCache().getChunk(FastMath.floorDiv(x, 16), FastMath.floorDiv(z, 16));
|
||||||
int cx = FastMath.floorMod(x, 16);
|
int cx = FastMath.floorMod(x, 16);
|
||||||
int cz = FastMath.floorMod(z, 16);
|
int cz = FastMath.floorMod(z, 16);
|
||||||
|
|
||||||
int height = world.getWorld().getMaxHeight();
|
int height = world.getWorld().getMaxHeight();
|
||||||
|
|
||||||
while (height >= 0 && sampler.sample(cx, height - 1, cz) < 0) {
|
do height--;
|
||||||
height--;
|
while(height >= 0 && sampler.sample(cx, height, cz) < 0);
|
||||||
}
|
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public abstract class ServerWorldMixin {
|
|||||||
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey<World> registryKey, DimensionType dimensionType, WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<Spawner> list, boolean bl, CallbackInfo ci) {
|
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey<World> registryKey, DimensionType dimensionType, WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long l, List<Spawner> list, boolean bl, CallbackInfo ci) {
|
||||||
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
||||||
TerraFabricPlugin.getInstance().getWorldMap().put(dimensionType, Pair.of((ServerWorld) (Object) this, new TerraWorld((com.dfsek.terra.api.platform.world.World) this, ((FabricChunkGeneratorWrapper) chunkGenerator).getPack(), TerraFabricPlugin.getInstance())));
|
TerraFabricPlugin.getInstance().getWorldMap().put(dimensionType, Pair.of((ServerWorld) (Object) this, new TerraWorld((com.dfsek.terra.api.platform.world.World) this, ((FabricChunkGeneratorWrapper) chunkGenerator).getPack(), TerraFabricPlugin.getInstance())));
|
||||||
|
((FabricChunkGeneratorWrapper) chunkGenerator).setDimensionType(dimensionType);
|
||||||
TerraFabricPlugin.getInstance().logger().info("Registered world " + this + " to dimension type " + dimensionType);
|
TerraFabricPlugin.getInstance().logger().info("Registered world " + this + " to dimension type " + dimensionType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user