From 512a03e027911d7f50ea1beeaf16788b1a52dc03 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Wed, 15 Jan 2014 10:49:50 +1100 Subject: [PATCH] You can now only spawn on beaches (configurable) --- .../configuration/BOPConfigurationMisc.java | 8 ++++-- .../biomesoplenty/common/core/BOPBiomes.java | 21 +++++++++++----- .../common/world/WorldChunkManagerBOP.java | 25 +++++++++++++++++++ .../common/world/WorldProviderSurfaceBOP.java | 17 +++++++++++++ .../common/world/WorldTypeBOP.java | 15 +++++++++++ 5 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java create mode 100644 src/main/java/biomesoplenty/common/world/WorldProviderSurfaceBOP.java diff --git a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMisc.java b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMisc.java index ee22420bd..89ab39aaa 100644 --- a/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMisc.java +++ b/src/main/java/biomesoplenty/common/configuration/BOPConfigurationMisc.java @@ -16,7 +16,6 @@ public class BOPConfigurationMisc public static boolean skyColors; public static boolean achievements; public static boolean dungeonLoot; - public static boolean rainCreatesPuddles; public static boolean amethystTools; public static boolean mudTools; @@ -29,6 +28,9 @@ public class BOPConfigurationMisc public static int promisedLandSkyColor; + public static int spawnSearchRadius; + public static boolean onlySpawnOnBeaches; + public static void init(File configFile) { config = new Configuration(configFile); @@ -39,7 +41,6 @@ public class BOPConfigurationMisc achievements = config.get("Miscellanious Settings", "Add Biomes O\' Plenty Achievements", true).getBoolean(false); dungeonLoot = config.get("Miscellanious Settings", "Add Custom Dungeon Loot", true).getBoolean(false); - rainCreatesPuddles = config.get("Miscellanious Settings", "Enable Puddles During Rain", true).getBoolean(true); hotSpringsRegeneration = config.get("Miscellanious Settings", "Enable Spring Water Regeneration Effect", true).getBoolean(true); amethystTools = config.get("Crafting Settings", "Enable Amethyst Tool/Armor Crafting", true).getBoolean(true); @@ -52,6 +53,9 @@ public class BOPConfigurationMisc //Hard-Coded Colors skyColors = config.get("Hard-Coded Colors", "Enable Sky Colors", true).getBoolean(false); + + spawnSearchRadius = config.get("Spawn Settings", "Spawn Location Search Radius", 1024, "Must be 256 or higher").getInt(); + onlySpawnOnBeaches = config.get("Spawn Settings", "Only Spawn On Beaches", true).getBoolean(true); promisedLandSkyColor = config.get("Hard-Coded Colors", "Promised Land Sky Color", 5883101, null).getInt(); diff --git a/src/main/java/biomesoplenty/common/core/BOPBiomes.java b/src/main/java/biomesoplenty/common/core/BOPBiomes.java index 7f8eea586..6a72edfc4 100644 --- a/src/main/java/biomesoplenty/common/core/BOPBiomes.java +++ b/src/main/java/biomesoplenty/common/core/BOPBiomes.java @@ -71,6 +71,7 @@ import biomesoplenty.common.biomes.BiomeGenWasteland; import biomesoplenty.common.biomes.BiomeGenWetland; import biomesoplenty.common.biomes.BiomeGenWoodland; import biomesoplenty.common.configuration.BOPConfigurationIDs; +import biomesoplenty.common.configuration.BOPConfigurationMisc; import biomesoplenty.common.world.WorldTypeBOP; public class BOPBiomes @@ -172,14 +173,22 @@ public class BOPBiomes registerBiome(new BOPBiomeListEntry(new BiomeGenWetland(BOPConfigurationIDs.wetlandID).setBiomeName("Wetland"), BOPBiomeTemperatureType.WARM)); registerBiome(new BOPBiomeListEntry(new BiomeGenWoodland(BOPConfigurationIDs.woodlandID).setBiomeName("Woodland"), BOPBiomeTemperatureType.WARM)); } - + private static void addSpawnBiomes() { - //TODO: Spawn only on beaches. - - clearAllSpawnBiomes(); - - addSpawnBiome(BiomeGenBase.beach); + if (BOPConfigurationMisc.onlySpawnOnBeaches) + { + clearAllSpawnBiomes(); + + addSpawnBiome(BiomeGenBase.beach); + } + else + { + for (BiomeGenBase biome : BOPBiomeHelper.biomeList.values()) + { + addSpawnBiome(biome); + } + } } public static void registerOnlyBiome(BOPBiomeListEntry biome) diff --git a/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java b/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java new file mode 100644 index 000000000..97fd7703e --- /dev/null +++ b/src/main/java/biomesoplenty/common/world/WorldChunkManagerBOP.java @@ -0,0 +1,25 @@ +package biomesoplenty.common.world; + +import java.util.List; +import java.util.Random; + +import biomesoplenty.common.configuration.BOPConfigurationMisc; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.WorldChunkManager; + +public class WorldChunkManagerBOP extends WorldChunkManager +{ + public WorldChunkManagerBOP(World world) + { + super(world); + } + + @Override + public ChunkPosition func_150795_a(int x, int z, int radius, List biomesToSpawnIn, Random random) + { + int spawnSearchRadius = BOPConfigurationMisc.spawnSearchRadius >= 256 ? BOPConfigurationMisc.spawnSearchRadius : 256; + + return super.func_150795_a(x, z, spawnSearchRadius, biomesToSpawnIn, random); + } +} diff --git a/src/main/java/biomesoplenty/common/world/WorldProviderSurfaceBOP.java b/src/main/java/biomesoplenty/common/world/WorldProviderSurfaceBOP.java new file mode 100644 index 000000000..bbc921f58 --- /dev/null +++ b/src/main/java/biomesoplenty/common/world/WorldProviderSurfaceBOP.java @@ -0,0 +1,17 @@ +package biomesoplenty.common.world; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.WorldProviderSurface; + +public class WorldProviderSurfaceBOP extends WorldProviderSurface +{ + @Override + public boolean canCoordinateBeSpawn(int x, int z) + { + //TODO: getTopBlock() + Block topBlock = this.worldObj.func_147474_b(x, z); + + return topBlock == Blocks.sand && this.worldChunkMgr.getBiomesToSpawnIn().contains(this.worldObj.getBiomeGenForCoordsBody(x, z)); + } +} diff --git a/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java b/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java index 384f67d21..3f1d7c990 100644 --- a/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java +++ b/src/main/java/biomesoplenty/common/world/WorldTypeBOP.java @@ -1,15 +1,24 @@ package biomesoplenty.common.world; +import net.minecraft.world.World; import net.minecraft.world.WorldType; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.biome.WorldChunkManagerHell; +import net.minecraft.world.gen.FlatGeneratorInfo; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.GenLayerBiomeEdge; import net.minecraft.world.gen.layer.GenLayerZoom; +import net.minecraftforge.common.DimensionManager; public class WorldTypeBOP extends WorldType { public WorldTypeBOP() { super("BIOMESOP"); + + DimensionManager.unregisterProviderType(0); + DimensionManager.registerProviderType(0, WorldProviderSurfaceBOP.class, true); } @Override @@ -20,4 +29,10 @@ public class WorldTypeBOP extends WorldType ret = new GenLayerBiomeEdge(1000L, ret); return ret; } + + @Override + public WorldChunkManager getChunkManager(World world) + { + return new WorldChunkManagerBOP(world); + } }