You can now only spawn on beaches (configurable)

This commit is contained in:
Adubbz 2014-01-15 10:49:50 +11:00
parent ae45fee974
commit 512a03e027
5 changed files with 78 additions and 8 deletions

View File

@ -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();

View File

@ -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)

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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);
}
}