Advertisement
Guest User

Untitled

a guest
Dec 29th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.20 KB | None | 0 0
  1. package mineworld.world.biomes;
  2. import java.util.Random;
  3.  
  4. import mineworld.core.MWBlocks;
  5. import mineworld.entities.EntityCorruptor;
  6. import mineworld.world.gen.WorldGenCorruptedTree;
  7. import mineworld.world.gen.crate.WorldGenCorruptedCrate;
  8. import net.minecraft.block.Block;
  9. import net.minecraft.block.material.Material;
  10. import net.minecraft.entity.Entity;
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.world.World;
  13. import net.minecraft.world.biome.BiomeGenBase;
  14. import net.minecraft.world.gen.feature.WorldGenAbstractTree;
  15. import net.minecraft.world.gen.feature.WorldGenBigMushroom;
  16. public class BiomeGenCorrupted extends BiomeGenBase
  17. {
  18. WorldGenCorruptedTree worldGenTrees = new WorldGenCorruptedTree(false);
  19. int portal_generated = 0;
  20. int crate_x, crate_z;
  21. boolean has_crate_spawned;
  22. public BiomeGenCorrupted(int par1)
  23. {
  24. super(par1);
  25. this.portal_generated = 0;
  26. //this.theBiomeDecorator.treesPerChunk = 5;
  27. this.setHeight(BiomeGenBase.height_MidHills);
  28. this.topBlock = MWBlocks.corrupted_grass;
  29. //this.topBlock = Blocks.grass;
  30. this.fillerBlock = MWBlocks.corrupted_dirt;
  31. Random rand = new Random();
  32. this.crate_x = 200 + rand.nextInt(56);
  33. this.crate_z = 200 + rand.nextInt(56);
  34. this.has_crate_spawned = false;
  35. }
  36.  
  37. public WorldGenAbstractTree getRandomWorldGenForTrees(Random par1)
  38. {
  39. return (WorldGenAbstractTree) worldGenTrees;
  40. }
  41.  
  42. public void decorate(World par1World, Random par2Random, int par3, int par4)
  43. {
  44. int k;
  45. int l;
  46. int i1;
  47. int j1;
  48. int k1;
  49.  
  50. for (k = 0; k < 2; ++k)
  51. {
  52. for (l = 0; l < 2; ++l)
  53. {
  54. i1 = par3 + k * 4 + 1 + 8 + par2Random.nextInt(3);
  55. j1 = par4 + l * 4 + 1 + 8 + par2Random.nextInt(3);
  56. k1 = par1World.getHeightValue(i1, j1);
  57.  
  58. if (par2Random.nextInt(20) == 0)
  59. {
  60. WorldGenBigMushroom worldgenbigmushroom = new WorldGenBigMushroom();
  61. worldgenbigmushroom.generate(par1World, par2Random, i1, k1, j1);
  62. }
  63. else
  64. {
  65. WorldGenAbstractTree worldgenabstracttree = this.getRandomWorldGenForTrees(par2Random);
  66. worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D);
  67.  
  68. if (worldgenabstracttree.generate(par1World, par2Random, i1, k1, j1))
  69. {
  70. worldgenabstracttree.func_150524_b(par1World, par2Random, i1, k1, j1);
  71. }
  72. }
  73. }
  74. }
  75.  
  76. Entity corrupter = par1World.getEntityByID(new EntityCorruptor(par1World).getEntityId());
  77. if(corrupter == null)
  78. {
  79. int j = 80;
  80. if(this.has_crate_spawned == false)
  81. {
  82. System.out.println("Crate generated at: " + crate_x + " par1World.getTopSolidOrLiquidBlock(crate_x, crate_z) " + crate_z);
  83. new WorldGenCorruptedCrate().generate(par1World, par2Random, crate_x, par1World.getTopSolidOrLiquidBlock(crate_x, crate_z), crate_z);
  84. this.has_crate_spawned = true;
  85. }
  86. }
  87.  
  88.  
  89. super.decorate(par1World, par2Random, par3, par4);
  90. }
  91.  
  92. @Override
  93. public void genTerrainBlocks(World world, Random random, Block[] blocks, byte[] bytes, int int1, int int2, double d) {
  94. boolean flag = true;
  95. Block block = this.topBlock;
  96. byte b0 = (byte)(this.field_150604_aj & 255);
  97. Block block1 = this.fillerBlock;
  98. int k = -1;
  99. int l = (int)(d / 3.0D + 3.0D + random.nextDouble() * 0.25D);
  100. int i1 = int1 & 15;
  101. int j1 = int2 & 15;
  102. int k1 = blocks.length / 256;
  103.  
  104. for (int l1 = 255; l1 >= 0; --l1)
  105. {
  106. int i2 = (j1 * 16 + i1) * k1 + l1;
  107.  
  108. if (l1 <= 0 + random.nextInt(5))
  109. {
  110. blocks[i2] = Blocks.bedrock;
  111. }
  112. else
  113. {
  114. Block block2 = blocks[i2];
  115.  
  116. if (block2 != null && block2.getMaterial() != Material.air)
  117. {
  118. if (block2 == MWBlocks.corrupted_stone || block2 == Blocks.grass || block2 == Blocks.stone)
  119. {
  120. if (k == -1)
  121. {
  122. if (l <= 0)
  123. {
  124. block = null;
  125. b0 = 0;
  126. block1 = MWBlocks.corrupted_grass;
  127. }
  128. else if (l1 >= 59 && l1 <= 64)
  129. {
  130. block = this.topBlock;
  131. b0 = (byte)(this.field_150604_aj & 255);
  132. block1 = this.fillerBlock;
  133. }
  134.  
  135. if (l1 < 63 && (block == null || block.getMaterial() == Material.air))
  136. {
  137. if (this.getFloatTemperature(int1, l1, int2) < 0.15F)
  138. {
  139. block = Blocks.ice;
  140. b0 = 0;
  141. }
  142. else
  143. {
  144. block = MWBlocks.corrupted_water;
  145. b0 = 0;
  146. }
  147. }
  148.  
  149. k = l;
  150.  
  151. if (l1 >= 62)
  152. {
  153. blocks[i2] = block;
  154. bytes[i2] = b0;
  155. }
  156. else if (l1 < 56 - l)
  157. {
  158. block = null;
  159. block1 = MWBlocks.corrupted_dirt;
  160. blocks[i2] = Blocks.gravel;
  161. }
  162. else
  163. {
  164. blocks[i2] = block1;
  165. }
  166. }
  167. else if (k > 0)
  168. {
  169. --k;
  170. blocks[i2] = block1;
  171.  
  172. if (k == 0 && block1 == Blocks.sand)
  173. {
  174. k = random.nextInt(4) + Math.max(0, l1 - 63);
  175. block1 = Blocks.sandstone;
  176. }
  177. }
  178. }
  179. if(block2 == Blocks.dirt)
  180. {
  181. block = null;
  182. b0 = 0;
  183. block1 = MWBlocks.corrupted_dirt;
  184. }
  185. if(block2 == Blocks.water || block2 == Blocks.flowing_water)
  186. {
  187. block = null;
  188. b0 = 0;
  189. block1 = MWBlocks.corrupted_water;
  190. }
  191. }
  192. else
  193. {
  194. k = -1;
  195. }
  196. }
  197. }
  198. }
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement