From 7c2fc86c722ab5be8258eaca5d6b7478830da3b7 Mon Sep 17 00:00:00 2001 From: srs-bsns Date: Sun, 12 Nov 2017 04:49:34 -0500 Subject: [PATCH] Override for #getBiomesForGeneration, fixes #1070 This adds an override for `BiomeProvider#getBiomesForGeneration` to `BiomeProviderBOPHell` that defaults to `Biomes.HELL` instead of `Biomes.DEFAULT` (ocean) if a chunk's biome array contains -1. Signed-off-by: srs-bsns --- .../common/world/BiomeProviderBOPHell.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/main/java/biomesoplenty/common/world/BiomeProviderBOPHell.java b/src/main/java/biomesoplenty/common/world/BiomeProviderBOPHell.java index c77500da1..82da5c6cd 100644 --- a/src/main/java/biomesoplenty/common/world/BiomeProviderBOPHell.java +++ b/src/main/java/biomesoplenty/common/world/BiomeProviderBOPHell.java @@ -8,13 +8,19 @@ package biomesoplenty.common.world; import biomesoplenty.common.world.layer.*; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.init.Biomes; +import net.minecraft.util.ReportedException; import net.minecraft.world.World; import net.minecraft.world.WorldType; +import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeProvider; import net.minecraft.world.gen.layer.*; public class BiomeProviderBOPHell extends BiomeProvider { + public BiomeProviderBOPHell(long seed, WorldType worldType, String chunkProviderSettings) { super(); @@ -32,6 +38,40 @@ public class BiomeProviderBOPHell extends BiomeProvider this.biomeIndexLayer = genlayers[1]; } + @Override + public Biome[] getBiomesForGeneration(Biome[] biomes, int x, int z, int width, int height) + { + IntCache.resetIntCache(); + + if (biomes == null || biomes.length < width * height) + { + biomes = new Biome[width * height]; + } + + int[] aint = this.genBiomes.getInts(x, z, width, height); + + try + { + for (int i = 0; i < width * height; ++i) + { + biomes[i] = Biome.getBiome(aint[i], Biomes.HELL); + } + + return biomes; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("RawBiomeBlock"); + crashreportcategory.addCrashSection("biomes[] size", biomes.length); + crashreportcategory.addCrashSection("x", x); + crashreportcategory.addCrashSection("z", z); + crashreportcategory.addCrashSection("w", width); + crashreportcategory.addCrashSection("h", height); + throw new ReportedException(crashreport); + } + } + public BiomeProviderBOPHell(World world) { this(world.getSeed(), world.getWorldInfo().getTerrainType(), world.getWorldInfo().getGeneratorOptions());