Advertisement
Guest User

Untitled

a guest
May 7th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.47 KB | None | 0 0
  1. package ShadoTECH.Util;
  2.  
  3. import java.util.Random;
  4.  
  5. import ShadoTECH.sT_Blocks;
  6. import net.minecraft.block.Block;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.world.World;
  9. import net.minecraft.world.biome.BiomeGenBase;
  10. import net.minecraft.world.biome.BiomeGenBeach;
  11. import net.minecraft.world.biome.BiomeGenDesert;
  12. import net.minecraft.world.biome.BiomeGenHills;
  13. import net.minecraft.world.biome.BiomeGenOcean;
  14. import net.minecraft.world.chunk.IChunkProvider;
  15. import net.minecraft.world.gen.feature.WorldGenMinable;
  16. import net.minecraftforge.common.BiomeDictionary;
  17. import net.minecraftforge.common.BiomeDictionary.Type;
  18. import cpw.mods.fml.common.IWorldGenerator;
  19.  
  20. public class OreWorldGenerator implements IWorldGenerator
  21. {
  22. @Override
  23. public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
  24. {
  25. switch(world.provider.dimensionId)
  26. {
  27. case 0:
  28. //Overworld
  29. generateSurface(world, random, chunkX * 16, chunkZ * 16);
  30. customOverworld(world, random, chunkX, chunkZ);
  31. case -1:
  32. //Nether
  33. customNether(world, random, chunkX, chunkZ);
  34. break;
  35. }
  36. }
  37.  
  38. public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY)
  39. {
  40. int maxPossY = minY + (maxY - 1);
  41. assert maxY > minY: "The maximum Y must be greater than the Minimum Y";
  42. assert maxX > 0 && maxX <= 16: "addOreSpawn: The Maximum X must be greater than 0 and less than 16";
  43. assert minY > 0: "addOreSpawn: The Minimum Y must be greater than 0";
  44. assert maxY < 256 && maxY > 0: "addOreSpawn: The Maximum Y must be less than 256 but greater than 0";
  45. assert maxZ > 0 && maxZ <= 16: "addOreSpawn: The Maximum Z must be greater than 0 and less than 16";
  46.  
  47. int diffBtwnMinMaxY = maxY - minY;
  48. for(int x = 0; x < chancesToSpawn; x++)
  49. {
  50. int posX = blockXPos + random.nextInt(maxX);
  51. int posY = minY + random.nextInt(diffBtwnMinMaxY);
  52. int posZ = blockZPos + random.nextInt(maxZ);
  53. (new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
  54. }
  55. }
  56.  
  57. public void customOverworld(World world, Random random, int chunkX, int chunkZ)
  58. {
  59. for(int x = 0; x < 16; x++)
  60. {
  61. for(int z = 0; z < 16; z++)
  62. {
  63. if(ConfigurationHandler.FlatBedrock)
  64. {
  65. for(int y = 5; y > 0; y--)
  66. {
  67. if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
  68. {
  69. world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.stone, 0, 2);
  70. }
  71. }
  72. }
  73. if(ConfigurationHandler.RemoveBedrock)
  74. {
  75. for(int y = 5; y >= 0; y--)
  76. {
  77. if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
  78. {
  79. world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.stone, 0, 2);
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86.  
  87. public void customNether(World world, Random random, int chunkX, int chunkZ)
  88. {
  89. for(int x = 0; x < 16; x++)
  90. {
  91. for(int z = 0; z < 16; z++)
  92. {
  93. boolean isNether = world.getBiomeGenForCoords(chunkX, chunkZ).biomeName.toLowerCase().equals("hell");
  94. if(isNether)
  95. {
  96. if(ConfigurationHandler.FlatBedrockNether)
  97. {
  98. for(int y = 5; y > 0; y--)
  99. {
  100. if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
  101. {
  102. world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.netherrack, 0, 2);
  103. }
  104. }
  105. }
  106. if(ConfigurationHandler.FlatBedrockNetherCeiling)
  107. {
  108. for(int y = 126; y > 120; y--)
  109. {
  110. if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
  111. {
  112. world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.netherrack, 0, 2);
  113. }
  114. }
  115. }
  116. if(ConfigurationHandler.RemoveBedrockNether)
  117. {
  118. for(int y = 5; y >= 0; y--)
  119. {
  120. if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
  121. {
  122. world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.netherrack, 0, 2);
  123. }
  124. }
  125. }
  126. if(ConfigurationHandler.RemoveBedrockNetherCeiling)
  127. {
  128. for(int y = 127; y >= 120; y--)
  129. {
  130. if(world.getBlock(chunkX * 16 + x, y, chunkZ * 16 + z) == Blocks.bedrock)
  131. {
  132. world.setBlock(chunkX * 16 + x, y, chunkZ * 16 + z, Blocks.netherrack, 0, 2);
  133. }
  134. }
  135. }
  136. }
  137. }
  138. }
  139. }
  140.  
  141. public void generateSurface(World world, Random random, int chunkX, int chunkZ)
  142. {
  143. BiomeGenBase biome = world.getBiomeGenForCoords(chunkX, chunkZ);
  144.  
  145. if(ConfigurationHandler.EnableCopper)
  146. {
  147. if(random.nextInt(100) <= ConfigurationHandler.RarityCopper)
  148. {
  149. this.addOreSpawn(sT_Blocks.oreCopper, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeCopper, ConfigurationHandler.VeinsPerChunkCopper, ConfigurationHandler.MinCopper, ConfigurationHandler.MaxCopper);
  150. }
  151. }
  152.  
  153. if(ConfigurationHandler.EnableTin)
  154. {
  155. if(random.nextInt(100) <= ConfigurationHandler.RarityTin)
  156. {
  157. this.addOreSpawn(sT_Blocks.oreTin, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeTin, ConfigurationHandler.VeinsPerChunkTin, ConfigurationHandler.MinTin, ConfigurationHandler.MaxTin);
  158. }
  159. }
  160.  
  161. if(ConfigurationHandler.EnableUranium)
  162. {
  163. if(random.nextInt(100) <= ConfigurationHandler.RarityUranium)
  164. {
  165. this.addOreSpawn(sT_Blocks.oreUranium, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeUranium, ConfigurationHandler.VeinsPerChunkUranium, ConfigurationHandler.MinUranium, ConfigurationHandler.MaxUranium);
  166. }
  167. }
  168.  
  169. if(ConfigurationHandler.EnableSilver)
  170. {
  171. if(random.nextInt(100) <= ConfigurationHandler.RaritySilver)
  172. {
  173. this.addOreSpawn(sT_Blocks.oreSilver, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeSilver, ConfigurationHandler.VeinsPerChunkSilver, ConfigurationHandler.MinSilver, ConfigurationHandler.MaxSilver);
  174. }
  175. }
  176.  
  177. if(ConfigurationHandler.EnableLead)
  178. {
  179. if(random.nextInt(100) <= ConfigurationHandler.RarityLead)
  180. {
  181. this.addOreSpawn(sT_Blocks.oreLead, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeLead, ConfigurationHandler.VeinsPerChunkLead, ConfigurationHandler.MinLead, ConfigurationHandler.MaxLead);
  182. }
  183. }
  184.  
  185. if(ConfigurationHandler.EnableRuby)
  186. {
  187. if(random.nextInt(100) <= ConfigurationHandler.RarityRuby)
  188. {
  189. if(ConfigurationHandler.BiomeRuby == true)
  190. {
  191. if(biome instanceof BiomeGenDesert)
  192. {
  193. this.addOreSpawn(sT_Blocks.oreRuby, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeRuby, ConfigurationHandler.VeinsPerChunkRuby, ConfigurationHandler.MinRuby, ConfigurationHandler.MaxRuby);
  194. }
  195. }
  196. else
  197. {
  198. this.addOreSpawn(sT_Blocks.oreRuby, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeRuby, ConfigurationHandler.VeinsPerChunkRuby, ConfigurationHandler.MinRuby, ConfigurationHandler.MaxRuby);
  199. }
  200. }
  201. }
  202.  
  203. if(ConfigurationHandler.EnableSapphire)
  204. {
  205. if(random.nextInt(100) <= ConfigurationHandler.RaritySapphire)
  206. {
  207. if(ConfigurationHandler.BiomeSapphire == true)
  208. {
  209. if(biome instanceof BiomeGenOcean)
  210. {
  211. this.addOreSpawn(sT_Blocks.oreSapphire, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeSapphire, ConfigurationHandler.VeinsPerChunkSapphire, ConfigurationHandler.MinSapphire, ConfigurationHandler.MaxSapphire);
  212. }
  213. }
  214. else
  215. {
  216. this.addOreSpawn(sT_Blocks.oreSapphire, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeSapphire, ConfigurationHandler.VeinsPerChunkSapphire, ConfigurationHandler.MinSapphire, ConfigurationHandler.MaxSapphire);
  217. }
  218. }
  219. }
  220.  
  221. if(ConfigurationHandler.RemoveVanillaGen)
  222. {
  223. if(random.nextInt(100) <= ConfigurationHandler.RarityCoal)
  224. {
  225. this.addOreSpawn(Blocks.coal_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeCoal, ConfigurationHandler.VeinsPerChunkCoal, ConfigurationHandler.MinCoal, ConfigurationHandler.MaxCoal);
  226. }
  227.  
  228. if(random.nextInt(100) <= ConfigurationHandler.RarityIron)
  229. {
  230. this.addOreSpawn(Blocks.iron_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeIron, ConfigurationHandler.VeinsPerChunkIron, ConfigurationHandler.MinIron, ConfigurationHandler.MaxIron);
  231. }
  232.  
  233. if(random.nextInt(100) <= ConfigurationHandler.RarityGold)
  234. {
  235. this.addOreSpawn(Blocks.gold_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeGold, ConfigurationHandler.VeinsPerChunkGold, ConfigurationHandler.MinGold, ConfigurationHandler.MaxGold);
  236. }
  237.  
  238. if(random.nextInt(100) <= ConfigurationHandler.RarityDiamond)
  239. {
  240. this.addOreSpawn(Blocks.diamond_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeDiamond, ConfigurationHandler.VeinsPerChunkDiamond, ConfigurationHandler.MinDiamond, ConfigurationHandler.MaxDiamond);
  241. }
  242.  
  243. if(random.nextInt(100) <= ConfigurationHandler.RarityEmerald)
  244. {
  245. if(ConfigurationHandler.BiomeEmerald == true)
  246. {
  247. if(biome instanceof BiomeGenHills)
  248. {
  249. this.addOreSpawn(Blocks.emerald_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeEmerald, ConfigurationHandler.VeinsPerChunkEmerald, ConfigurationHandler.MinEmerald, ConfigurationHandler.MaxEmerald);
  250. }
  251. }
  252. else
  253. {
  254. this.addOreSpawn(Blocks.emerald_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeEmerald, ConfigurationHandler.VeinsPerChunkEmerald, ConfigurationHandler.MinEmerald, ConfigurationHandler.MaxEmerald);
  255. }
  256. }
  257.  
  258. if(random.nextInt(100) <= ConfigurationHandler.RarityRedstone)
  259. {
  260. this.addOreSpawn(Blocks.redstone_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeRedstone, ConfigurationHandler.VeinsPerChunkRedstone, ConfigurationHandler.MinRedstone, ConfigurationHandler.MaxRedstone);
  261. }
  262.  
  263. if(random.nextInt(100) <= ConfigurationHandler.RarityLapis)
  264. {
  265. this.addOreSpawn(Blocks.lapis_ore, world, random, chunkX, chunkZ, 16, 16, ConfigurationHandler.VeinSizeLapis, ConfigurationHandler.VeinsPerChunkLapis, ConfigurationHandler.MinLapis, ConfigurationHandler.MaxLapis);
  266. }
  267. }
  268. }
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement