001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 import java.awt.Color; 006 import java.util.ArrayList; 007 import java.util.List; 008 import java.util.Random; 009 010 public abstract class BiomeGenBase 011 { 012 /** An array of all the biomes, indexed by biome id. */ 013 public static final BiomeGenBase[] biomeList = new BiomeGenBase[256]; 014 public static final BiomeGenBase ocean = (new BiomeGenOcean(0)).setColor(112).setBiomeName("Ocean").setMinMaxHeight(-1.0F, 0.4F); 015 public static final BiomeGenBase plains = (new BiomeGenPlains(1)).setColor(9286496).setBiomeName("Plains").setTemperatureRainfall(0.8F, 0.4F); 016 public static final BiomeGenBase desert = (new BiomeGenDesert(2)).setColor(16421912).setBiomeName("Desert").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setMinMaxHeight(0.1F, 0.2F); 017 public static final BiomeGenBase extremeHills = (new BiomeGenHills(3)).setColor(6316128).setBiomeName("Extreme Hills").setMinMaxHeight(0.3F, 1.5F).setTemperatureRainfall(0.2F, 0.3F); 018 public static final BiomeGenBase forest = (new BiomeGenForest(4)).setColor(353825).setBiomeName("Forest").func_76733_a(5159473).setTemperatureRainfall(0.7F, 0.8F); 019 public static final BiomeGenBase taiga = (new BiomeGenTaiga(5)).setColor(747097).setBiomeName("Taiga").func_76733_a(5159473).setEnableSnow().setTemperatureRainfall(0.05F, 0.8F).setMinMaxHeight(0.1F, 0.4F); 020 public static final BiomeGenBase swampland = (new BiomeGenSwamp(6)).setColor(522674).setBiomeName("Swampland").func_76733_a(9154376).setMinMaxHeight(-0.2F, 0.1F).setTemperatureRainfall(0.8F, 0.9F); 021 public static final BiomeGenBase river = (new BiomeGenRiver(7)).setColor(255).setBiomeName("River").setMinMaxHeight(-0.5F, 0.0F); 022 public static final BiomeGenBase hell = (new BiomeGenHell(8)).setColor(16711680).setBiomeName("Hell").setDisableRain().setTemperatureRainfall(2.0F, 0.0F); 023 024 /** Is the biome used for sky world. */ 025 public static final BiomeGenBase sky = (new BiomeGenEnd(9)).setColor(8421631).setBiomeName("Sky").setDisableRain(); 026 public static final BiomeGenBase frozenOcean = (new BiomeGenOcean(10)).setColor(9474208).setBiomeName("FrozenOcean").setEnableSnow().setMinMaxHeight(-1.0F, 0.5F).setTemperatureRainfall(0.0F, 0.5F); 027 public static final BiomeGenBase frozenRiver = (new BiomeGenRiver(11)).setColor(10526975).setBiomeName("FrozenRiver").setEnableSnow().setMinMaxHeight(-0.5F, 0.0F).setTemperatureRainfall(0.0F, 0.5F); 028 public static final BiomeGenBase icePlains = (new BiomeGenSnow(12)).setColor(16777215).setBiomeName("Ice Plains").setEnableSnow().setTemperatureRainfall(0.0F, 0.5F); 029 public static final BiomeGenBase iceMountains = (new BiomeGenSnow(13)).setColor(10526880).setBiomeName("Ice Mountains").setEnableSnow().setMinMaxHeight(0.3F, 1.3F).setTemperatureRainfall(0.0F, 0.5F); 030 public static final BiomeGenBase mushroomIsland = (new BiomeGenMushroomIsland(14)).setColor(16711935).setBiomeName("MushroomIsland").setTemperatureRainfall(0.9F, 1.0F).setMinMaxHeight(0.2F, 1.0F); 031 public static final BiomeGenBase mushroomIslandShore = (new BiomeGenMushroomIsland(15)).setColor(10486015).setBiomeName("MushroomIslandShore").setTemperatureRainfall(0.9F, 1.0F).setMinMaxHeight(-1.0F, 0.1F); 032 033 /** Beach biome. */ 034 public static final BiomeGenBase beach = (new BiomeGenBeach(16)).setColor(16440917).setBiomeName("Beach").setTemperatureRainfall(0.8F, 0.4F).setMinMaxHeight(0.0F, 0.1F); 035 036 /** Desert Hills biome. */ 037 public static final BiomeGenBase desertHills = (new BiomeGenDesert(17)).setColor(13786898).setBiomeName("DesertHills").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setMinMaxHeight(0.3F, 0.8F); 038 039 /** Forest Hills biome. */ 040 public static final BiomeGenBase forestHills = (new BiomeGenForest(18)).setColor(2250012).setBiomeName("ForestHills").func_76733_a(5159473).setTemperatureRainfall(0.7F, 0.8F).setMinMaxHeight(0.3F, 0.7F); 041 042 /** Taiga Hills biome. */ 043 public static final BiomeGenBase taigaHills = (new BiomeGenTaiga(19)).setColor(1456435).setBiomeName("TaigaHills").setEnableSnow().func_76733_a(5159473).setTemperatureRainfall(0.05F, 0.8F).setMinMaxHeight(0.3F, 0.8F); 044 045 /** Extreme Hills Edge biome. */ 046 public static final BiomeGenBase extremeHillsEdge = (new BiomeGenHills(20)).setColor(7501978).setBiomeName("Extreme Hills Edge").setMinMaxHeight(0.2F, 0.8F).setTemperatureRainfall(0.2F, 0.3F); 047 048 /** Jungle biome identifier */ 049 public static final BiomeGenBase jungle = (new BiomeGenJungle(21)).setColor(5470985).setBiomeName("Jungle").func_76733_a(5470985).setTemperatureRainfall(1.2F, 0.9F).setMinMaxHeight(0.2F, 0.4F); 050 public static final BiomeGenBase jungleHills = (new BiomeGenJungle(22)).setColor(2900485).setBiomeName("JungleHills").func_76733_a(5470985).setTemperatureRainfall(1.2F, 0.9F).setMinMaxHeight(1.8F, 0.5F); 051 public String biomeName; 052 public int color; 053 054 /** The block expected to be on the top of this biome */ 055 public byte topBlock; 056 057 /** The block to fill spots in when not on the top */ 058 public byte fillerBlock; 059 public int field_76754_C; 060 061 /** The minimum height of this biome. Default 0.1. */ 062 public float minHeight; 063 064 /** The maximum height of this biome. Default 0.3. */ 065 public float maxHeight; 066 067 /** The temperature of this biome. */ 068 public float temperature; 069 070 /** The rainfall in this biome. */ 071 public float rainfall; 072 073 /** Color tint applied to water depending on biome */ 074 public int waterColorMultiplier; 075 076 /** The biome decorator. */ 077 public BiomeDecorator theBiomeDecorator; 078 079 /** 080 * Holds the classes of IMobs (hostile mobs) that can be spawned in the biome. 081 */ 082 protected List spawnableMonsterList; 083 084 /** 085 * Holds the classes of any creature that can be spawned in the biome as friendly creature. 086 */ 087 protected List spawnableCreatureList; 088 089 /** 090 * Holds the classes of any aquatic creature that can be spawned in the water of the biome. 091 */ 092 protected List spawnableWaterCreatureList; 093 094 /** Set to true if snow is enabled for this biome. */ 095 private boolean enableSnow; 096 097 /** 098 * Is true (default) if the biome support rain (desert and nether can't have rain) 099 */ 100 private boolean enableRain; 101 102 /** The id number to this biome, and its index in the biomeList array. */ 103 public final int biomeID; 104 protected WorldGenTrees worldGeneratorTrees; 105 106 /** The big tree generator. */ 107 protected WorldGenBigTree worldGeneratorBigTree; 108 protected WorldGenForest worldGeneratorForest; 109 protected WorldGenSwamp worldGeneratorSwamp; 110 111 protected BiomeGenBase(int par1) 112 { 113 this.topBlock = (byte)Block.grass.blockID; 114 this.fillerBlock = (byte)Block.dirt.blockID; 115 this.field_76754_C = 5169201; 116 this.minHeight = 0.1F; 117 this.maxHeight = 0.3F; 118 this.temperature = 0.5F; 119 this.rainfall = 0.5F; 120 this.waterColorMultiplier = 16777215; 121 this.spawnableMonsterList = new ArrayList(); 122 this.spawnableCreatureList = new ArrayList(); 123 this.spawnableWaterCreatureList = new ArrayList(); 124 this.enableRain = true; 125 this.worldGeneratorTrees = new WorldGenTrees(false); 126 this.worldGeneratorBigTree = new WorldGenBigTree(false); 127 this.worldGeneratorForest = new WorldGenForest(false); 128 this.worldGeneratorSwamp = new WorldGenSwamp(); 129 this.biomeID = par1; 130 biomeList[par1] = this; 131 this.theBiomeDecorator = this.createBiomeDecorator(); 132 this.spawnableCreatureList.add(new SpawnListEntry(EntitySheep.class, 12, 4, 4)); 133 this.spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 10, 4, 4)); 134 this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 10, 4, 4)); 135 this.spawnableCreatureList.add(new SpawnListEntry(EntityCow.class, 8, 4, 4)); 136 this.spawnableMonsterList.add(new SpawnListEntry(EntitySpider.class, 10, 4, 4)); 137 this.spawnableMonsterList.add(new SpawnListEntry(EntityZombie.class, 10, 4, 4)); 138 this.spawnableMonsterList.add(new SpawnListEntry(EntitySkeleton.class, 10, 4, 4)); 139 this.spawnableMonsterList.add(new SpawnListEntry(EntityCreeper.class, 10, 4, 4)); 140 this.spawnableMonsterList.add(new SpawnListEntry(EntitySlime.class, 10, 4, 4)); 141 this.spawnableMonsterList.add(new SpawnListEntry(EntityEnderman.class, 1, 1, 4)); 142 this.spawnableWaterCreatureList.add(new SpawnListEntry(EntitySquid.class, 10, 4, 4)); 143 } 144 145 /** 146 * Allocate a new BiomeDecorator for this BiomeGenBase 147 */ 148 protected BiomeDecorator createBiomeDecorator() 149 { 150 return new BiomeDecorator(this); 151 } 152 153 /** 154 * Sets the temperature and rainfall of this biome. 155 */ 156 private BiomeGenBase setTemperatureRainfall(float par1, float par2) 157 { 158 if (par1 > 0.1F && par1 < 0.2F) 159 { 160 throw new IllegalArgumentException("Please avoid temperatures in the range 0.1 - 0.2 because of snow"); 161 } 162 else 163 { 164 this.temperature = par1; 165 this.rainfall = par2; 166 return this; 167 } 168 } 169 170 /** 171 * Sets the minimum and maximum height of this biome. Seems to go from -2.0 to 2.0. 172 */ 173 private BiomeGenBase setMinMaxHeight(float par1, float par2) 174 { 175 this.minHeight = par1; 176 this.maxHeight = par2; 177 return this; 178 } 179 180 /** 181 * Disable the rain for the biome. 182 */ 183 private BiomeGenBase setDisableRain() 184 { 185 this.enableRain = false; 186 return this; 187 } 188 189 /** 190 * Gets a WorldGen appropriate for this biome. 191 */ 192 public WorldGenerator getRandomWorldGenForTrees(Random par1Random) 193 { 194 return (WorldGenerator)(par1Random.nextInt(10) == 0 ? this.worldGeneratorBigTree : this.worldGeneratorTrees); 195 } 196 197 /** 198 * Gets a WorldGen appropriate for this biome. 199 */ 200 public WorldGenerator getRandomWorldGenForGrass(Random par1Random) 201 { 202 return new WorldGenTallGrass(Block.tallGrass.blockID, 1); 203 } 204 205 /** 206 * sets enableSnow to true during biome initialization. returns BiomeGenBase. 207 */ 208 protected BiomeGenBase setEnableSnow() 209 { 210 this.enableSnow = true; 211 return this; 212 } 213 214 protected BiomeGenBase setBiomeName(String par1Str) 215 { 216 this.biomeName = par1Str; 217 return this; 218 } 219 220 protected BiomeGenBase func_76733_a(int par1) 221 { 222 this.field_76754_C = par1; 223 return this; 224 } 225 226 protected BiomeGenBase setColor(int par1) 227 { 228 this.color = par1; 229 return this; 230 } 231 232 @SideOnly(Side.CLIENT) 233 234 /** 235 * takes temperature, returns color 236 */ 237 public int getSkyColorByTemp(float par1) 238 { 239 par1 /= 3.0F; 240 241 if (par1 < -1.0F) 242 { 243 par1 = -1.0F; 244 } 245 246 if (par1 > 1.0F) 247 { 248 par1 = 1.0F; 249 } 250 251 return Color.getHSBColor(0.62222224F - par1 * 0.05F, 0.5F + par1 * 0.1F, 1.0F).getRGB(); 252 } 253 254 /** 255 * Returns the correspondent list of the EnumCreatureType informed. 256 */ 257 public List getSpawnableList(EnumCreatureType par1EnumCreatureType) 258 { 259 return par1EnumCreatureType == EnumCreatureType.monster ? this.spawnableMonsterList : (par1EnumCreatureType == EnumCreatureType.creature ? this.spawnableCreatureList : (par1EnumCreatureType == EnumCreatureType.waterCreature ? this.spawnableWaterCreatureList : null)); 260 } 261 262 /** 263 * Returns true if the biome have snowfall instead a normal rain. 264 */ 265 public boolean getEnableSnow() 266 { 267 return this.enableSnow; 268 } 269 270 /** 271 * Return true if the biome supports lightning bolt spawn, either by have the bolts enabled and have rain enabled. 272 */ 273 public boolean canSpawnLightningBolt() 274 { 275 return this.enableSnow ? false : this.enableRain; 276 } 277 278 /** 279 * Checks to see if the rainfall level of the biome is extremely high 280 */ 281 public boolean isHighHumidity() 282 { 283 return this.rainfall > 0.85F; 284 } 285 286 /** 287 * returns the chance a creature has to spawn. 288 */ 289 public float getSpawningChance() 290 { 291 return 0.1F; 292 } 293 294 /** 295 * Gets an integer representation of this biome's rainfall 296 */ 297 public final int getIntRainfall() 298 { 299 return (int)(this.rainfall * 65536.0F); 300 } 301 302 /** 303 * Gets an integer representation of this biome's temperature 304 */ 305 public final int getIntTemperature() 306 { 307 return (int)(this.temperature * 65536.0F); 308 } 309 310 @SideOnly(Side.CLIENT) 311 312 /** 313 * Gets a floating point representation of this biome's rainfall 314 */ 315 public final float getFloatRainfall() 316 { 317 return this.rainfall; 318 } 319 320 /** 321 * Gets a floating point representation of this biome's temperature 322 */ 323 public final float getFloatTemperature() 324 { 325 return this.temperature; 326 } 327 328 public void decorate(World par1World, Random par2Random, int par3, int par4) 329 { 330 this.theBiomeDecorator.decorate(par1World, par2Random, par3, par4); 331 } 332 333 @SideOnly(Side.CLIENT) 334 335 /** 336 * Provides the basic grass color based on the biome temperature and rainfall 337 */ 338 public int getBiomeGrassColor() 339 { 340 double var1 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F); 341 double var3 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); 342 return ColorizerGrass.getGrassColor(var1, var3); 343 } 344 345 @SideOnly(Side.CLIENT) 346 347 /** 348 * Provides the basic foliage color based on the biome temperature and rainfall 349 */ 350 public int getBiomeFoliageColor() 351 { 352 double var1 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F); 353 double var3 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); 354 return ColorizerFoliage.getFoliageColor(var1, var3); 355 } 356 }