| 1 | package net.minecraft.world.biome;
|
| 2 |
|
| 3 | import java.util.Arrays;
|
| 4 | import java.util.Random;
|
| 5 | import net.minecraft.block.BlockColored;
|
| 6 | import net.minecraft.block.BlockDirt;
|
| 7 | import net.minecraft.block.BlockSand;
|
| 8 | import net.minecraft.block.material.Material;
|
| 9 | import net.minecraft.block.state.IBlockState;
|
| 10 | import net.minecraft.init.Blocks;
|
| 11 | import net.minecraft.item.EnumDyeColor;
|
| 12 | import net.minecraft.util.BlockPos;
|
| 13 | import net.minecraft.world.World;
|
| 14 | import net.minecraft.world.chunk.ChunkPrimer;
|
| 15 | import net.minecraft.world.gen.NoiseGeneratorPerlin;
|
| 16 | import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
| 17 |
|
| 18 | public class BiomeGenMesa extends BiomeGenBase
|
| 19 | {
|
| 20 | private IBlockState[] field_150621_aC;
|
| 21 | private long field_150622_aD;
|
| 22 | private NoiseGeneratorPerlin field_150623_aE;
|
| 23 | private NoiseGeneratorPerlin field_150624_aF;
|
| 24 | private NoiseGeneratorPerlin field_150625_aG;
|
| 25 | private boolean field_150626_aH;
|
| 26 | private boolean field_150620_aI;
|
| 27 |
|
| 28 | public BiomeGenMesa(int id, boolean p_i45380_2_, boolean p_i45380_3_)
|
| 29 | {
|
| 30 | super(id);
|
| 31 | this.field_150626_aH = p_i45380_2_;
|
| 32 | this.field_150620_aI = p_i45380_3_;
|
| 33 | this.setDisableRain();
|
| 34 | this.setTemperatureRainfall(2.0F, 0.0F);
|
| 35 | this.spawnableCreatureList.clear();
|
| 36 | this.topBlock = Blocks.sand.getDefaultState().withProperty(BlockSand.VARIANT, BlockSand.EnumType.RED_SAND);
|
| 37 | this.fillerBlock = Blocks.stained_hardened_clay.getDefaultState();
|
| 38 | this.theBiomeDecorator.treesPerChunk = -999;
|
| 39 | this.theBiomeDecorator.deadBushPerChunk = 20;
|
| 40 | this.theBiomeDecorator.reedsPerChunk = 3;
|
| 41 | this.theBiomeDecorator.cactiPerChunk = 5;
|
| 42 | this.theBiomeDecorator.flowersPerChunk = 0;
|
| 43 | this.spawnableCreatureList.clear();
|
| 44 |
|
| 45 | if (p_i45380_3_)
|
| 46 | {
|
| 47 | this.theBiomeDecorator.treesPerChunk = 5;
|
| 48 | }
|
| 49 | }
|
| 50 |
|
| 51 | public WorldGenAbstractTree genBigTreeChance(Random rand)
|
| 52 | {
|
| 53 | return this.worldGeneratorTrees;
|
| 54 | }
|
| 55 |
|
| 56 | public int getFoliageColorAtPos(BlockPos pos)
|
| 57 | {
|
| 58 | return 10387789;
|
| 59 | }
|
| 60 |
|
| 61 | public int getGrassColorAtPos(BlockPos pos)
|
| 62 | {
|
| 63 | return 9470285;
|
| 64 | }
|
| 65 |
|
| 66 | public void decorate(World worldIn, Random rand, BlockPos pos)
|
| 67 | {
|
| 68 | super.decorate(worldIn, rand, pos);
|
| 69 | }
|
| 70 |
|
| 71 | public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal)
|
| 72 | {
|
| 73 | if (this.field_150621_aC == null || this.field_150622_aD != worldIn.getSeed())
|
| 74 | {
|
| 75 | this.func_150619_a(worldIn.getSeed());
|
| 76 | }
|
| 77 |
|
| 78 | if (this.field_150623_aE == null || this.field_150624_aF == null || this.field_150622_aD != worldIn.getSeed())
|
| 79 | {
|
| 80 | Random random = new Random(this.field_150622_aD);
|
| 81 | this.field_150623_aE = new NoiseGeneratorPerlin(random, 4);
|
| 82 | this.field_150624_aF = new NoiseGeneratorPerlin(random, 1);
|
| 83 | }
|
| 84 |
|
| 85 | this.field_150622_aD = worldIn.getSeed();
|
| 86 | double d4 = 0.0D;
|
| 87 |
|
| 88 | if (this.field_150626_aH)
|
| 89 | {
|
| 90 | int i = (x & -16) + (z & 15);
|
| 91 | int j = (z & -16) + (x & 15);
|
| 92 | double d0 = Math.min(Math.abs(noiseVal), this.field_150623_aE.func_151601_a((double)i * 0.25D, (double)j * 0.25D));
|
| 93 |
|
| 94 | if (d0 > 0.0D)
|
| 95 | {
|
| 96 | double d1 = 0.001953125D;
|
| 97 | double d2 = Math.abs(this.field_150624_aF.func_151601_a((double)i * d1, (double)j * d1));
|
| 98 | d4 = d0 * d0 * 2.5D;
|
| 99 | double d3 = Math.ceil(d2 * 50.0D) + 14.0D;
|
| 100 |
|
| 101 | if (d4 > d3)
|
| 102 | {
|
| 103 | d4 = d3;
|
| 104 | }
|
| 105 |
|
| 106 | d4 = d4 + 64.0D;
|
| 107 | }
|
| 108 | }
|
| 109 |
|
| 110 | int j1 = x & 15;
|
| 111 | int k1 = z & 15;
|
| 112 | int l1 = worldIn.getSeaLevel();
|
| 113 | IBlockState iblockstate = Blocks.stained_hardened_clay.getDefaultState();
|
| 114 | IBlockState iblockstate3 = this.fillerBlock;
|
| 115 | int k = (int)(noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D);
|
| 116 | boolean flag = Math.cos(noiseVal / 3.0D * Math.PI) > 0.0D;
|
| 117 | int l = -1;
|
| 118 | boolean flag1 = false;
|
| 119 |
|
| 120 | for (int i1 = 255; i1 >= 0; --i1)
|
| 121 | {
|
| 122 | if (chunkPrimerIn.getBlockState(k1, i1, j1).getBlock().getMaterial() == Material.air && i1 < (int)d4)
|
| 123 | {
|
| 124 | chunkPrimerIn.setBlockState(k1, i1, j1, Blocks.stone.getDefaultState());
|
| 125 | }
|
| 126 |
|
| 127 | if (i1 <= rand.nextInt(5))
|
| 128 | {
|
| 129 | chunkPrimerIn.setBlockState(k1, i1, j1, Blocks.bedrock.getDefaultState());
|
| 130 | }
|
| 131 | else
|
| 132 | {
|
| 133 | IBlockState iblockstate1 = chunkPrimerIn.getBlockState(k1, i1, j1);
|
| 134 |
|
| 135 | if (iblockstate1.getBlock().getMaterial() == Material.air)
|
| 136 | {
|
| 137 | l = -1;
|
| 138 | }
|
| 139 | else if (iblockstate1.getBlock() == Blocks.stone)
|
| 140 | {
|
| 141 | if (l == -1)
|
| 142 | {
|
| 143 | flag1 = false;
|
| 144 |
|
| 145 | if (k <= 0)
|
| 146 | {
|
| 147 | iblockstate = null;
|
| 148 | iblockstate3 = Blocks.stone.getDefaultState();
|
| 149 | }
|
| 150 | else if (i1 >= l1 - 4 && i1 <= l1 + 1)
|
| 151 | {
|
| 152 | iblockstate = Blocks.stained_hardened_clay.getDefaultState();
|
| 153 | iblockstate3 = this.fillerBlock;
|
| 154 | }
|
| 155 |
|
| 156 | if (i1 < l1 && (iblockstate == null || iblockstate.getBlock().getMaterial() == Material.air))
|
| 157 | {
|
| 158 | iblockstate = Blocks.water.getDefaultState();
|
| 159 | }
|
| 160 |
|
| 161 | l = k + Math.max(0, i1 - l1);
|
| 162 |
|
| 163 | if (i1 < l1 - 1)
|
| 164 | {
|
| 165 | chunkPrimerIn.setBlockState(k1, i1, j1, iblockstate3);
|
| 166 |
|
| 167 | if (iblockstate3.getBlock() == Blocks.stained_hardened_clay)
|
| 168 | {
|
| 169 | chunkPrimerIn.setBlockState(k1, i1, j1, iblockstate3.getBlock().getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.ORANGE));
|
| 170 | }
|
| 171 | }
|
| 172 | else if (this.field_150620_aI && i1 > 86 + k * 2)
|
| 173 | {
|
| 174 | if (flag)
|
| 175 | {
|
| 176 | chunkPrimerIn.setBlockState(k1, i1, j1, Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT));
|
| 177 | }
|
| 178 | else
|
| 179 | {
|
| 180 | chunkPrimerIn.setBlockState(k1, i1, j1, Blocks.grass.getDefaultState());
|
| 181 | }
|
| 182 | }
|
| 183 | else if (i1 <= l1 + 3 + k)
|
| 184 | {
|
| 185 | chunkPrimerIn.setBlockState(k1, i1, j1, this.topBlock);
|
| 186 | flag1 = true;
|
| 187 | }
|
| 188 | else
|
| 189 | {
|
| 190 | IBlockState iblockstate4;
|
| 191 |
|
| 192 | if (i1 >= 64 && i1 <= 127)
|
| 193 | {
|
| 194 | if (flag)
|
| 195 | {
|
| 196 | iblockstate4 = Blocks.hardened_clay.getDefaultState();
|
| 197 | }
|
| 198 | else
|
| 199 | {
|
| 200 | iblockstate4 = this.func_180629_a(x, i1, z);
|
| 201 | }
|
| 202 | }
|
| 203 | else
|
| 204 | {
|
| 205 | iblockstate4 = Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.ORANGE);
|
| 206 | }
|
| 207 |
|
| 208 | chunkPrimerIn.setBlockState(k1, i1, j1, iblockstate4);
|
| 209 | }
|
| 210 | }
|
| 211 | else if (l > 0)
|
| 212 | {
|
| 213 | --l;
|
| 214 |
|
| 215 | if (flag1)
|
| 216 | {
|
| 217 | chunkPrimerIn.setBlockState(k1, i1, j1, Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.ORANGE));
|
| 218 | }
|
| 219 | else
|
| 220 | {
|
| 221 | IBlockState iblockstate2 = this.func_180629_a(x, i1, z);
|
| 222 | chunkPrimerIn.setBlockState(k1, i1, j1, iblockstate2);
|
| 223 | }
|
| 224 | }
|
| 225 | }
|
| 226 | }
|
| 227 | }
|
| 228 | }
|
| 229 |
|
| 230 | private void func_150619_a(long p_150619_1_)
|
| 231 | {
|
| 232 | this.field_150621_aC = new IBlockState[64];
|
| 233 | Arrays.fill(this.field_150621_aC, Blocks.hardened_clay.getDefaultState());
|
| 234 | Random random = new Random(p_150619_1_);
|
| 235 | this.field_150625_aG = new NoiseGeneratorPerlin(random, 1);
|
| 236 |
|
| 237 | for (int l1 = 0; l1 < 64; ++l1)
|
| 238 | {
|
| 239 | l1 += random.nextInt(5) + 1;
|
| 240 |
|
| 241 | if (l1 < 64)
|
| 242 | {
|
| 243 | this.field_150621_aC[l1] = Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.ORANGE);
|
| 244 | }
|
| 245 | }
|
| 246 |
|
| 247 | int i2 = random.nextInt(4) + 2;
|
| 248 |
|
| 249 | for (int i = 0; i < i2; ++i)
|
| 250 | {
|
| 251 | int j = random.nextInt(3) + 1;
|
| 252 | int k = random.nextInt(64);
|
| 253 |
|
| 254 | for (int l = 0; k + l < 64 && l < j; ++l)
|
| 255 | {
|
| 256 | this.field_150621_aC[k + l] = Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.YELLOW);
|
| 257 | }
|
| 258 | }
|
| 259 |
|
| 260 | int j2 = random.nextInt(4) + 2;
|
| 261 |
|
| 262 | for (int k2 = 0; k2 < j2; ++k2)
|
| 263 | {
|
| 264 | int i3 = random.nextInt(3) + 2;
|
| 265 | int l3 = random.nextInt(64);
|
| 266 |
|
| 267 | for (int i1 = 0; l3 + i1 < 64 && i1 < i3; ++i1)
|
| 268 | {
|
| 269 | this.field_150621_aC[l3 + i1] = Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.BROWN);
|
| 270 | }
|
| 271 | }
|
| 272 |
|
| 273 | int l2 = random.nextInt(4) + 2;
|
| 274 |
|
| 275 | for (int j3 = 0; j3 < l2; ++j3)
|
| 276 | {
|
| 277 | int i4 = random.nextInt(3) + 1;
|
| 278 | int k4 = random.nextInt(64);
|
| 279 |
|
| 280 | for (int j1 = 0; k4 + j1 < 64 && j1 < i4; ++j1)
|
| 281 | {
|
| 282 | this.field_150621_aC[k4 + j1] = Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.RED);
|
| 283 | }
|
| 284 | }
|
| 285 |
|
| 286 | int k3 = random.nextInt(3) + 3;
|
| 287 | int j4 = 0;
|
| 288 |
|
| 289 | for (int l4 = 0; l4 < k3; ++l4)
|
| 290 | {
|
| 291 | int i5 = 1;
|
| 292 | j4 += random.nextInt(16) + 4;
|
| 293 |
|
| 294 | for (int k1 = 0; j4 + k1 < 64 && k1 < i5; ++k1)
|
| 295 | {
|
| 296 | this.field_150621_aC[j4 + k1] = Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.WHITE);
|
| 297 |
|
| 298 | if (j4 + k1 > 1 && random.nextBoolean())
|
| 299 | {
|
| 300 | this.field_150621_aC[j4 + k1 - 1] = Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.SILVER);
|
| 301 | }
|
| 302 |
|
| 303 | if (j4 + k1 < 63 && random.nextBoolean())
|
| 304 | {
|
| 305 | this.field_150621_aC[j4 + k1 + 1] = Blocks.stained_hardened_clay.getDefaultState().withProperty(BlockColored.COLOR, EnumDyeColor.SILVER);
|
| 306 | }
|
| 307 | }
|
| 308 | }
|
| 309 | }
|
| 310 |
|
| 311 | private IBlockState func_180629_a(int p_180629_1_, int p_180629_2_, int p_180629_3_)
|
| 312 | {
|
| 313 | int i = (int)Math.round(this.field_150625_aG.func_151601_a((double)p_180629_1_ * 1.0D / 512.0D, (double)p_180629_1_ * 1.0D / 512.0D) * 2.0D);
|
| 314 | return this.field_150621_aC[(p_180629_2_ + i + 64) % 64];
|
| 315 | }
|
| 316 |
|
| 317 | protected BiomeGenBase createMutatedBiome(int p_180277_1_)
|
| 318 | {
|
| 319 | boolean flag = this.biomeID == BiomeGenBase.mesa.biomeID;
|
| 320 | BiomeGenMesa biomegenmesa = new BiomeGenMesa(p_180277_1_, flag, this.field_150620_aI);
|
| 321 |
|
| 322 | if (!flag)
|
| 323 | {
|
| 324 | biomegenmesa.setHeight(height_LowHills);
|
| 325 | biomegenmesa.setBiomeName(this.biomeName + " M");
|
| 326 | }
|
| 327 | else
|
| 328 | {
|
| 329 | biomegenmesa.setBiomeName(this.biomeName + " (Bryce)");
|
| 330 | }
|
| 331 |
|
| 332 | biomegenmesa.func_150557_a(this.color, true);
|
| 333 | return biomegenmesa;
|
| 334 | }
|
| 335 | }
|
| 336 |
|