From 79b745e0055175c475a195fe493ba435c2853e64 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Tue, 17 Mar 2020 23:54:52 +0000 Subject: [PATCH] Randomise y coordinate to search from when spawning structures in 'cavern' dimensions, fixes #372 --- .../wizardry/worldgen/WorldGenSurfaceStructure.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/electroblob/wizardry/worldgen/WorldGenSurfaceStructure.java b/src/main/java/electroblob/wizardry/worldgen/WorldGenSurfaceStructure.java index 95e97840..5af256f9 100644 --- a/src/main/java/electroblob/wizardry/worldgen/WorldGenSurfaceStructure.java +++ b/src/main/java/electroblob/wizardry/worldgen/WorldGenSurfaceStructure.java @@ -144,6 +144,9 @@ public abstract class WorldGenSurfaceStructure implements IWorldGenerator { // Estimate a starting height for searching for the floor BlockPos centre = world.getTopSolidOrLiquidBlock(new BlockPos(origin.add(size.getX()/2, 0, size.getZ()/2))); + // Check if we're at the top of the world, and if so just randomise the y pos (accounts for 'cavern' dimensions) + if(centre.getY() >= world.getActualHeight()) centre = new BlockPos(centre.getX(), random.nextInt(world.getActualHeight()), centre.getZ()); + Integer startingHeight = WizardryUtilities.getNearestSurface(world, centre, EnumFacing.UP, 32, true, WizardryUtilities.SurfaceCriteria.COLLIDABLE_IGNORING_TREES);