From 68061d64b839a7e91ce8a04c03d6e8f5f8db8923 Mon Sep 17 00:00:00 2001 From: BONNe Date: Fri, 1 Feb 2019 00:08:42 +0200 Subject: [PATCH] Fix issue when some blocks were generated outside world bounds if first position was on top or bottom block. --- .../generators/populators/EntitiesPopulator.java | 4 ++-- .../generators/populators/MaterialPopulator.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/world/bentobox/caveblock/generators/populators/EntitiesPopulator.java b/src/main/java/world/bentobox/caveblock/generators/populators/EntitiesPopulator.java index e8da544..2a8db24 100644 --- a/src/main/java/world/bentobox/caveblock/generators/populators/EntitiesPopulator.java +++ b/src/main/java/world/bentobox/caveblock/generators/populators/EntitiesPopulator.java @@ -64,7 +64,7 @@ public class EntitiesPopulator extends BlockPopulator for (Map.Entry> entry : entityChanceMap.entrySet()) { - for (int subY = 1; subY < worldHeight; subY += 16) + for (int subY = 0; subY < worldHeight; subY += 16) { for (int tries = 0; tries < generationTry; tries++) { @@ -72,7 +72,7 @@ public class EntitiesPopulator extends BlockPopulator { int x = random.nextInt(15); int z = random.nextInt(15); - int y = subY + random.nextInt(15); + int y = Math.min(worldHeight - 2, subY + random.nextInt(15)); this.tryToPlaceEntity(world, chunk.getBlock(x, y, z), entry.getKey(), x, z, mainMaterial); } diff --git a/src/main/java/world/bentobox/caveblock/generators/populators/MaterialPopulator.java b/src/main/java/world/bentobox/caveblock/generators/populators/MaterialPopulator.java index 179f003..b0b26ee 100644 --- a/src/main/java/world/bentobox/caveblock/generators/populators/MaterialPopulator.java +++ b/src/main/java/world/bentobox/caveblock/generators/populators/MaterialPopulator.java @@ -66,7 +66,7 @@ public class MaterialPopulator extends BlockPopulator for (Map.Entry> entry : materialChanceMap.entrySet()) { - for (int subY = 1; subY < worldHeight; subY += 16) + for (int subY = 0; subY < worldHeight; subY += 16) { for (int tries = 0; tries < generationTry; tries++) { @@ -74,7 +74,7 @@ public class MaterialPopulator extends BlockPopulator { int x = random.nextInt(15); int z = random.nextInt(15); - int y = subY + random.nextInt(16); + int y = Math.min(worldHeight - 2, subY + random.nextInt(15)); Block block = chunk.getBlock(x, y, z); @@ -100,7 +100,7 @@ public class MaterialPopulator extends BlockPopulator x = Math.min(15, x + 1); break; case 1: - y = Math.min(worldHeight - 1, y + 1); + y = Math.min(worldHeight - 2, y + 1); break; case 2: z = Math.min(15, z + 1); @@ -109,7 +109,7 @@ public class MaterialPopulator extends BlockPopulator x = Math.max(0, x - 1); break; case 4: - y = Math.max(0, y - 1); + y = Math.max(1, y - 1); break; case 5: z = Math.max(0, z - 1);