From 8d2976992a2192e60c214beef88b729235b984e2 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sun, 3 Jan 2016 21:53:43 +1100 Subject: [PATCH] Prevented villages from spawning in the Jade Cliffs and Highland --- .../biome/overworld/BiomeGenHighland.java | 2 + .../biome/overworld/BiomeGenJadeCliffs.java | 2 + .../common/world/WorldChunkManagerBOP.java | 41 +++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenHighland.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenHighland.java index 84d3a9531..5d6ae669c 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenHighland.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenHighland.java @@ -35,6 +35,8 @@ public class BiomeGenHighland extends BOPBiome this.setColor(0x7CAD66); this.setTemperatureRainfall(0.5F, 0.8F); + this.canGenerateVillages = false; + this.addWeight(BOPClimates.COOL_TEMPERATE, 7); // other plants diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenJadeCliffs.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenJadeCliffs.java index 8c0bb1d52..e7b0ae162 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenJadeCliffs.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenJadeCliffs.java @@ -40,6 +40,8 @@ public class BiomeGenJadeCliffs extends BOPBiome this.skyColor = 0xB7CCAD; this.setTemperatureRainfall(0.8F, 0.9F); + this.canGenerateVillages = false; + this.addWeight(BOPClimates.WET_TEMPERATE, 3); this.addGenerator("limestone_patches", GeneratorStage.SAND, (new GeneratorSplotches.Builder()).amountPerChunk(26).splotchSize(25).replace(Blocks.stone).with(BOPBlocks.stone.getDefaultState().withProperty(BlockBOPStone.VARIANT, BlockBOPStone.StoneType.LIMESTONE)).create()); diff --git a/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java b/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java index a1e602b95..e1315920c 100644 --- a/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java +++ b/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java @@ -271,4 +271,45 @@ public class WorldChunkManagerBOP extends WorldChunkManager return new GenLayer[] {riverMixFinal, biomesFinal, riverMixFinal}; } + + @Override + public boolean areBiomesViable(int x, int z, int radius, List allowedBiomes) + { + IntCache.resetIntCache(); + int minX = x - (radius >> 2); + int minY = z - (radius >> 2); + int maxX = x + (radius >> 2); + int maxY = z + (radius >> 2); + + int areaWidth = maxX - minX + 1; //Find difference between the min and the max X. Add 1 as the result cannot be 0 + int areaHeight = maxY - minY + 1; //Find difference between the min and the max Y. Add 1 as the result cannot be 0 + int[] biomeIds = this.genBiomes.getInts(minX, minY, areaWidth, areaHeight); //Create an array of the biome ids within the desired area + + try + { + //Ensure entire area contains only desired biomes + for (int index = 0; index < areaWidth * areaHeight; ++index) + { + BiomeGenBase biomegenbase = BiomeGenBase.getBiome(biomeIds[index]); + + if (!allowedBiomes.contains(biomegenbase)) + { + return false; //Stop checking, we have found an undesirable biome + } + } + + return true; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer"); + crashreportcategory.addCrashSection("Layer", this.genBiomes.toString()); + crashreportcategory.addCrashSection("x", Integer.valueOf(x)); + crashreportcategory.addCrashSection("z", Integer.valueOf(z)); + crashreportcategory.addCrashSection("radius", Integer.valueOf(radius)); + crashreportcategory.addCrashSection("allowed", allowedBiomes); + throw new ReportedException(crashreport); + } + } }