Camellias_

ChunkProviderHell

May 8th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 24.35 KB | None | 0 0
  1. package net.minecraft.world.gen;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5. import javax.annotation.Nullable;
  6. import net.minecraft.block.BlockFalling;
  7. import net.minecraft.block.material.Material;
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.block.state.pattern.BlockMatcher;
  10. import net.minecraft.entity.EnumCreatureType;
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraft.util.math.ChunkPos;
  14. import net.minecraft.util.math.MathHelper;
  15. import net.minecraft.world.World;
  16. import net.minecraft.world.biome.Biome;
  17. import net.minecraft.world.chunk.Chunk;
  18. import net.minecraft.world.chunk.ChunkPrimer;
  19. import net.minecraft.world.gen.feature.WorldGenBush;
  20. import net.minecraft.world.gen.feature.WorldGenFire;
  21. import net.minecraft.world.gen.feature.WorldGenGlowStone1;
  22. import net.minecraft.world.gen.feature.WorldGenGlowStone2;
  23. import net.minecraft.world.gen.feature.WorldGenHellLava;
  24. import net.minecraft.world.gen.feature.WorldGenMinable;
  25. import net.minecraft.world.gen.feature.WorldGenerator;
  26. import net.minecraft.world.gen.structure.MapGenNetherBridge;
  27.  
  28. public class ChunkGeneratorHell implements IChunkGenerator
  29. {
  30.     protected static final IBlockState AIR = Blocks.AIR.getDefaultState();
  31.     protected static final IBlockState NETHERRACK = Blocks.NETHERRACK.getDefaultState();
  32.     protected static final IBlockState BEDROCK = Blocks.BEDROCK.getDefaultState();
  33.     protected static final IBlockState LAVA = Blocks.LAVA.getDefaultState();
  34.     protected static final IBlockState GRAVEL = Blocks.GRAVEL.getDefaultState();
  35.     protected static final IBlockState SOUL_SAND = Blocks.SOUL_SAND.getDefaultState();
  36.     private final World world;
  37.     private final boolean generateStructures;
  38.     private final Random rand;
  39.     /** Holds the noise used to determine whether slowsand can be generated at a location */
  40.     private double[] slowsandNoise = new double[256];
  41.     private double[] gravelNoise = new double[256];
  42.     private double[] depthBuffer = new double[256];
  43.     private double[] buffer;
  44.     private NoiseGeneratorOctaves lperlinNoise1;
  45.     private NoiseGeneratorOctaves lperlinNoise2;
  46.     private NoiseGeneratorOctaves perlinNoise1;
  47.     /** Determines whether slowsand or gravel can be generated at a location */
  48.     private NoiseGeneratorOctaves slowsandGravelNoiseGen;
  49.     /** Determines whether something other than nettherack can be generated at a location */
  50.     private NoiseGeneratorOctaves netherrackExculsivityNoiseGen;
  51.     public NoiseGeneratorOctaves scaleNoise;
  52.     public NoiseGeneratorOctaves depthNoise;
  53.     private final WorldGenFire fireFeature = new WorldGenFire();
  54.     private final WorldGenGlowStone1 lightGemGen = new WorldGenGlowStone1();
  55.     private final WorldGenGlowStone2 hellPortalGen = new WorldGenGlowStone2();
  56.     private final WorldGenerator quartzGen = new WorldGenMinable(Blocks.QUARTZ_ORE.getDefaultState(), 14, BlockMatcher.forBlock(Blocks.NETHERRACK));
  57.     private final WorldGenerator magmaGen = new WorldGenMinable(Blocks.MAGMA.getDefaultState(), 33, BlockMatcher.forBlock(Blocks.NETHERRACK));
  58.     private final WorldGenHellLava lavaTrapGen = new WorldGenHellLava(Blocks.FLOWING_LAVA, true);
  59.     private final WorldGenHellLava hellSpringGen = new WorldGenHellLava(Blocks.FLOWING_LAVA, false);
  60.     private final WorldGenBush brownMushroomFeature = new WorldGenBush(Blocks.BROWN_MUSHROOM);
  61.     private final WorldGenBush redMushroomFeature = new WorldGenBush(Blocks.RED_MUSHROOM);
  62.     private MapGenNetherBridge genNetherBridge = new MapGenNetherBridge();
  63.     private MapGenBase genNetherCaves = new MapGenCavesHell();
  64.     double[] pnr;
  65.     double[] ar;
  66.     double[] br;
  67.     double[] noiseData4;
  68.     double[] dr;
  69.  
  70.     public ChunkGeneratorHell(World worldIn, boolean p_i45637_2_, long seed)
  71.     {
  72.         this.world = worldIn;
  73.         this.generateStructures = p_i45637_2_;
  74.         this.rand = new Random(seed);
  75.         this.lperlinNoise1 = new NoiseGeneratorOctaves(this.rand, 16);
  76.         this.lperlinNoise2 = new NoiseGeneratorOctaves(this.rand, 16);
  77.         this.perlinNoise1 = new NoiseGeneratorOctaves(this.rand, 8);
  78.         this.slowsandGravelNoiseGen = new NoiseGeneratorOctaves(this.rand, 4);
  79.         this.netherrackExculsivityNoiseGen = new NoiseGeneratorOctaves(this.rand, 4);
  80.         this.scaleNoise = new NoiseGeneratorOctaves(this.rand, 10);
  81.         this.depthNoise = new NoiseGeneratorOctaves(this.rand, 16);
  82.         worldIn.setSeaLevel(63);
  83.  
  84.         net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell ctx =
  85.                 new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell(lperlinNoise1, lperlinNoise2, perlinNoise1, slowsandGravelNoiseGen, netherrackExculsivityNoiseGen, scaleNoise, depthNoise);
  86.         ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(worldIn, this.rand, ctx);
  87.         this.lperlinNoise1 = ctx.getLPerlin1();
  88.         this.lperlinNoise2 = ctx.getLPerlin2();
  89.         this.perlinNoise1 = ctx.getPerlin();
  90.         this.slowsandGravelNoiseGen = ctx.getPerlin2();
  91.         this.netherrackExculsivityNoiseGen = ctx.getPerlin3();
  92.         this.scaleNoise = ctx.getScale();
  93.         this.depthNoise = ctx.getDepth();
  94.         this.genNetherBridge = (MapGenNetherBridge)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(genNetherBridge, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_BRIDGE);
  95.         this.genNetherCaves = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(genNetherCaves, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_CAVE);
  96.     }
  97.  
  98.     public void prepareHeights(int p_185936_1_, int p_185936_2_, ChunkPrimer primer)
  99.     {
  100.         int i = 4;
  101.         int j = this.world.getSeaLevel() / 2 + 1;
  102.         int k = 5;
  103.         int l = 17;
  104.         int i1 = 5;
  105.         this.buffer = this.getHeights(this.buffer, p_185936_1_ * 4, 0, p_185936_2_ * 4, 5, 17, 5);
  106.  
  107.         for (int j1 = 0; j1 < 4; ++j1)
  108.         {
  109.             for (int k1 = 0; k1 < 4; ++k1)
  110.             {
  111.                 for (int l1 = 0; l1 < 16; ++l1)
  112.                 {
  113.                     double d0 = 0.125D;
  114.                     double d1 = this.buffer[((j1 + 0) * 5 + k1 + 0) * 17 + l1 + 0];
  115.                     double d2 = this.buffer[((j1 + 0) * 5 + k1 + 1) * 17 + l1 + 0];
  116.                     double d3 = this.buffer[((j1 + 1) * 5 + k1 + 0) * 17 + l1 + 0];
  117.                     double d4 = this.buffer[((j1 + 1) * 5 + k1 + 1) * 17 + l1 + 0];
  118.                     double d5 = (this.buffer[((j1 + 0) * 5 + k1 + 0) * 17 + l1 + 1] - d1) * 0.125D;
  119.                     double d6 = (this.buffer[((j1 + 0) * 5 + k1 + 1) * 17 + l1 + 1] - d2) * 0.125D;
  120.                     double d7 = (this.buffer[((j1 + 1) * 5 + k1 + 0) * 17 + l1 + 1] - d3) * 0.125D;
  121.                     double d8 = (this.buffer[((j1 + 1) * 5 + k1 + 1) * 17 + l1 + 1] - d4) * 0.125D;
  122.  
  123.                     for (int i2 = 0; i2 < 8; ++i2)
  124.                     {
  125.                         double d9 = 0.25D;
  126.                         double d10 = d1;
  127.                         double d11 = d2;
  128.                         double d12 = (d3 - d1) * 0.25D;
  129.                         double d13 = (d4 - d2) * 0.25D;
  130.  
  131.                         for (int j2 = 0; j2 < 4; ++j2)
  132.                         {
  133.                             double d14 = 0.25D;
  134.                             double d15 = d10;
  135.                             double d16 = (d11 - d10) * 0.25D;
  136.  
  137.                             for (int k2 = 0; k2 < 4; ++k2)
  138.                             {
  139.                                 IBlockState iblockstate = null;
  140.  
  141.                                 if (l1 * 8 + i2 < j)
  142.                                 {
  143.                                     iblockstate = LAVA;
  144.                                 }
  145.  
  146.                                 if (d15 > 0.0D)
  147.                                 {
  148.                                     iblockstate = NETHERRACK;
  149.                                 }
  150.  
  151.                                 int l2 = j2 + j1 * 4;
  152.                                 int i3 = i2 + l1 * 8;
  153.                                 int j3 = k2 + k1 * 4;
  154.                                 primer.setBlockState(l2, i3, j3, iblockstate);
  155.                                 d15 += d16;
  156.                             }
  157.  
  158.                             d10 += d12;
  159.                             d11 += d13;
  160.                         }
  161.  
  162.                         d1 += d5;
  163.                         d2 += d6;
  164.                         d3 += d7;
  165.                         d4 += d8;
  166.                     }
  167.                 }
  168.             }
  169.         }
  170.     }
  171.  
  172.     public void buildSurfaces(int p_185937_1_, int p_185937_2_, ChunkPrimer primer)
  173.     {
  174.         if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185937_1_, p_185937_2_, primer, this.world)) return;
  175.         int i = this.world.getSeaLevel() + 1;
  176.         double d0 = 0.03125D;
  177.         this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.03125D, 0.03125D, 1.0D);
  178.         this.gravelNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.gravelNoise, p_185937_1_ * 16, 109, p_185937_2_ * 16, 16, 1, 16, 0.03125D, 1.0D, 0.03125D);
  179.         this.depthBuffer = this.netherrackExculsivityNoiseGen.generateNoiseOctaves(this.depthBuffer, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.0625D, 0.0625D, 0.0625D);
  180.  
  181.         for (int j = 0; j < 16; ++j)
  182.         {
  183.             for (int k = 0; k < 16; ++k)
  184.             {
  185.                 boolean flag = this.slowsandNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D;
  186.                 boolean flag1 = this.gravelNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D;
  187.                 int l = (int)(this.depthBuffer[j + k * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);
  188.                 int i1 = -1;
  189.                 IBlockState iblockstate = NETHERRACK;
  190.                 IBlockState iblockstate1 = NETHERRACK;
  191.  
  192.                 for (int j1 = 127; j1 >= 0; --j1)
  193.                 {
  194.                     if (j1 < 127 - this.rand.nextInt(5) && j1 > this.rand.nextInt(5))
  195.                     {
  196.                         IBlockState iblockstate2 = primer.getBlockState(k, j1, j);
  197.  
  198.                         if (iblockstate2.getBlock() != null && iblockstate2.getMaterial() != Material.AIR)
  199.                         {
  200.                             if (iblockstate2.getBlock() == Blocks.NETHERRACK)
  201.                             {
  202.                                 if (i1 == -1)
  203.                                 {
  204.                                     if (l <= 0)
  205.                                     {
  206.                                         iblockstate = AIR;
  207.                                         iblockstate1 = NETHERRACK;
  208.                                     }
  209.                                     else if (j1 >= i - 4 && j1 <= i + 1)
  210.                                     {
  211.                                         iblockstate = NETHERRACK;
  212.                                         iblockstate1 = NETHERRACK;
  213.  
  214.                                         if (flag1)
  215.                                         {
  216.                                             iblockstate = GRAVEL;
  217.                                             iblockstate1 = NETHERRACK;
  218.                                         }
  219.  
  220.                                         if (flag)
  221.                                         {
  222.                                             iblockstate = SOUL_SAND;
  223.                                             iblockstate1 = SOUL_SAND;
  224.                                         }
  225.                                     }
  226.  
  227.                                     if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR))
  228.                                     {
  229.                                         iblockstate = LAVA;
  230.                                     }
  231.  
  232.                                     i1 = l;
  233.  
  234.                                     if (j1 >= i - 1)
  235.                                     {
  236.                                         primer.setBlockState(k, j1, j, iblockstate);
  237.                                     }
  238.                                     else
  239.                                     {
  240.                                         primer.setBlockState(k, j1, j, iblockstate1);
  241.                                     }
  242.                                 }
  243.                                 else if (i1 > 0)
  244.                                 {
  245.                                     --i1;
  246.                                     primer.setBlockState(k, j1, j, iblockstate1);
  247.                                 }
  248.                             }
  249.                         }
  250.                         else
  251.                         {
  252.                             i1 = -1;
  253.                         }
  254.                     }
  255.                     else
  256.                     {
  257.                         primer.setBlockState(k, j1, j, BEDROCK);
  258.                     }
  259.                 }
  260.             }
  261.         }
  262.     }
  263.  
  264.     /**
  265.      * Generates the chunk at the specified position, from scratch
  266.      */
  267.     public Chunk generateChunk(int x, int z)
  268.     {
  269.         this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
  270.         ChunkPrimer chunkprimer = new ChunkPrimer();
  271.         this.prepareHeights(x, z, chunkprimer);
  272.         this.buildSurfaces(x, z, chunkprimer);
  273.         this.genNetherCaves.generate(this.world, x, z, chunkprimer);
  274.  
  275.         if (this.generateStructures)
  276.         {
  277.             this.genNetherBridge.generate(this.world, x, z, chunkprimer);
  278.         }
  279.  
  280.         Chunk chunk = new Chunk(this.world, chunkprimer, x, z);
  281.         Biome[] abiome = this.world.getBiomeProvider().getBiomes((Biome[])null, x * 16, z * 16, 16, 16);
  282.         byte[] abyte = chunk.getBiomeArray();
  283.  
  284.         for (int i = 0; i < abyte.length; ++i)
  285.         {
  286.             abyte[i] = (byte)Biome.getIdForBiome(abiome[i]);
  287.         }
  288.  
  289.         chunk.resetRelightChecks();
  290.         return chunk;
  291.     }
  292.  
  293.     private double[] getHeights(double[] p_185938_1_, int p_185938_2_, int p_185938_3_, int p_185938_4_, int p_185938_5_, int p_185938_6_, int p_185938_7_)
  294.     {
  295.         if (p_185938_1_ == null)
  296.         {
  297.             p_185938_1_ = new double[p_185938_5_ * p_185938_6_ * p_185938_7_];
  298.         }
  299.  
  300.         net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, p_185938_1_, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_);
  301.         net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
  302.         if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getNoisefield();
  303.  
  304.         double d0 = 684.412D;
  305.         double d1 = 2053.236D;
  306.         this.noiseData4 = this.scaleNoise.generateNoiseOctaves(this.noiseData4, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, 1, p_185938_7_, 1.0D, 0.0D, 1.0D);
  307.         this.dr = this.depthNoise.generateNoiseOctaves(this.dr, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, 1, p_185938_7_, 100.0D, 0.0D, 100.0D);
  308.         this.pnr = this.perlinNoise1.generateNoiseOctaves(this.pnr, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_, 8.555150000000001D, 34.2206D, 8.555150000000001D);
  309.         this.ar = this.lperlinNoise1.generateNoiseOctaves(this.ar, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_, 684.412D, 2053.236D, 684.412D);
  310.         this.br = this.lperlinNoise2.generateNoiseOctaves(this.br, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_, 684.412D, 2053.236D, 684.412D);
  311.         int i = 0;
  312.         double[] adouble = new double[p_185938_6_];
  313.  
  314.         for (int j = 0; j < p_185938_6_; ++j)
  315.         {
  316.             adouble[j] = Math.cos((double)j * Math.PI * 6.0D / (double)p_185938_6_) * 2.0D;
  317.             double d2 = (double)j;
  318.  
  319.             if (j > p_185938_6_ / 2)
  320.             {
  321.                 d2 = (double)(p_185938_6_ - 1 - j);
  322.             }
  323.  
  324.             if (d2 < 4.0D)
  325.             {
  326.                 d2 = 4.0D - d2;
  327.                 adouble[j] -= d2 * d2 * d2 * 10.0D;
  328.             }
  329.         }
  330.  
  331.         for (int l = 0; l < p_185938_5_; ++l)
  332.         {
  333.             for (int i1 = 0; i1 < p_185938_7_; ++i1)
  334.             {
  335.                 double d3 = 0.0D;
  336.  
  337.                 for (int k = 0; k < p_185938_6_; ++k)
  338.                 {
  339.                     double d4 = adouble[k];
  340.                     double d5 = this.ar[i] / 512.0D;
  341.                     double d6 = this.br[i] / 512.0D;
  342.                     double d7 = (this.pnr[i] / 10.0D + 1.0D) / 2.0D;
  343.                     double d8;
  344.  
  345.                     if (d7 < 0.0D)
  346.                     {
  347.                         d8 = d5;
  348.                     }
  349.                     else if (d7 > 1.0D)
  350.                     {
  351.                         d8 = d6;
  352.                     }
  353.                     else
  354.                     {
  355.                         d8 = d5 + (d6 - d5) * d7;
  356.                     }
  357.  
  358.                     d8 = d8 - d4;
  359.  
  360.                     if (k > p_185938_6_ - 4)
  361.                     {
  362.                         double d9 = (double)((float)(k - (p_185938_6_ - 4)) / 3.0F);
  363.                         d8 = d8 * (1.0D - d9) + -10.0D * d9;
  364.                     }
  365.  
  366.                     if ((double)k < 0.0D)
  367.                     {
  368.                         double d10 = (0.0D - (double)k) / 4.0D;
  369.                         d10 = MathHelper.clamp(d10, 0.0D, 1.0D);
  370.                         d8 = d8 * (1.0D - d10) + -10.0D * d10;
  371.                     }
  372.  
  373.                     p_185938_1_[i] = d8;
  374.                     ++i;
  375.                 }
  376.             }
  377.         }
  378.  
  379.         return p_185938_1_;
  380.     }
  381.  
  382.     /**
  383.      * Generate initial structures in this chunk, e.g. mineshafts, temples, lakes, and dungeons
  384.      */
  385.     public void populate(int x, int z)
  386.     {
  387.         BlockFalling.fallInstantly = true;
  388.         net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.world, this.rand, x, z, false);
  389.         int i = x * 16;
  390.         int j = z * 16;
  391.         BlockPos blockpos = new BlockPos(i, 0, j);
  392.         Biome biome = this.world.getBiome(blockpos.add(16, 0, 16));
  393.         ChunkPos chunkpos = new ChunkPos(x, z);
  394.         this.genNetherBridge.generateStructure(this.world, this.rand, chunkpos);
  395.  
  396.         if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA))
  397.         for (int k = 0; k < 8; ++k)
  398.         {
  399.             this.hellSpringGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(120) + 4, this.rand.nextInt(16) + 8));
  400.         }
  401.  
  402.         if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.FIRE))
  403.         for (int i1 = 0; i1 < this.rand.nextInt(this.rand.nextInt(10) + 1) + 1; ++i1)
  404.         {
  405.             this.fireFeature.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(120) + 4, this.rand.nextInt(16) + 8));
  406.         }
  407.  
  408.         if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.GLOWSTONE))
  409.         {
  410.         for (int j1 = 0; j1 < this.rand.nextInt(this.rand.nextInt(10) + 1); ++j1)
  411.         {
  412.             this.lightGemGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(120) + 4, this.rand.nextInt(16) + 8));
  413.         }
  414.  
  415.         for (int k1 = 0; k1 < 10; ++k1)
  416.         {
  417.             this.hellPortalGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(128), this.rand.nextInt(16) + 8));
  418.         }
  419.         }//Forge: End doGLowstone
  420.  
  421.         net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, x, z, false);
  422.         net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Pre(this.world, this.rand, blockpos));
  423.  
  424.         if (net.minecraftforge.event.terraingen.TerrainGen.decorate(this.world, this.rand, blockpos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM))
  425.         {
  426.         if (this.rand.nextBoolean())
  427.         {
  428.             this.brownMushroomFeature.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(128), this.rand.nextInt(16) + 8));
  429.         }
  430.  
  431.         if (this.rand.nextBoolean())
  432.         {
  433.             this.redMushroomFeature.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + 8, this.rand.nextInt(128), this.rand.nextInt(16) + 8));
  434.         }
  435.         }
  436.  
  437.  
  438.         if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(this.world, this.rand, quartzGen, blockpos, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.QUARTZ))
  439.         for (int l1 = 0; l1 < 16; ++l1)
  440.         {
  441.             this.quartzGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16), this.rand.nextInt(108) + 10, this.rand.nextInt(16)));
  442.         }
  443.  
  444.         int i2 = this.world.getSeaLevel() / 2 + 1;
  445.  
  446.         if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_MAGMA))
  447.         for (int l = 0; l < 4; ++l)
  448.         {
  449.             this.magmaGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16), i2 - 5 + this.rand.nextInt(10), this.rand.nextInt(16)));
  450.         }
  451.  
  452.         if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA2))
  453.         for (int j2 = 0; j2 < 16; ++j2)
  454.         {
  455.             int offset = net.minecraftforge.common.ForgeModContainer.fixVanillaCascading ? 8 : 0; // MC-117810
  456.             this.lavaTrapGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16) + offset, this.rand.nextInt(108) + 10, this.rand.nextInt(16) + offset));
  457.         }
  458.  
  459.         biome.decorate(this.world, this.rand, new BlockPos(i, 0, j));
  460.  
  461.         net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Post(this.world, this.rand, blockpos));
  462.  
  463.         BlockFalling.fallInstantly = false;
  464.     }
  465.  
  466.     /**
  467.      * Called to generate additional structures after initial worldgen, used by ocean monuments
  468.      */
  469.     public boolean generateStructures(Chunk chunkIn, int x, int z)
  470.     {
  471.         return false;
  472.     }
  473.  
  474.     public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos)
  475.     {
  476.         if (creatureType == EnumCreatureType.MONSTER)
  477.         {
  478.             if (this.genNetherBridge.isInsideStructure(pos))
  479.             {
  480.                 return this.genNetherBridge.getSpawnList();
  481.             }
  482.  
  483.             if (this.genNetherBridge.isPositionInStructure(this.world, pos) && this.world.getBlockState(pos.down()).getBlock() == Blocks.NETHER_BRICK)
  484.             {
  485.                 return this.genNetherBridge.getSpawnList();
  486.             }
  487.         }
  488.  
  489.         Biome biome = this.world.getBiome(pos);
  490.         return biome.getSpawnableList(creatureType);
  491.     }
  492.  
  493.     @Nullable
  494.     public BlockPos getNearestStructurePos(World worldIn, String structureName, BlockPos position, boolean findUnexplored)
  495.     {
  496.         return "Fortress".equals(structureName) && this.genNetherBridge != null ? this.genNetherBridge.getNearestStructurePos(worldIn, position, findUnexplored) : null;
  497.     }
  498.  
  499.     public boolean isInsideStructure(World worldIn, String structureName, BlockPos pos)
  500.     {
  501.         return "Fortress".equals(structureName) && this.genNetherBridge != null ? this.genNetherBridge.isInsideStructure(pos) : false;
  502.     }
  503.  
  504.     /**
  505.      * Recreates data about structures intersecting given chunk (used for example by getPossibleCreatures), without
  506.      * placing any blocks. When called for the first time before any chunk is generated - also initializes the internal
  507.      * state needed by getPossibleCreatures.
  508.      */
  509.     public void recreateStructures(Chunk chunkIn, int x, int z)
  510.     {
  511.         this.genNetherBridge.generate(this.world, x, z, (ChunkPrimer)null);
  512.     }
  513. }
Advertisement
Add Comment
Please, Sign In to add comment