| 1 | package net.minecraft.world.gen;
|
| 2 |
|
| 3 | import java.util.Random;
|
| 4 | import net.minecraft.block.state.IBlockState;
|
| 5 | import net.minecraft.init.Blocks;
|
| 6 | import net.minecraft.util.MathHelper;
|
| 7 | import net.minecraft.world.World;
|
| 8 | import net.minecraft.world.chunk.ChunkPrimer;
|
| 9 |
|
| 10 | public class MapGenCavesHell extends MapGenBase
|
| 11 | {
|
| 12 | protected void func_180705_a(long p_180705_1_, int p_180705_3_, int p_180705_4_, ChunkPrimer p_180705_5_, double p_180705_6_, double p_180705_8_, double p_180705_10_)
|
| 13 | {
|
| 14 | this.func_180704_a(p_180705_1_, p_180705_3_, p_180705_4_, p_180705_5_, p_180705_6_, p_180705_8_, p_180705_10_, 1.0F + this.rand.nextFloat() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D);
|
| 15 | }
|
| 16 |
|
| 17 | protected void func_180704_a(long p_180704_1_, int p_180704_3_, int p_180704_4_, ChunkPrimer p_180704_5_, double p_180704_6_, double p_180704_8_, double p_180704_10_, float p_180704_12_, float p_180704_13_, float p_180704_14_, int p_180704_15_, int p_180704_16_, double p_180704_17_)
|
| 18 | {
|
| 19 | double d0 = (double)(p_180704_3_ * 16 + 8);
|
| 20 | double d1 = (double)(p_180704_4_ * 16 + 8);
|
| 21 | float f = 0.0F;
|
| 22 | float f1 = 0.0F;
|
| 23 | Random random = new Random(p_180704_1_);
|
| 24 |
|
| 25 | if (p_180704_16_ <= 0)
|
| 26 | {
|
| 27 | int i = this.range * 16 - 16;
|
| 28 | p_180704_16_ = i - random.nextInt(i / 4);
|
| 29 | }
|
| 30 |
|
| 31 | boolean flag1 = false;
|
| 32 |
|
| 33 | if (p_180704_15_ == -1)
|
| 34 | {
|
| 35 | p_180704_15_ = p_180704_16_ / 2;
|
| 36 | flag1 = true;
|
| 37 | }
|
| 38 |
|
| 39 | int j = random.nextInt(p_180704_16_ / 2) + p_180704_16_ / 4;
|
| 40 |
|
| 41 | for (boolean flag = random.nextInt(6) == 0; p_180704_15_ < p_180704_16_; ++p_180704_15_)
|
| 42 | {
|
| 43 | double d2 = 1.5D + (double)(MathHelper.sin((float)p_180704_15_ * (float)Math.PI / (float)p_180704_16_) * p_180704_12_ * 1.0F);
|
| 44 | double d3 = d2 * p_180704_17_;
|
| 45 | float f2 = MathHelper.cos(p_180704_14_);
|
| 46 | float f3 = MathHelper.sin(p_180704_14_);
|
| 47 | p_180704_6_ += (double)(MathHelper.cos(p_180704_13_) * f2);
|
| 48 | p_180704_8_ += (double)f3;
|
| 49 | p_180704_10_ += (double)(MathHelper.sin(p_180704_13_) * f2);
|
| 50 |
|
| 51 | if (flag)
|
| 52 | {
|
| 53 | p_180704_14_ = p_180704_14_ * 0.92F;
|
| 54 | }
|
| 55 | else
|
| 56 | {
|
| 57 | p_180704_14_ = p_180704_14_ * 0.7F;
|
| 58 | }
|
| 59 |
|
| 60 | p_180704_14_ = p_180704_14_ + f1 * 0.1F;
|
| 61 | p_180704_13_ += f * 0.1F;
|
| 62 | f1 = f1 * 0.9F;
|
| 63 | f = f * 0.75F;
|
| 64 | f1 = f1 + (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F;
|
| 65 | f = f + (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F;
|
| 66 |
|
| 67 | if (!flag1 && p_180704_15_ == j && p_180704_12_ > 1.0F)
|
| 68 | {
|
| 69 | this.func_180704_a(random.nextLong(), p_180704_3_, p_180704_4_, p_180704_5_, p_180704_6_, p_180704_8_, p_180704_10_, random.nextFloat() * 0.5F + 0.5F, p_180704_13_ - ((float)Math.PI / 2F), p_180704_14_ / 3.0F, p_180704_15_, p_180704_16_, 1.0D);
|
| 70 | this.func_180704_a(random.nextLong(), p_180704_3_, p_180704_4_, p_180704_5_, p_180704_6_, p_180704_8_, p_180704_10_, random.nextFloat() * 0.5F + 0.5F, p_180704_13_ + ((float)Math.PI / 2F), p_180704_14_ / 3.0F, p_180704_15_, p_180704_16_, 1.0D);
|
| 71 | return;
|
| 72 | }
|
| 73 |
|
| 74 | if (flag1 || random.nextInt(4) != 0)
|
| 75 | {
|
| 76 | double d4 = p_180704_6_ - d0;
|
| 77 | double d5 = p_180704_10_ - d1;
|
| 78 | double d6 = (double)(p_180704_16_ - p_180704_15_);
|
| 79 | double d7 = (double)(p_180704_12_ + 2.0F + 16.0F);
|
| 80 |
|
| 81 | if (d4 * d4 + d5 * d5 - d6 * d6 > d7 * d7)
|
| 82 | {
|
| 83 | return;
|
| 84 | }
|
| 85 |
|
| 86 | if (p_180704_6_ >= d0 - 16.0D - d2 * 2.0D && p_180704_10_ >= d1 - 16.0D - d2 * 2.0D && p_180704_6_ <= d0 + 16.0D + d2 * 2.0D && p_180704_10_ <= d1 + 16.0D + d2 * 2.0D)
|
| 87 | {
|
| 88 | int j2 = MathHelper.floor_double(p_180704_6_ - d2) - p_180704_3_ * 16 - 1;
|
| 89 | int k = MathHelper.floor_double(p_180704_6_ + d2) - p_180704_3_ * 16 + 1;
|
| 90 | int k2 = MathHelper.floor_double(p_180704_8_ - d3) - 1;
|
| 91 | int l = MathHelper.floor_double(p_180704_8_ + d3) + 1;
|
| 92 | int l2 = MathHelper.floor_double(p_180704_10_ - d2) - p_180704_4_ * 16 - 1;
|
| 93 | int i1 = MathHelper.floor_double(p_180704_10_ + d2) - p_180704_4_ * 16 + 1;
|
| 94 |
|
| 95 | if (j2 < 0)
|
| 96 | {
|
| 97 | j2 = 0;
|
| 98 | }
|
| 99 |
|
| 100 | if (k > 16)
|
| 101 | {
|
| 102 | k = 16;
|
| 103 | }
|
| 104 |
|
| 105 | if (k2 < 1)
|
| 106 | {
|
| 107 | k2 = 1;
|
| 108 | }
|
| 109 |
|
| 110 | if (l > 120)
|
| 111 | {
|
| 112 | l = 120;
|
| 113 | }
|
| 114 |
|
| 115 | if (l2 < 0)
|
| 116 | {
|
| 117 | l2 = 0;
|
| 118 | }
|
| 119 |
|
| 120 | if (i1 > 16)
|
| 121 | {
|
| 122 | i1 = 16;
|
| 123 | }
|
| 124 |
|
| 125 | boolean flag2 = false;
|
| 126 |
|
| 127 | for (int j1 = j2; !flag2 && j1 < k; ++j1)
|
| 128 | {
|
| 129 | for (int k1 = l2; !flag2 && k1 < i1; ++k1)
|
| 130 | {
|
| 131 | for (int l1 = l + 1; !flag2 && l1 >= k2 - 1; --l1)
|
| 132 | {
|
| 133 | if (l1 >= 0 && l1 < 128)
|
| 134 | {
|
| 135 | IBlockState iblockstate = p_180704_5_.getBlockState(j1, l1, k1);
|
| 136 |
|
| 137 | if (iblockstate.getBlock() == Blocks.flowing_lava || iblockstate.getBlock() == Blocks.lava)
|
| 138 | {
|
| 139 | flag2 = true;
|
| 140 | }
|
| 141 |
|
| 142 | if (l1 != k2 - 1 && j1 != j2 && j1 != k - 1 && k1 != l2 && k1 != i1 - 1)
|
| 143 | {
|
| 144 | l1 = k2;
|
| 145 | }
|
| 146 | }
|
| 147 | }
|
| 148 | }
|
| 149 | }
|
| 150 |
|
| 151 | if (!flag2)
|
| 152 | {
|
| 153 | for (int i3 = j2; i3 < k; ++i3)
|
| 154 | {
|
| 155 | double d10 = ((double)(i3 + p_180704_3_ * 16) + 0.5D - p_180704_6_) / d2;
|
| 156 |
|
| 157 | for (int j3 = l2; j3 < i1; ++j3)
|
| 158 | {
|
| 159 | double d8 = ((double)(j3 + p_180704_4_ * 16) + 0.5D - p_180704_10_) / d2;
|
| 160 |
|
| 161 | for (int i2 = l; i2 > k2; --i2)
|
| 162 | {
|
| 163 | double d9 = ((double)(i2 - 1) + 0.5D - p_180704_8_) / d3;
|
| 164 |
|
| 165 | if (d9 > -0.7D && d10 * d10 + d9 * d9 + d8 * d8 < 1.0D)
|
| 166 | {
|
| 167 | IBlockState iblockstate1 = p_180704_5_.getBlockState(i3, i2, j3);
|
| 168 |
|
| 169 | if (iblockstate1.getBlock() == Blocks.netherrack || iblockstate1.getBlock() == Blocks.dirt || iblockstate1.getBlock() == Blocks.grass)
|
| 170 | {
|
| 171 | p_180704_5_.setBlockState(i3, i2, j3, Blocks.air.getDefaultState());
|
| 172 | }
|
| 173 | }
|
| 174 | }
|
| 175 | }
|
| 176 | }
|
| 177 |
|
| 178 | if (flag1)
|
| 179 | {
|
| 180 | break;
|
| 181 | }
|
| 182 | }
|
| 183 | }
|
| 184 | }
|
| 185 | }
|
| 186 | }
|
| 187 |
|
| 188 | /**
|
| 189 | * Recursively called by generate()
|
| 190 | */
|
| 191 | protected void recursiveGenerate(World worldIn, int chunkX, int chunkZ, int p_180701_4_, int p_180701_5_, ChunkPrimer chunkPrimerIn)
|
| 192 | {
|
| 193 | int i = this.rand.nextInt(this.rand.nextInt(this.rand.nextInt(10) + 1) + 1);
|
| 194 |
|
| 195 | if (this.rand.nextInt(5) != 0)
|
| 196 | {
|
| 197 | i = 0;
|
| 198 | }
|
| 199 |
|
| 200 | for (int j = 0; j < i; ++j)
|
| 201 | {
|
| 202 | double d0 = (double)(chunkX * 16 + this.rand.nextInt(16));
|
| 203 | double d1 = (double)this.rand.nextInt(128);
|
| 204 | double d2 = (double)(chunkZ * 16 + this.rand.nextInt(16));
|
| 205 | int k = 1;
|
| 206 |
|
| 207 | if (this.rand.nextInt(4) == 0)
|
| 208 | {
|
| 209 | this.func_180705_a(this.rand.nextLong(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2);
|
| 210 | k += this.rand.nextInt(4);
|
| 211 | }
|
| 212 |
|
| 213 | for (int l = 0; l < k; ++l)
|
| 214 | {
|
| 215 | float f = this.rand.nextFloat() * (float)Math.PI * 2.0F;
|
| 216 | float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F;
|
| 217 | float f2 = this.rand.nextFloat() * 2.0F + this.rand.nextFloat();
|
| 218 | this.func_180704_a(this.rand.nextLong(), p_180701_4_, p_180701_5_, chunkPrimerIn, d0, d1, d2, f2 * 2.0F, f, f1, 0, 0, 0.5D);
|
| 219 | }
|
| 220 | }
|
| 221 | }
|
| 222 | }
|
| 223 |
|