| 1 | package net.minecraft.world.biome;
|
| 2 |
|
| 3 | import com.google.common.collect.Lists;
|
| 4 | import com.google.common.collect.Maps;
|
| 5 | import com.google.common.collect.Sets;
|
| 6 | import java.util.Collections;
|
| 7 | import java.util.List;
|
| 8 | import java.util.Map;
|
| 9 | import java.util.Random;
|
| 10 | import java.util.Set;
|
| 11 | import net.minecraft.block.BlockFlower;
|
| 12 | import net.minecraft.block.BlockSand;
|
| 13 | import net.minecraft.block.BlockTallGrass;
|
| 14 | import net.minecraft.block.material.Material;
|
| 15 | import net.minecraft.block.state.IBlockState;
|
| 16 | import net.minecraft.entity.EntityLiving;
|
| 17 | import net.minecraft.entity.EnumCreatureType;
|
| 18 | import net.minecraft.entity.monster.EntityCreeper;
|
| 19 | import net.minecraft.entity.monster.EntityEnderman;
|
| 20 | import net.minecraft.entity.monster.EntitySkeleton;
|
| 21 | import net.minecraft.entity.monster.EntitySlime;
|
| 22 | import net.minecraft.entity.monster.EntitySpider;
|
| 23 | import net.minecraft.entity.monster.EntityWitch;
|
| 24 | import net.minecraft.entity.monster.EntityZombie;
|
| 25 | import net.minecraft.entity.passive.EntityBat;
|
| 26 | import net.minecraft.entity.passive.EntityChicken;
|
| 27 | import net.minecraft.entity.passive.EntityCow;
|
| 28 | import net.minecraft.entity.passive.EntityPig;
|
| 29 | import net.minecraft.entity.passive.EntityRabbit;
|
| 30 | import net.minecraft.entity.passive.EntitySheep;
|
| 31 | import net.minecraft.entity.passive.EntitySquid;
|
| 32 | import net.minecraft.init.Blocks;
|
| 33 | import net.minecraft.util.BlockPos;
|
| 34 | import net.minecraft.util.MathHelper;
|
| 35 | import net.minecraft.util.WeightedRandom;
|
| 36 | import net.minecraft.world.ColorizerFoliage;
|
| 37 | import net.minecraft.world.ColorizerGrass;
|
| 38 | import net.minecraft.world.World;
|
| 39 | import net.minecraft.world.chunk.ChunkPrimer;
|
| 40 | import net.minecraft.world.gen.NoiseGeneratorPerlin;
|
| 41 | import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
| 42 | import net.minecraft.world.gen.feature.WorldGenBigTree;
|
| 43 | import net.minecraft.world.gen.feature.WorldGenDoublePlant;
|
| 44 | import net.minecraft.world.gen.feature.WorldGenSwamp;
|
| 45 | import net.minecraft.world.gen.feature.WorldGenTallGrass;
|
| 46 | import net.minecraft.world.gen.feature.WorldGenTrees;
|
| 47 | import net.minecraft.world.gen.feature.WorldGenerator;
|
| 48 | import org.apache.logging.log4j.LogManager;
|
| 49 | import org.apache.logging.log4j.Logger;
|
| 50 |
|
| 51 | public abstract class BiomeGenBase
|
| 52 | {
|
| 53 | private static final Logger logger = LogManager.getLogger();
|
| 54 | protected static final BiomeGenBase.Height height_Default = new BiomeGenBase.Height(0.1F, 0.2F);
|
| 55 | protected static final BiomeGenBase.Height height_ShallowWaters = new BiomeGenBase.Height(-0.5F, 0.0F);
|
| 56 | protected static final BiomeGenBase.Height height_Oceans = new BiomeGenBase.Height(-1.0F, 0.1F);
|
| 57 | protected static final BiomeGenBase.Height height_DeepOceans = new BiomeGenBase.Height(-1.8F, 0.1F);
|
| 58 | protected static final BiomeGenBase.Height height_LowPlains = new BiomeGenBase.Height(0.125F, 0.05F);
|
| 59 | protected static final BiomeGenBase.Height height_MidPlains = new BiomeGenBase.Height(0.2F, 0.2F);
|
| 60 | protected static final BiomeGenBase.Height height_LowHills = new BiomeGenBase.Height(0.45F, 0.3F);
|
| 61 | protected static final BiomeGenBase.Height height_HighPlateaus = new BiomeGenBase.Height(1.5F, 0.025F);
|
| 62 | protected static final BiomeGenBase.Height height_MidHills = new BiomeGenBase.Height(1.0F, 0.5F);
|
| 63 | protected static final BiomeGenBase.Height height_Shores = new BiomeGenBase.Height(0.0F, 0.025F);
|
| 64 | protected static final BiomeGenBase.Height height_RockyWaters = new BiomeGenBase.Height(0.1F, 0.8F);
|
| 65 | protected static final BiomeGenBase.Height height_LowIslands = new BiomeGenBase.Height(0.2F, 0.3F);
|
| 66 | protected static final BiomeGenBase.Height height_PartiallySubmerged = new BiomeGenBase.Height(-0.2F, 0.1F);
|
| 67 |
|
| 68 | /** An array of all the biomes, indexed by biome id. */
|
| 69 | private static final BiomeGenBase[] biomeList = new BiomeGenBase[256];
|
| 70 | public static final Set<BiomeGenBase> explorationBiomesList = Sets.<BiomeGenBase>newHashSet();
|
| 71 | public static final Map<String, BiomeGenBase> BIOME_ID_MAP = Maps.<String, BiomeGenBase>newHashMap();
|
| 72 | public static final BiomeGenBase ocean = (new BiomeGenOcean(0)).setColor(112).setBiomeName("Ocean").setHeight(height_Oceans);
|
| 73 | public static final BiomeGenBase plains = (new BiomeGenPlains(1)).setColor(9286496).setBiomeName("Plains");
|
| 74 | public static final BiomeGenBase desert = (new BiomeGenDesert(2)).setColor(16421912).setBiomeName("Desert").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setHeight(height_LowPlains);
|
| 75 | public static final BiomeGenBase extremeHills = (new BiomeGenHills(3, false)).setColor(6316128).setBiomeName("Extreme Hills").setHeight(height_MidHills).setTemperatureRainfall(0.2F, 0.3F);
|
| 76 | public static final BiomeGenBase forest = (new BiomeGenForest(4, 0)).setColor(353825).setBiomeName("Forest");
|
| 77 | public static final BiomeGenBase taiga = (new BiomeGenTaiga(5, 0)).setColor(747097).setBiomeName("Taiga").setFillerBlockMetadata(5159473).setTemperatureRainfall(0.25F, 0.8F).setHeight(height_MidPlains);
|
| 78 | public static final BiomeGenBase swampland = (new BiomeGenSwamp(6)).setColor(522674).setBiomeName("Swampland").setFillerBlockMetadata(9154376).setHeight(height_PartiallySubmerged).setTemperatureRainfall(0.8F, 0.9F);
|
| 79 | public static final BiomeGenBase river = (new BiomeGenRiver(7)).setColor(255).setBiomeName("River").setHeight(height_ShallowWaters);
|
| 80 | public static final BiomeGenBase hell = (new BiomeGenHell(8)).setColor(16711680).setBiomeName("Hell").setDisableRain().setTemperatureRainfall(2.0F, 0.0F);
|
| 81 |
|
| 82 | /** Is the biome used for sky world. */
|
| 83 | public static final BiomeGenBase sky = (new BiomeGenEnd(9)).setColor(8421631).setBiomeName("The End").setDisableRain();
|
| 84 | public static final BiomeGenBase frozenOcean = (new BiomeGenOcean(10)).setColor(9474208).setBiomeName("FrozenOcean").setEnableSnow().setHeight(height_Oceans).setTemperatureRainfall(0.0F, 0.5F);
|
| 85 | public static final BiomeGenBase frozenRiver = (new BiomeGenRiver(11)).setColor(10526975).setBiomeName("FrozenRiver").setEnableSnow().setHeight(height_ShallowWaters).setTemperatureRainfall(0.0F, 0.5F);
|
| 86 | public static final BiomeGenBase icePlains = (new BiomeGenSnow(12, false)).setColor(16777215).setBiomeName("Ice Plains").setEnableSnow().setTemperatureRainfall(0.0F, 0.5F).setHeight(height_LowPlains);
|
| 87 | public static final BiomeGenBase iceMountains = (new BiomeGenSnow(13, false)).setColor(10526880).setBiomeName("Ice Mountains").setEnableSnow().setHeight(height_LowHills).setTemperatureRainfall(0.0F, 0.5F);
|
| 88 | public static final BiomeGenBase mushroomIsland = (new BiomeGenMushroomIsland(14)).setColor(16711935).setBiomeName("MushroomIsland").setTemperatureRainfall(0.9F, 1.0F).setHeight(height_LowIslands);
|
| 89 | public static final BiomeGenBase mushroomIslandShore = (new BiomeGenMushroomIsland(15)).setColor(10486015).setBiomeName("MushroomIslandShore").setTemperatureRainfall(0.9F, 1.0F).setHeight(height_Shores);
|
| 90 |
|
| 91 | /** Beach biome. */
|
| 92 | public static final BiomeGenBase beach = (new BiomeGenBeach(16)).setColor(16440917).setBiomeName("Beach").setTemperatureRainfall(0.8F, 0.4F).setHeight(height_Shores);
|
| 93 |
|
| 94 | /** Desert Hills biome. */
|
| 95 | public static final BiomeGenBase desertHills = (new BiomeGenDesert(17)).setColor(13786898).setBiomeName("DesertHills").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setHeight(height_LowHills);
|
| 96 |
|
| 97 | /** Forest Hills biome. */
|
| 98 | public static final BiomeGenBase forestHills = (new BiomeGenForest(18, 0)).setColor(2250012).setBiomeName("ForestHills").setHeight(height_LowHills);
|
| 99 |
|
| 100 | /** Taiga Hills biome. */
|
| 101 | public static final BiomeGenBase taigaHills = (new BiomeGenTaiga(19, 0)).setColor(1456435).setBiomeName("TaigaHills").setFillerBlockMetadata(5159473).setTemperatureRainfall(0.25F, 0.8F).setHeight(height_LowHills);
|
| 102 |
|
| 103 | /** Extreme Hills Edge biome. */
|
| 104 | public static final BiomeGenBase extremeHillsEdge = (new BiomeGenHills(20, true)).setColor(7501978).setBiomeName("Extreme Hills Edge").setHeight(height_MidHills.attenuate()).setTemperatureRainfall(0.2F, 0.3F);
|
| 105 |
|
| 106 | /** Jungle biome identifier */
|
| 107 | public static final BiomeGenBase jungle = (new BiomeGenJungle(21, false)).setColor(5470985).setBiomeName("Jungle").setFillerBlockMetadata(5470985).setTemperatureRainfall(0.95F, 0.9F);
|
| 108 | public static final BiomeGenBase jungleHills = (new BiomeGenJungle(22, false)).setColor(2900485).setBiomeName("JungleHills").setFillerBlockMetadata(5470985).setTemperatureRainfall(0.95F, 0.9F).setHeight(height_LowHills);
|
| 109 | public static final BiomeGenBase jungleEdge = (new BiomeGenJungle(23, true)).setColor(6458135).setBiomeName("JungleEdge").setFillerBlockMetadata(5470985).setTemperatureRainfall(0.95F, 0.8F);
|
| 110 | public static final BiomeGenBase deepOcean = (new BiomeGenOcean(24)).setColor(48).setBiomeName("Deep Ocean").setHeight(height_DeepOceans);
|
| 111 | public static final BiomeGenBase stoneBeach = (new BiomeGenStoneBeach(25)).setColor(10658436).setBiomeName("Stone Beach").setTemperatureRainfall(0.2F, 0.3F).setHeight(height_RockyWaters);
|
| 112 | public static final BiomeGenBase coldBeach = (new BiomeGenBeach(26)).setColor(16445632).setBiomeName("Cold Beach").setTemperatureRainfall(0.05F, 0.3F).setHeight(height_Shores).setEnableSnow();
|
| 113 | public static final BiomeGenBase birchForest = (new BiomeGenForest(27, 2)).setBiomeName("Birch Forest").setColor(3175492);
|
| 114 | public static final BiomeGenBase birchForestHills = (new BiomeGenForest(28, 2)).setBiomeName("Birch Forest Hills").setColor(2055986).setHeight(height_LowHills);
|
| 115 | public static final BiomeGenBase roofedForest = (new BiomeGenForest(29, 3)).setColor(4215066).setBiomeName("Roofed Forest");
|
| 116 | public static final BiomeGenBase coldTaiga = (new BiomeGenTaiga(30, 0)).setColor(3233098).setBiomeName("Cold Taiga").setFillerBlockMetadata(5159473).setEnableSnow().setTemperatureRainfall(-0.5F, 0.4F).setHeight(height_MidPlains).func_150563_c(16777215);
|
| 117 | public static final BiomeGenBase coldTaigaHills = (new BiomeGenTaiga(31, 0)).setColor(2375478).setBiomeName("Cold Taiga Hills").setFillerBlockMetadata(5159473).setEnableSnow().setTemperatureRainfall(-0.5F, 0.4F).setHeight(height_LowHills).func_150563_c(16777215);
|
| 118 | public static final BiomeGenBase megaTaiga = (new BiomeGenTaiga(32, 1)).setColor(5858897).setBiomeName("Mega Taiga").setFillerBlockMetadata(5159473).setTemperatureRainfall(0.3F, 0.8F).setHeight(height_MidPlains);
|
| 119 | public static final BiomeGenBase megaTaigaHills = (new BiomeGenTaiga(33, 1)).setColor(4542270).setBiomeName("Mega Taiga Hills").setFillerBlockMetadata(5159473).setTemperatureRainfall(0.3F, 0.8F).setHeight(height_LowHills);
|
| 120 | public static final BiomeGenBase extremeHillsPlus = (new BiomeGenHills(34, true)).setColor(5271632).setBiomeName("Extreme Hills+").setHeight(height_MidHills).setTemperatureRainfall(0.2F, 0.3F);
|
| 121 | public static final BiomeGenBase savanna = (new BiomeGenSavanna(35)).setColor(12431967).setBiomeName("Savanna").setTemperatureRainfall(1.2F, 0.0F).setDisableRain().setHeight(height_LowPlains);
|
| 122 | public static final BiomeGenBase savannaPlateau = (new BiomeGenSavanna(36)).setColor(10984804).setBiomeName("Savanna Plateau").setTemperatureRainfall(1.0F, 0.0F).setDisableRain().setHeight(height_HighPlateaus);
|
| 123 | public static final BiomeGenBase mesa = (new BiomeGenMesa(37, false, false)).setColor(14238997).setBiomeName("Mesa");
|
| 124 | public static final BiomeGenBase mesaPlateau_F = (new BiomeGenMesa(38, false, true)).setColor(11573093).setBiomeName("Mesa Plateau F").setHeight(height_HighPlateaus);
|
| 125 | public static final BiomeGenBase mesaPlateau = (new BiomeGenMesa(39, false, false)).setColor(13274213).setBiomeName("Mesa Plateau").setHeight(height_HighPlateaus);
|
| 126 | public static final BiomeGenBase field_180279_ad = ocean;
|
| 127 | protected static final NoiseGeneratorPerlin temperatureNoise;
|
| 128 | protected static final NoiseGeneratorPerlin GRASS_COLOR_NOISE;
|
| 129 | protected static final WorldGenDoublePlant DOUBLE_PLANT_GENERATOR;
|
| 130 | public String biomeName;
|
| 131 | public int color;
|
| 132 | public int field_150609_ah;
|
| 133 |
|
| 134 | /** The block expected to be on the top of this biome */
|
| 135 | public IBlockState topBlock = Blocks.grass.getDefaultState();
|
| 136 |
|
| 137 | /** The block to fill spots in when not on the top */
|
| 138 | public IBlockState fillerBlock = Blocks.dirt.getDefaultState();
|
| 139 | public int fillerBlockMetadata = 5169201;
|
| 140 |
|
| 141 | /** The minimum height of this biome. Default 0.1. */
|
| 142 | public float minHeight;
|
| 143 |
|
| 144 | /** The maximum height of this biome. Default 0.3. */
|
| 145 | public float maxHeight;
|
| 146 |
|
| 147 | /** The temperature of this biome. */
|
| 148 | public float temperature;
|
| 149 |
|
| 150 | /** The rainfall in this biome. */
|
| 151 | public float rainfall;
|
| 152 |
|
| 153 | /** Color tint applied to water depending on biome */
|
| 154 | public int waterColorMultiplier;
|
| 155 |
|
| 156 | /** The biome decorator. */
|
| 157 | public BiomeDecorator theBiomeDecorator;
|
| 158 | protected List<BiomeGenBase.SpawnListEntry> spawnableMonsterList;
|
| 159 | protected List<BiomeGenBase.SpawnListEntry> spawnableCreatureList;
|
| 160 | protected List<BiomeGenBase.SpawnListEntry> spawnableWaterCreatureList;
|
| 161 | protected List<BiomeGenBase.SpawnListEntry> spawnableCaveCreatureList;
|
| 162 |
|
| 163 | /** Set to true if snow is enabled for this biome. */
|
| 164 | protected boolean enableSnow;
|
| 165 |
|
| 166 | /**
|
| 167 | * Is true (default) if the biome support rain (desert and nether can't have rain)
|
| 168 | */
|
| 169 | protected boolean enableRain;
|
| 170 |
|
| 171 | /** The id number to this biome, and its index in the biomeList array. */
|
| 172 | public final int biomeID;
|
| 173 |
|
| 174 | /** The tree generator. */
|
| 175 | protected WorldGenTrees worldGeneratorTrees;
|
| 176 |
|
| 177 | /** The big tree generator. */
|
| 178 | protected WorldGenBigTree worldGeneratorBigTree;
|
| 179 |
|
| 180 | /** The swamp tree generator. */
|
| 181 | protected WorldGenSwamp worldGeneratorSwamp;
|
| 182 |
|
| 183 | protected BiomeGenBase(int id)
|
| 184 | {
|
| 185 | this.minHeight = height_Default.rootHeight;
|
| 186 | this.maxHeight = height_Default.variation;
|
| 187 | this.temperature = 0.5F;
|
| 188 | this.rainfall = 0.5F;
|
| 189 | this.waterColorMultiplier = 16777215;
|
| 190 | this.spawnableMonsterList = Lists.<BiomeGenBase.SpawnListEntry>newArrayList();
|
| 191 | this.spawnableCreatureList = Lists.<BiomeGenBase.SpawnListEntry>newArrayList();
|
| 192 | this.spawnableWaterCreatureList = Lists.<BiomeGenBase.SpawnListEntry>newArrayList();
|
| 193 | this.spawnableCaveCreatureList = Lists.<BiomeGenBase.SpawnListEntry>newArrayList();
|
| 194 | this.enableRain = true;
|
| 195 | this.worldGeneratorTrees = new WorldGenTrees(false);
|
| 196 | this.worldGeneratorBigTree = new WorldGenBigTree(false);
|
| 197 | this.worldGeneratorSwamp = new WorldGenSwamp();
|
| 198 | this.biomeID = id;
|
| 199 | biomeList[id] = this;
|
| 200 | this.theBiomeDecorator = this.createBiomeDecorator();
|
| 201 | this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 12, 4, 4));
|
| 202 | this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityRabbit.class, 10, 3, 3));
|
| 203 | this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityPig.class, 10, 4, 4));
|
| 204 | this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 10, 4, 4));
|
| 205 | this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 8, 4, 4));
|
| 206 | this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 100, 4, 4));
|
| 207 | this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 100, 4, 4));
|
| 208 | this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 100, 4, 4));
|
| 209 | this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 100, 4, 4));
|
| 210 | this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 100, 4, 4));
|
| 211 | this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityEnderman.class, 10, 1, 4));
|
| 212 | this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 1));
|
| 213 | this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 10, 4, 4));
|
| 214 | this.spawnableCaveCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 10, 8, 8));
|
| 215 | }
|
| 216 |
|
| 217 | /**
|
| 218 | * Allocate a new BiomeDecorator for this BiomeGenBase
|
| 219 | */
|
| 220 | protected BiomeDecorator createBiomeDecorator()
|
| 221 | {
|
| 222 | return new BiomeDecorator();
|
| 223 | }
|
| 224 |
|
| 225 | /**
|
| 226 | * Sets the temperature and rainfall of this biome.
|
| 227 | */
|
| 228 | protected BiomeGenBase setTemperatureRainfall(float temperatureIn, float rainfallIn)
|
| 229 | {
|
| 230 | if (temperatureIn > 0.1F && temperatureIn < 0.2F)
|
| 231 | {
|
| 232 | throw new IllegalArgumentException("Please avoid temperatures in the range 0.1 - 0.2 because of snow");
|
| 233 | }
|
| 234 | else
|
| 235 | {
|
| 236 | this.temperature = temperatureIn;
|
| 237 | this.rainfall = rainfallIn;
|
| 238 | return this;
|
| 239 | }
|
| 240 | }
|
| 241 |
|
| 242 | protected final BiomeGenBase setHeight(BiomeGenBase.Height heights)
|
| 243 | {
|
| 244 | this.minHeight = heights.rootHeight;
|
| 245 | this.maxHeight = heights.variation;
|
| 246 | return this;
|
| 247 | }
|
| 248 |
|
| 249 | /**
|
| 250 | * Disable the rain for the biome.
|
| 251 | */
|
| 252 | protected BiomeGenBase setDisableRain()
|
| 253 | {
|
| 254 | this.enableRain = false;
|
| 255 | return this;
|
| 256 | }
|
| 257 |
|
| 258 | public WorldGenAbstractTree genBigTreeChance(Random rand)
|
| 259 | {
|
| 260 | return (WorldGenAbstractTree)(rand.nextInt(10) == 0 ? this.worldGeneratorBigTree : this.worldGeneratorTrees);
|
| 261 | }
|
| 262 |
|
| 263 | /**
|
| 264 | * Gets a WorldGen appropriate for this biome.
|
| 265 | */
|
| 266 | public WorldGenerator getRandomWorldGenForGrass(Random rand)
|
| 267 | {
|
| 268 | return new WorldGenTallGrass(BlockTallGrass.EnumType.GRASS);
|
| 269 | }
|
| 270 |
|
| 271 | public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos)
|
| 272 | {
|
| 273 | return rand.nextInt(3) > 0 ? BlockFlower.EnumFlowerType.DANDELION : BlockFlower.EnumFlowerType.POPPY;
|
| 274 | }
|
| 275 |
|
| 276 | /**
|
| 277 | * sets enableSnow to true during biome initialization. returns BiomeGenBase.
|
| 278 | */
|
| 279 | protected BiomeGenBase setEnableSnow()
|
| 280 | {
|
| 281 | this.enableSnow = true;
|
| 282 | return this;
|
| 283 | }
|
| 284 |
|
| 285 | protected BiomeGenBase setBiomeName(String name)
|
| 286 | {
|
| 287 | this.biomeName = name;
|
| 288 | return this;
|
| 289 | }
|
| 290 |
|
| 291 | protected BiomeGenBase setFillerBlockMetadata(int meta)
|
| 292 | {
|
| 293 | this.fillerBlockMetadata = meta;
|
| 294 | return this;
|
| 295 | }
|
| 296 |
|
| 297 | protected BiomeGenBase setColor(int colorIn)
|
| 298 | {
|
| 299 | this.func_150557_a(colorIn, false);
|
| 300 | return this;
|
| 301 | }
|
| 302 |
|
| 303 | protected BiomeGenBase func_150563_c(int p_150563_1_)
|
| 304 | {
|
| 305 | this.field_150609_ah = p_150563_1_;
|
| 306 | return this;
|
| 307 | }
|
| 308 |
|
| 309 | protected BiomeGenBase func_150557_a(int colorIn, boolean p_150557_2_)
|
| 310 | {
|
| 311 | this.color = colorIn;
|
| 312 |
|
| 313 | if (p_150557_2_)
|
| 314 | {
|
| 315 | this.field_150609_ah = (colorIn & 16711422) >> 1;
|
| 316 | }
|
| 317 | else
|
| 318 | {
|
| 319 | this.field_150609_ah = colorIn;
|
| 320 | }
|
| 321 |
|
| 322 | return this;
|
| 323 | }
|
| 324 |
|
| 325 | /**
|
| 326 | * takes temperature, returns color
|
| 327 | */
|
| 328 | public int getSkyColorByTemp(float p_76731_1_)
|
| 329 | {
|
| 330 | p_76731_1_ = p_76731_1_ / 3.0F;
|
| 331 | p_76731_1_ = MathHelper.clamp_float(p_76731_1_, -1.0F, 1.0F);
|
| 332 | return MathHelper.hsvToRGB(0.62222224F - p_76731_1_ * 0.05F, 0.5F + p_76731_1_ * 0.1F, 1.0F);
|
| 333 | }
|
| 334 |
|
| 335 | public List<BiomeGenBase.SpawnListEntry> getSpawnableList(EnumCreatureType creatureType)
|
| 336 | {
|
| 337 | switch (creatureType)
|
| 338 | {
|
| 339 | case MONSTER:
|
| 340 | return this.spawnableMonsterList;
|
| 341 |
|
| 342 | case CREATURE:
|
| 343 | return this.spawnableCreatureList;
|
| 344 |
|
| 345 | case WATER_CREATURE:
|
| 346 | return this.spawnableWaterCreatureList;
|
| 347 |
|
| 348 | case AMBIENT:
|
| 349 | return this.spawnableCaveCreatureList;
|
| 350 |
|
| 351 | default:
|
| 352 | return Collections.<BiomeGenBase.SpawnListEntry>emptyList();
|
| 353 | }
|
| 354 | }
|
| 355 |
|
| 356 | /**
|
| 357 | * Returns true if the biome have snowfall instead a normal rain.
|
| 358 | */
|
| 359 | public boolean getEnableSnow()
|
| 360 | {
|
| 361 | return this.isSnowyBiome();
|
| 362 | }
|
| 363 |
|
| 364 | /**
|
| 365 | * Check if rain can occur in biome
|
| 366 | */
|
| 367 | public boolean canRain()
|
| 368 | {
|
| 369 | return this.isSnowyBiome() ? false : this.enableRain;
|
| 370 | }
|
| 371 |
|
| 372 | /**
|
| 373 | * Checks to see if the rainfall level of the biome is extremely high
|
| 374 | */
|
| 375 | public boolean isHighHumidity()
|
| 376 | {
|
| 377 | return this.rainfall > 0.85F;
|
| 378 | }
|
| 379 |
|
| 380 | /**
|
| 381 | * returns the chance a creature has to spawn.
|
| 382 | */
|
| 383 | public float getSpawningChance()
|
| 384 | {
|
| 385 | return 0.1F;
|
| 386 | }
|
| 387 |
|
| 388 | /**
|
| 389 | * Gets an integer representation of this biome's rainfall
|
| 390 | */
|
| 391 | public final int getIntRainfall()
|
| 392 | {
|
| 393 | return (int)(this.rainfall * 65536.0F);
|
| 394 | }
|
| 395 |
|
| 396 | /**
|
| 397 | * Gets a floating point representation of this biome's rainfall
|
| 398 | */
|
| 399 | public final float getFloatRainfall()
|
| 400 | {
|
| 401 | return this.rainfall;
|
| 402 | }
|
| 403 |
|
| 404 | /**
|
| 405 | * Gets a floating point representation of this biome's temperature
|
| 406 | */
|
| 407 | public final float getFloatTemperature(BlockPos pos)
|
| 408 | {
|
| 409 | if (pos.getY() > 64)
|
| 410 | {
|
| 411 | float f = (float)(temperatureNoise.func_151601_a((double)pos.getX() * 1.0D / 8.0D, (double)pos.getZ() * 1.0D / 8.0D) * 4.0D);
|
| 412 | return this.temperature - (f + (float)pos.getY() - 64.0F) * 0.05F / 30.0F;
|
| 413 | }
|
| 414 | else
|
| 415 | {
|
| 416 | return this.temperature;
|
| 417 | }
|
| 418 | }
|
| 419 |
|
| 420 | public void decorate(World worldIn, Random rand, BlockPos pos)
|
| 421 | {
|
| 422 | this.theBiomeDecorator.decorate(worldIn, rand, this, pos);
|
| 423 | }
|
| 424 |
|
| 425 | public int getGrassColorAtPos(BlockPos pos)
|
| 426 | {
|
| 427 | double d0 = (double)MathHelper.clamp_float(this.getFloatTemperature(pos), 0.0F, 1.0F);
|
| 428 | double d1 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
|
| 429 | return ColorizerGrass.getGrassColor(d0, d1);
|
| 430 | }
|
| 431 |
|
| 432 | public int getFoliageColorAtPos(BlockPos pos)
|
| 433 | {
|
| 434 | double d0 = (double)MathHelper.clamp_float(this.getFloatTemperature(pos), 0.0F, 1.0F);
|
| 435 | double d1 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
|
| 436 | return ColorizerFoliage.getFoliageColor(d0, d1);
|
| 437 | }
|
| 438 |
|
| 439 | public boolean isSnowyBiome()
|
| 440 | {
|
| 441 | return this.enableSnow;
|
| 442 | }
|
| 443 |
|
| 444 | public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal)
|
| 445 | {
|
| 446 | this.generateBiomeTerrain(worldIn, rand, chunkPrimerIn, x, z, noiseVal);
|
| 447 | }
|
| 448 |
|
| 449 | /**
|
| 450 | * Given x, z coordinates, we count down all the y positions starting at 255 and working our way down. When we hit a
|
| 451 | * non-air block, we replace it with this.topBlock (default grass, descendants may set otherwise), and then a
|
| 452 | * relatively shallow layer of blocks of type this.fillerBlock (default dirt). A random set of blocks below y == 5
|
| 453 | * (but always including y == 0) is replaced with bedrock.
|
| 454 | *
|
| 455 | * If we don't hit non-air until somewhat below sea level, we top with gravel and fill down with stone.
|
| 456 | *
|
| 457 | * If this.fillerBlock is red sand, we replace some of that with red sandstone.
|
| 458 | */
|
| 459 | public final void generateBiomeTerrain(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal)
|
| 460 | {
|
| 461 | int i = worldIn.getSeaLevel();
|
| 462 | IBlockState iblockstate = this.topBlock;
|
| 463 | IBlockState iblockstate1 = this.fillerBlock;
|
| 464 | int j = -1;
|
| 465 | int k = (int)(noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
|
| 466 | int l = x & 15;
|
| 467 | int i1 = z & 15;
|
| 468 | BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
| 469 |
|
| 470 | for (int j1 = 255; j1 >= 0; --j1)
|
| 471 | {
|
| 472 | if (j1 <= rand.nextInt(5))
|
| 473 | {
|
| 474 | chunkPrimerIn.setBlockState(i1, j1, l, Blocks.bedrock.getDefaultState());
|
| 475 | }
|
| 476 | else
|
| 477 | {
|
| 478 | IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l);
|
| 479 |
|
| 480 | if (iblockstate2.getBlock().getMaterial() == Material.air)
|
| 481 | {
|
| 482 | j = -1;
|
| 483 | }
|
| 484 | else if (iblockstate2.getBlock() == Blocks.stone)
|
| 485 | {
|
| 486 | if (j == -1)
|
| 487 | {
|
| 488 | if (k <= 0)
|
| 489 | {
|
| 490 | iblockstate = null;
|
| 491 | iblockstate1 = Blocks.stone.getDefaultState();
|
| 492 | }
|
| 493 | else if (j1 >= i - 4 && j1 <= i + 1)
|
| 494 | {
|
| 495 | iblockstate = this.topBlock;
|
| 496 | iblockstate1 = this.fillerBlock;
|
| 497 | }
|
| 498 |
|
| 499 | if (j1 < i && (iblockstate == null || iblockstate.getBlock().getMaterial() == Material.air))
|
| 500 | {
|
| 501 | if (this.getFloatTemperature(blockpos$mutableblockpos.set(x, j1, z)) < 0.15F)
|
| 502 | {
|
| 503 | iblockstate = Blocks.ice.getDefaultState();
|
| 504 | }
|
| 505 | else
|
| 506 | {
|
| 507 | iblockstate = Blocks.water.getDefaultState();
|
| 508 | }
|
| 509 | }
|
| 510 |
|
| 511 | j = k;
|
| 512 |
|
| 513 | if (j1 >= i - 1)
|
| 514 | {
|
| 515 | chunkPrimerIn.setBlockState(i1, j1, l, iblockstate);
|
| 516 | }
|
| 517 | else if (j1 < i - 7 - k)
|
| 518 | {
|
| 519 | iblockstate = null;
|
| 520 | iblockstate1 = Blocks.stone.getDefaultState();
|
| 521 | chunkPrimerIn.setBlockState(i1, j1, l, Blocks.gravel.getDefaultState());
|
| 522 | }
|
| 523 | else
|
| 524 | {
|
| 525 | chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
|
| 526 | }
|
| 527 | }
|
| 528 | else if (j > 0)
|
| 529 | {
|
| 530 | --j;
|
| 531 | chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1);
|
| 532 |
|
| 533 | if (j == 0 && iblockstate1.getBlock() == Blocks.sand)
|
| 534 | {
|
| 535 | j = rand.nextInt(4) + Math.max(0, j1 - 63);
|
| 536 | iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? Blocks.red_sandstone.getDefaultState() : Blocks.sandstone.getDefaultState();
|
| 537 | }
|
| 538 | }
|
| 539 | }
|
| 540 | }
|
| 541 | }
|
| 542 | }
|
| 543 |
|
| 544 | /**
|
| 545 | * Creates a mutated version of the biome and places it into the biomeList with an index equal to the original plus
|
| 546 | * 128
|
| 547 | */
|
| 548 | protected BiomeGenBase createMutation()
|
| 549 | {
|
| 550 | return this.createMutatedBiome(this.biomeID + 128);
|
| 551 | }
|
| 552 |
|
| 553 | protected BiomeGenBase createMutatedBiome(int p_180277_1_)
|
| 554 | {
|
| 555 | return new BiomeGenMutated(p_180277_1_, this);
|
| 556 | }
|
| 557 |
|
| 558 | public Class <? extends BiomeGenBase > getBiomeClass()
|
| 559 | {
|
| 560 | return this.getClass();
|
| 561 | }
|
| 562 |
|
| 563 | /**
|
| 564 | * returns true if the biome specified is equal to this biome
|
| 565 | */
|
| 566 | public boolean isEqualTo(BiomeGenBase biome)
|
| 567 | {
|
| 568 | return biome == this ? true : (biome == null ? false : this.getBiomeClass() == biome.getBiomeClass());
|
| 569 | }
|
| 570 |
|
| 571 | public BiomeGenBase.TempCategory getTempCategory()
|
| 572 | {
|
| 573 | return (double)this.temperature < 0.2D ? BiomeGenBase.TempCategory.COLD : ((double)this.temperature < 1.0D ? BiomeGenBase.TempCategory.MEDIUM : BiomeGenBase.TempCategory.WARM);
|
| 574 | }
|
| 575 |
|
| 576 | public static BiomeGenBase[] getBiomeGenArray()
|
| 577 | {
|
| 578 | return biomeList;
|
| 579 | }
|
| 580 |
|
| 581 | /**
|
| 582 | * return the biome specified by biomeID, or 0 (ocean) if out of bounds
|
| 583 | */
|
| 584 | public static BiomeGenBase getBiome(int id)
|
| 585 | {
|
| 586 | return getBiomeFromBiomeList(id, (BiomeGenBase)null);
|
| 587 | }
|
| 588 |
|
| 589 | public static BiomeGenBase getBiomeFromBiomeList(int biomeId, BiomeGenBase biome)
|
| 590 | {
|
| 591 | if (biomeId >= 0 && biomeId <= biomeList.length)
|
| 592 | {
|
| 593 | BiomeGenBase biomegenbase = biomeList[biomeId];
|
| 594 | return biomegenbase == null ? biome : biomegenbase;
|
| 595 | }
|
| 596 | else
|
| 597 | {
|
| 598 | logger.warn("Biome ID is out of bounds: " + biomeId + ", defaulting to 0 (Ocean)");
|
| 599 | return ocean;
|
| 600 | }
|
| 601 | }
|
| 602 |
|
| 603 | static
|
| 604 | {
|
| 605 | plains.createMutation();
|
| 606 | desert.createMutation();
|
| 607 | forest.createMutation();
|
| 608 | taiga.createMutation();
|
| 609 | swampland.createMutation();
|
| 610 | icePlains.createMutation();
|
| 611 | jungle.createMutation();
|
| 612 | jungleEdge.createMutation();
|
| 613 | coldTaiga.createMutation();
|
| 614 | savanna.createMutation();
|
| 615 | savannaPlateau.createMutation();
|
| 616 | mesa.createMutation();
|
| 617 | mesaPlateau_F.createMutation();
|
| 618 | mesaPlateau.createMutation();
|
| 619 | birchForest.createMutation();
|
| 620 | birchForestHills.createMutation();
|
| 621 | roofedForest.createMutation();
|
| 622 | megaTaiga.createMutation();
|
| 623 | extremeHills.createMutation();
|
| 624 | extremeHillsPlus.createMutation();
|
| 625 | megaTaiga.createMutatedBiome(megaTaigaHills.biomeID + 128).setBiomeName("Redwood Taiga Hills M");
|
| 626 |
|
| 627 | for (BiomeGenBase biomegenbase : biomeList)
|
| 628 | {
|
| 629 | if (biomegenbase != null)
|
| 630 | {
|
| 631 | if (BIOME_ID_MAP.containsKey(biomegenbase.biomeName))
|
| 632 | {
|
| 633 | throw new Error("Biome \"" + biomegenbase.biomeName + "\" is defined as both ID " + ((BiomeGenBase)BIOME_ID_MAP.get(biomegenbase.biomeName)).biomeID + " and " + biomegenbase.biomeID);
|
| 634 | }
|
| 635 |
|
| 636 | BIOME_ID_MAP.put(biomegenbase.biomeName, biomegenbase);
|
| 637 |
|
| 638 | if (biomegenbase.biomeID < 128)
|
| 639 | {
|
| 640 | explorationBiomesList.add(biomegenbase);
|
| 641 | }
|
| 642 | }
|
| 643 | }
|
| 644 |
|
| 645 | explorationBiomesList.remove(hell);
|
| 646 | explorationBiomesList.remove(sky);
|
| 647 | explorationBiomesList.remove(frozenOcean);
|
| 648 | explorationBiomesList.remove(extremeHillsEdge);
|
| 649 | temperatureNoise = new NoiseGeneratorPerlin(new Random(1234L), 1);
|
| 650 | GRASS_COLOR_NOISE = new NoiseGeneratorPerlin(new Random(2345L), 1);
|
| 651 | DOUBLE_PLANT_GENERATOR = new WorldGenDoublePlant();
|
| 652 | }
|
| 653 |
|
| 654 | public static class Height
|
| 655 | {
|
| 656 | public float rootHeight;
|
| 657 | public float variation;
|
| 658 |
|
| 659 | public Height(float rootHeightIn, float variationIn)
|
| 660 | {
|
| 661 | this.rootHeight = rootHeightIn;
|
| 662 | this.variation = variationIn;
|
| 663 | }
|
| 664 |
|
| 665 | public BiomeGenBase.Height attenuate()
|
| 666 | {
|
| 667 | return new BiomeGenBase.Height(this.rootHeight * 0.8F, this.variation * 0.6F);
|
| 668 | }
|
| 669 | }
|
| 670 |
|
| 671 | public static class SpawnListEntry extends WeightedRandom.Item
|
| 672 | {
|
| 673 | public Class <? extends EntityLiving > entityClass;
|
| 674 | public int minGroupCount;
|
| 675 | public int maxGroupCount;
|
| 676 |
|
| 677 | public SpawnListEntry(Class <? extends EntityLiving > entityclassIn, int weight, int groupCountMin, int groupCountMax)
|
| 678 | {
|
| 679 | super(weight);
|
| 680 | this.entityClass = entityclassIn;
|
| 681 | this.minGroupCount = groupCountMin;
|
| 682 | this.maxGroupCount = groupCountMax;
|
| 683 | }
|
| 684 |
|
| 685 | public String toString()
|
| 686 | {
|
| 687 | return this.entityClass.getSimpleName() + "*(" + this.minGroupCount + "-" + this.maxGroupCount + "):" + this.itemWeight;
|
| 688 | }
|
| 689 | }
|
| 690 |
|
| 691 | public static enum TempCategory
|
| 692 | {
|
| 693 | OCEAN,
|
| 694 | COLD,
|
| 695 | MEDIUM,
|
| 696 | WARM;
|
| 697 | }
|
| 698 | }
|
| 699 |
|