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 protected List field_82914_M;
094
095 /** Set to true if snow is enabled for this biome. */
096 private boolean enableSnow;
097
098 /**
099 * Is true (default) if the biome support rain (desert and nether can't have rain)
100 */
101 private boolean enableRain;
102
103 /** The id number to this biome, and its index in the biomeList array. */
104 public final int biomeID;
105
106 /** The tree generator. */
107 protected WorldGenTrees worldGeneratorTrees;
108
109 /** The big tree generator. */
110 protected WorldGenBigTree worldGeneratorBigTree;
111
112 /** The forest generator. */
113 protected WorldGenForest worldGeneratorForest;
114
115 /** The swamp tree generator. */
116 protected WorldGenSwamp worldGeneratorSwamp;
117
118 protected BiomeGenBase(int par1)
119 {
120 this.topBlock = (byte)Block.grass.blockID;
121 this.fillerBlock = (byte)Block.dirt.blockID;
122 this.field_76754_C = 5169201;
123 this.minHeight = 0.1F;
124 this.maxHeight = 0.3F;
125 this.temperature = 0.5F;
126 this.rainfall = 0.5F;
127 this.waterColorMultiplier = 16777215;
128 this.spawnableMonsterList = new ArrayList();
129 this.spawnableCreatureList = new ArrayList();
130 this.spawnableWaterCreatureList = new ArrayList();
131 this.field_82914_M = new ArrayList();
132 this.enableRain = true;
133 this.worldGeneratorTrees = new WorldGenTrees(false);
134 this.worldGeneratorBigTree = new WorldGenBigTree(false);
135 this.worldGeneratorForest = new WorldGenForest(false);
136 this.worldGeneratorSwamp = new WorldGenSwamp();
137 this.biomeID = par1;
138 biomeList[par1] = this;
139 this.theBiomeDecorator = this.createBiomeDecorator();
140 this.spawnableCreatureList.add(new SpawnListEntry(EntitySheep.class, 12, 4, 4));
141 this.spawnableCreatureList.add(new SpawnListEntry(EntityPig.class, 10, 4, 4));
142 this.spawnableCreatureList.add(new SpawnListEntry(EntityChicken.class, 10, 4, 4));
143 this.spawnableCreatureList.add(new SpawnListEntry(EntityCow.class, 8, 4, 4));
144 this.spawnableMonsterList.add(new SpawnListEntry(EntitySpider.class, 10, 4, 4));
145 this.spawnableMonsterList.add(new SpawnListEntry(EntityZombie.class, 10, 4, 4));
146 this.spawnableMonsterList.add(new SpawnListEntry(EntitySkeleton.class, 10, 4, 4));
147 this.spawnableMonsterList.add(new SpawnListEntry(EntityCreeper.class, 10, 4, 4));
148 this.spawnableMonsterList.add(new SpawnListEntry(EntitySlime.class, 10, 4, 4));
149 this.spawnableMonsterList.add(new SpawnListEntry(EntityEnderman.class, 1, 1, 4));
150 this.spawnableWaterCreatureList.add(new SpawnListEntry(EntitySquid.class, 10, 4, 4));
151 this.field_82914_M.add(new SpawnListEntry(EntityBat.class, 10, 8, 8));
152 }
153
154 /**
155 * Allocate a new BiomeDecorator for this BiomeGenBase
156 */
157 protected BiomeDecorator createBiomeDecorator()
158 {
159 return new BiomeDecorator(this);
160 }
161
162 /**
163 * Sets the temperature and rainfall of this biome.
164 */
165 private BiomeGenBase setTemperatureRainfall(float par1, float par2)
166 {
167 if (par1 > 0.1F && par1 < 0.2F)
168 {
169 throw new IllegalArgumentException("Please avoid temperatures in the range 0.1 - 0.2 because of snow");
170 }
171 else
172 {
173 this.temperature = par1;
174 this.rainfall = par2;
175 return this;
176 }
177 }
178
179 /**
180 * Sets the minimum and maximum height of this biome. Seems to go from -2.0 to 2.0.
181 */
182 private BiomeGenBase setMinMaxHeight(float par1, float par2)
183 {
184 this.minHeight = par1;
185 this.maxHeight = par2;
186 return this;
187 }
188
189 /**
190 * Disable the rain for the biome.
191 */
192 private BiomeGenBase setDisableRain()
193 {
194 this.enableRain = false;
195 return this;
196 }
197
198 /**
199 * Gets a WorldGen appropriate for this biome.
200 */
201 public WorldGenerator getRandomWorldGenForTrees(Random par1Random)
202 {
203 return (WorldGenerator)(par1Random.nextInt(10) == 0 ? this.worldGeneratorBigTree : this.worldGeneratorTrees);
204 }
205
206 /**
207 * Gets a WorldGen appropriate for this biome.
208 */
209 public WorldGenerator getRandomWorldGenForGrass(Random par1Random)
210 {
211 return new WorldGenTallGrass(Block.tallGrass.blockID, 1);
212 }
213
214 /**
215 * sets enableSnow to true during biome initialization. returns BiomeGenBase.
216 */
217 protected BiomeGenBase setEnableSnow()
218 {
219 this.enableSnow = true;
220 return this;
221 }
222
223 protected BiomeGenBase setBiomeName(String par1Str)
224 {
225 this.biomeName = par1Str;
226 return this;
227 }
228
229 protected BiomeGenBase func_76733_a(int par1)
230 {
231 this.field_76754_C = par1;
232 return this;
233 }
234
235 protected BiomeGenBase setColor(int par1)
236 {
237 this.color = par1;
238 return this;
239 }
240
241 @SideOnly(Side.CLIENT)
242
243 /**
244 * takes temperature, returns color
245 */
246 public int getSkyColorByTemp(float par1)
247 {
248 par1 /= 3.0F;
249
250 if (par1 < -1.0F)
251 {
252 par1 = -1.0F;
253 }
254
255 if (par1 > 1.0F)
256 {
257 par1 = 1.0F;
258 }
259
260 return Color.getHSBColor(0.62222224F - par1 * 0.05F, 0.5F + par1 * 0.1F, 1.0F).getRGB();
261 }
262
263 /**
264 * Returns the correspondent list of the EnumCreatureType informed.
265 */
266 public List getSpawnableList(EnumCreatureType par1EnumCreatureType)
267 {
268 return par1EnumCreatureType == EnumCreatureType.monster ? this.spawnableMonsterList : (par1EnumCreatureType == EnumCreatureType.creature ? this.spawnableCreatureList : (par1EnumCreatureType == EnumCreatureType.waterCreature ? this.spawnableWaterCreatureList : (par1EnumCreatureType == EnumCreatureType.ambient ? this.field_82914_M : null)));
269 }
270
271 /**
272 * Returns true if the biome have snowfall instead a normal rain.
273 */
274 public boolean getEnableSnow()
275 {
276 return this.enableSnow;
277 }
278
279 /**
280 * Return true if the biome supports lightning bolt spawn, either by have the bolts enabled and have rain enabled.
281 */
282 public boolean canSpawnLightningBolt()
283 {
284 return this.enableSnow ? false : this.enableRain;
285 }
286
287 /**
288 * Checks to see if the rainfall level of the biome is extremely high
289 */
290 public boolean isHighHumidity()
291 {
292 return this.rainfall > 0.85F;
293 }
294
295 /**
296 * returns the chance a creature has to spawn.
297 */
298 public float getSpawningChance()
299 {
300 return 0.1F;
301 }
302
303 /**
304 * Gets an integer representation of this biome's rainfall
305 */
306 public final int getIntRainfall()
307 {
308 return (int)(this.rainfall * 65536.0F);
309 }
310
311 /**
312 * Gets an integer representation of this biome's temperature
313 */
314 public final int getIntTemperature()
315 {
316 return (int)(this.temperature * 65536.0F);
317 }
318
319 @SideOnly(Side.CLIENT)
320
321 /**
322 * Gets a floating point representation of this biome's rainfall
323 */
324 public final float getFloatRainfall()
325 {
326 return this.rainfall;
327 }
328
329 /**
330 * Gets a floating point representation of this biome's temperature
331 */
332 public final float getFloatTemperature()
333 {
334 return this.temperature;
335 }
336
337 public void decorate(World par1World, Random par2Random, int par3, int par4)
338 {
339 this.theBiomeDecorator.decorate(par1World, par2Random, par3, par4);
340 }
341
342 @SideOnly(Side.CLIENT)
343
344 /**
345 * Provides the basic grass color based on the biome temperature and rainfall
346 */
347 public int getBiomeGrassColor()
348 {
349 double var1 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F);
350 double var3 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
351 return ColorizerGrass.getGrassColor(var1, var3);
352 }
353
354 @SideOnly(Side.CLIENT)
355
356 /**
357 * Provides the basic foliage color based on the biome temperature and rainfall
358 */
359 public int getBiomeFoliageColor()
360 {
361 double var1 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F);
362 double var3 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
363 return ColorizerFoliage.getFoliageColor(var1, var3);
364 }
365 }