Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.48 KB | None | 0 0
  1. package net.EternIsles.dimension.dustopia;
  2.  
  3. import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE;
  4.  
  5. import java.util.List;
  6. import java.util.Random;
  7.  
  8. import net.EternIsles.izer.Blockizer;
  9. import net.EternIsles.structures.barathos.BigRock1;
  10. import net.EternIsles.structures.dustopia.Cage1;
  11. import net.EternIsles.structures.dustopia.Cage2;
  12. import net.EternIsles.structures.dustopia.Cage3;
  13. import net.EternIsles.structures.dustopia.DustTree1;
  14. import net.EternIsles.structures.dustopia.DustTree2;
  15. import net.EternIsles.structures.dustopia.DustTree3;
  16. import net.EternIsles.structures.dustopia.DustopiaVillage;
  17. import net.EternIsles.structures.dustopia.LottoCage;
  18. import net.EternIsles.structures.dustopia.MerkyreTower;
  19. import net.EternIsles.structures.dustopia.PrimordialShrine;
  20. import net.EternIsles.structures.dustopia.Stone1;
  21. import net.EternIsles.structures.dustopia.Stone2;
  22. import net.minecraft.block.Block;
  23. import net.minecraft.block.material.Material;
  24. import net.minecraft.entity.EnumCreatureType;
  25. import net.minecraft.init.Blocks;
  26. import net.minecraft.util.IProgressUpdate;
  27. import net.minecraft.util.MathHelper;
  28. import net.minecraft.world.ChunkPosition;
  29. import net.minecraft.world.World;
  30. import net.minecraft.world.WorldType;
  31. import net.minecraft.world.biome.BiomeGenBase;
  32. import net.minecraft.world.chunk.Chunk;
  33. import net.minecraft.world.chunk.IChunkProvider;
  34. import net.minecraft.world.gen.MapGenBase;
  35. import net.minecraft.world.gen.NoiseGenerator;
  36. import net.minecraft.world.gen.NoiseGeneratorOctaves;
  37. import net.minecraft.world.gen.NoiseGeneratorPerlin;
  38. import net.minecraft.world.gen.feature.WorldGenLakes;
  39. import net.minecraft.world.gen.feature.WorldGenerator;
  40. import net.minecraftforge.event.terraingen.TerrainGen;
  41.  
  42. public class ChunkProviderDustopia implements IChunkProvider {
  43.  
  44. private Random rand;
  45. private NoiseGeneratorOctaves noiseGen1, noiseGen2, noiseGen3, noiseGen5, noiseGen6;
  46. private NoiseGeneratorPerlin noiseGen4;
  47. private World worldObj;
  48. private WorldType type;
  49. private final double[] da;
  50. private final float[] parabolicField;
  51. private double[] stoneNoise = new double[256];
  52. private BiomeGenBase[] biomesForGeneration;
  53. private double[] gen1, gen2, gen3, gen4;
  54. private int[][] ia = new int[32][32];
  55.  
  56. private WorldGenerator cage1 = new Cage1();
  57. private WorldGenerator cage2 = new Cage2();
  58. private WorldGenerator cage3 = new Cage3();
  59. private WorldGenerator stone1 = new Stone1();
  60. private WorldGenerator stone2 = new Stone2();
  61. private WorldGenerator dustree1 = new DustTree1();
  62. private WorldGenerator dustree2 = new DustTree2();
  63. private WorldGenerator dustree3 = new DustTree3();
  64.  
  65. public ChunkProviderDustopia(World par1World, long par2) {
  66. this.worldObj = par1World;
  67. this.type = par1World.getWorldInfo().getTerrainType();
  68. this.rand = new Random(par2);
  69.  
  70. this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16);
  71. this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16);
  72. this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8);
  73. this.noiseGen4 = new NoiseGeneratorPerlin(this.rand, 4);
  74. this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);
  75. this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);
  76. this.da = new double[825];
  77. this.parabolicField = new float[25];
  78. for (int j = -2; j <= 2; ++j) {
  79. for (int k = -2; k <= 2; ++k) {
  80. float f = 10.0F / MathHelper.sqrt_float((float) (j * j + k * k) + 0.2F);
  81. this.parabolicField[j + 2 + (k + 2) * 5] = f;
  82. }
  83. }
  84.  
  85. NoiseGenerator[] noiseGens = { noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6 };
  86. noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens);
  87. this.noiseGen1 = (NoiseGeneratorOctaves) noiseGens[0];
  88. this.noiseGen2 = (NoiseGeneratorOctaves) noiseGens[1];
  89. this.noiseGen3 = (NoiseGeneratorOctaves) noiseGens[2];
  90. this.noiseGen4 = (NoiseGeneratorPerlin) noiseGens[3];
  91. this.noiseGen5 = (NoiseGeneratorOctaves) noiseGens[4];
  92. this.noiseGen6 = (NoiseGeneratorOctaves) noiseGens[5];
  93. }
  94.  
  95. public void generate(int i, int j, Block[] b) {
  96. byte b0 = 63;
  97. this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, i * 4 - 2,
  98. j * 4 - 2, 10, 10);
  99. this.generate(i * 4, 0, j * 4);
  100.  
  101. for (int k = 0; k < 4; ++k) {
  102. int l = k * 5;
  103. int i1 = (k + 1) * 5;
  104.  
  105. for (int j1 = 0; j1 < 4; ++j1) {
  106. int k1 = (l + j1) * 33;
  107. int l1 = (l + j1 + 1) * 33;
  108. int i2 = (i1 + j1) * 33;
  109. int j2 = (i1 + j1 + 1) * 33;
  110.  
  111. for (int k2 = 0; k2 < 32; ++k2) {
  112. double d0 = 0.125D;
  113. double d1 = this.da[k1 + k2];
  114. double d2 = this.da[l1 + k2];
  115. double d3 = this.da[i2 + k2];
  116. double d4 = this.da[j2 + k2];
  117. double d5 = (this.da[k1 + k2 + 1] - d1) * d0;
  118. double d6 = (this.da[l1 + k2 + 1] - d2) * d0;
  119. double d7 = (this.da[i2 + k2 + 1] - d3) * d0;
  120. double d8 = (this.da[j2 + k2 + 1] - d4) * d0;
  121.  
  122. for (int l2 = 0; l2 < 8; ++l2) {
  123. double d9 = 0.25D;
  124. double d10 = d1;
  125. double d11 = d2;
  126. double d12 = (d3 - d1) * d9;
  127. double d13 = (d4 - d2) * d9;
  128.  
  129. for (int i3 = 0; i3 < 4; ++i3) {
  130. int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2;
  131. short short1 = 256;
  132. j3 -= short1;
  133. double d14 = 0.25D;
  134. double d16 = (d11 - d10) * d14;
  135. double d15 = d10 - d16;
  136.  
  137. for (int k3 = 0; k3 < 4; ++k3) {
  138. if ((d15 += d16) > 0.0D)
  139. b[j3 += short1] = Blockizer.StoneDustopia;
  140.  
  141. else if (k2 * 8 + l2 < b0)
  142. b[j3 += short1] = Blockizer.GrassDustopia;
  143. else
  144. b[j3 += short1] = null;
  145.  
  146. }
  147.  
  148. d10 += d12;
  149. d11 += d13;
  150. }
  151.  
  152. d1 += d5;
  153. d2 += d6;
  154. d3 += d7;
  155. d4 += d8;
  156. }
  157. }
  158. }
  159. }
  160. }
  161.  
  162. public void replaceBlocksForBiome(int i, int j, Block[] ba, byte[] by, BiomeGenBase[] b) {
  163. double d0 = 0.03125D;
  164. this.stoneNoise = this.noiseGen4.func_151599_a(this.stoneNoise, (double) (i * 16), (double) (j * 16), 16, 16, d0 * 2.0D, d0 * 2.0D,
  165. 1.0D);
  166.  
  167. for (int k = 0; k < 16; ++k) {
  168. for (int l = 0; l < 16; ++l) {
  169. BiomeGenBase biomegenbase = b[l + k * 16];
  170. genBiomeTerrain(this.worldObj, this.rand, ba, by, i * 16 + k, j * 16 + l, this.stoneNoise[l + k * 16], biomegenbase);
  171. }
  172. }
  173. }
  174.  
  175. public final void genBiomeTerrain(World p_150560_1_, Random p_150560_2_, Block[] p_150560_3_, byte[] p_150560_4_, int p_150560_5_,
  176. int p_150560_6_, double p_150560_7_, BiomeGenBase b) {
  177. boolean flag = true;
  178. Block block = b.topBlock;
  179. byte b0 = (byte) (b.field_150604_aj & 255);
  180. Block block1 = b.fillerBlock;
  181. int k = -1;
  182. int l = (int) (p_150560_7_ / 3.0D + 3.0D + p_150560_2_.nextDouble() * 0.25D);
  183. int i1 = p_150560_5_ & 15;
  184. int j1 = p_150560_6_ & 15;
  185. int k1 = p_150560_3_.length / 256;
  186.  
  187. for (int l1 = 255; l1 >= 0; --l1) {
  188. int i2 = (j1 * 16 + i1) * k1 + l1;
  189.  
  190. if (l1 <= 0 + p_150560_2_.nextInt(5)) {
  191. p_150560_3_[i2] = Blocks.bedrock;
  192. } else {
  193. Block block2 = p_150560_3_[i2];
  194.  
  195. if (block2 != null && block2.getMaterial() != Material.air) {
  196. if (block2 == Blockizer.StoneDustopia) {
  197. if (k == -1) {
  198. if (l <= 0) {
  199. block = null;
  200. b0 = 0;
  201. block1 = Blockizer.StoneDustopia;
  202. } else if (l1 >= 59 && l1 <= 64) {
  203. block = b.topBlock;
  204. b0 = (byte) (b.field_150604_aj & 255);
  205. block1 = b.fillerBlock;
  206. }
  207.  
  208. if (l1 < 63 && (block == null || block.getMaterial() == Material.air)) {
  209. if (b.getFloatTemperature(p_150560_5_, l1, p_150560_6_) < 0.15F) {
  210. block = Blocks.water;
  211. b0 = 0;
  212. } else {
  213. block = Blockizer.StoneDustopia;
  214. b0 = 0;
  215. }
  216. }
  217.  
  218. k = l;
  219.  
  220. if (l1 >= 62) {
  221. p_150560_3_[i2] = block;
  222. p_150560_4_[i2] = b0;
  223. } else if (l1 < 56 - l) {
  224. block = null;
  225. block1 = Blockizer.StoneDustopia;
  226. p_150560_3_[i2] = Blockizer.StoneDustopia;
  227. } else {
  228. p_150560_3_[i2] = block1;
  229. }
  230. } else if (k > 0) {
  231. --k;
  232. p_150560_3_[i2] = block1;
  233.  
  234. if (k == 0 && block1 == Blockizer.StoneDustopia) {
  235. k = p_150560_2_.nextInt(4) + Math.max(0, l1 - 63);
  236. block1 = Blockizer.StoneDustopia;
  237. }
  238. }
  239. }
  240. } else {
  241. k = -1;
  242. }
  243. }
  244. }
  245. }
  246.  
  247. @Override
  248. public Chunk loadChunk(int par1, int par2) {
  249. return this.provideChunk(par1, par2);
  250. }
  251.  
  252. @Override
  253. public Chunk provideChunk(int par1, int par2) {
  254. this.rand.setSeed((long) par1 * 341873128712L + (long) par2 * 132897987541L);
  255. Block[] ablock = new Block[65536];
  256. byte[] abyte = new byte[65536];
  257. this.generate(par1, par2, ablock);
  258. this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16,
  259. par2 * 16, 16, 16);
  260. this.replaceBlocksForBiome(par1, par2, ablock, abyte, this.biomesForGeneration);
  261. Chunk chunk = new Chunk(this.worldObj, ablock, abyte, par1, par2);
  262. byte[] abyte1 = chunk.getBiomeArray();
  263.  
  264. for (int k = 0; k < abyte1.length; ++k)
  265. abyte1[k] = (byte) this.biomesForGeneration[k].biomeID;
  266.  
  267. chunk.generateSkylightMap();
  268. return chunk;
  269. }
  270.  
  271. private void generate(int x, int y, int z) {
  272. double d0 = 684.412D;
  273. double d1 = 684.412D;
  274. double d2 = 512.0D;
  275. double d3 = 512.0D;
  276. this.gen4 = this.noiseGen6.generateNoiseOctaves(this.gen4, x, z, 5, 5, 200.0D, 200.0D, 0.5D);
  277. this.gen1 = this.noiseGen3.generateNoiseOctaves(this.gen1, x, y, z, 5, 33, 5, 8.555150000000001D, 4.277575000000001D,
  278. 8.555150000000001D);
  279. this.gen2 = this.noiseGen1.generateNoiseOctaves(this.gen2, x, y, z, 5, 33, 5, 684.412D, 684.412D, 684.412D);
  280. this.gen3 = this.noiseGen2.generateNoiseOctaves(this.gen3, x, y, z, 5, 33, 5, 684.412D, 684.412D, 684.412D);
  281. boolean flag1 = false;
  282. boolean flag = false;
  283. int l = 0;
  284. int i1 = 0;
  285. double d4 = 8.5D;
  286.  
  287. for (int j1 = 0; j1 < 5; ++j1) {
  288. for (int k1 = 0; k1 < 5; ++k1) {
  289. float f = 0.0F;
  290. float f1 = 0.0F;
  291. float f2 = 0.0F;
  292. byte b0 = 2;
  293. BiomeGenBase biomegenbase = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10];
  294.  
  295. for (int l1 = -b0; l1 <= b0; ++l1) {
  296. for (int i2 = -b0; i2 <= b0; ++i2) {
  297. BiomeGenBase biomegenbase1 = this.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10];
  298. float f3 = biomegenbase1.rootHeight;
  299. float f4 = biomegenbase1.heightVariation;
  300.  
  301. if (this.type == WorldType.AMPLIFIED && f3 > 0.0F) {
  302. f3 = 1.0F + f3 * 2.0F;
  303. f4 = 1.0F + f4 * 4.0F;
  304. }
  305.  
  306. float f5 = this.parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F);
  307.  
  308. if (biomegenbase1.rootHeight > biomegenbase.rootHeight)
  309. f5 /= 2.0F;
  310.  
  311. f += f4 * f5;
  312. f1 += f3 * f5;
  313. f2 += f5;
  314. }
  315. }
  316.  
  317. f /= f2;
  318. f1 /= f2;
  319. f = f * 0.9F + 0.1F;
  320. f1 = (f1 * 4.0F - 1.0F) / 8.0F;
  321. double d12 = this.gen4[i1] / 8000.0D;
  322.  
  323. if (d12 < 0.0D) {
  324. d12 = -d12 * 0.3D;
  325. }
  326.  
  327. d12 = d12 * 3.0D - 2.0D;
  328.  
  329. if (d12 < 0.0D) {
  330. d12 /= 2.0D;
  331.  
  332. if (d12 < -1.0D)
  333. d12 = -1.0D;
  334.  
  335. d12 /= 1.4D;
  336. d12 /= 2.0D;
  337. } else {
  338. if (d12 > 1.0D)
  339. d12 = 1.0D;
  340.  
  341. d12 /= 8.0D;
  342. }
  343.  
  344. ++i1;
  345. double d13 = (double) f1;
  346. double d14 = (double) f;
  347. d13 += d12 * 0.2D;
  348. d13 = d13 * 8.5D / 8.0D;
  349. double d5 = 8.5D + d13 * 4.0D;
  350.  
  351. for (int j2 = 0; j2 < 33; ++j2) {
  352. double d6 = ((double) j2 - d5) * 12.0D * 128.0D / 256.0D / d14;
  353.  
  354. if (d6 < 0.0D)
  355. d6 *= 4.0D;
  356.  
  357. double d7 = this.gen2[l] / 512.0D;
  358. double d8 = this.gen3[l] / 512.0D;
  359. double d9 = (this.gen1[l] / 10.0D + 1.0D) / 2.0D;
  360. double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6;
  361.  
  362. if (j2 > 29) {
  363. double d11 = (double) ((float) (j2 - 29) / 3.0F);
  364. d10 = d10 * (1.0D - d11) + -10.0D * d11;
  365. }
  366.  
  367. this.da[l] = d10;
  368. ++l;
  369. }
  370. }
  371. }
  372. }
  373.  
  374. @Override
  375. public boolean chunkExists(int par1, int par2) {
  376. return true;
  377. }
  378.  
  379. @Override
  380. public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) {
  381. int var4 = par2 * 16;
  382. int var5 = par3 * 16;
  383. BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);
  384. long p1 = this.rand.nextLong() / 2L * 2L + 1L;
  385. long j1 = this.rand.nextLong() / 2L * 2L + 1L;
  386. this.rand.setSeed(this.worldObj.getSeed());
  387. this.rand.setSeed((long) par2 * p1 + (long) par3 * j1 ^ this.worldObj.getSeed());
  388. int j, var12, var13, var14, x, i, y, z;
  389.  
  390. for (i = 0; i < 6; i++) {
  391. x = var4 + this.rand.nextInt(16);
  392. z = var5 + this.rand.nextInt(16);
  393. y = this.worldObj.getHeightValue(x, z);
  394.  
  395. Random rand = new Random();
  396. int randomNum = rand.nextInt((4 - 1) + 1) + 1;
  397.  
  398. if (randomNum == 3) {
  399. dustree1.generate(this.worldObj, this.rand, x, y, z);
  400. } else if (randomNum == 2) {
  401. dustree2.generate(this.worldObj, this.rand, x, y, z);
  402. } else {
  403. dustree3.generate(this.worldObj, this.rand, x, y, z);
  404. }
  405.  
  406. }
  407.  
  408. for (i = 0; i < 8; i++) {
  409. x = var4 + this.rand.nextInt(16);
  410. z = var5 + this.rand.nextInt(16);
  411. y = this.worldObj.getHeightValue(x, z);
  412.  
  413. if (this.worldObj.getBlock(x, y - 1, z) == Blockizer.GrassDustopia) {
  414. Random rand = new Random();
  415. int randomNum = rand.nextInt((2 - 1) + 1) + 1;
  416. if (randomNum == 2) {
  417. this.worldObj.setBlock(x, y, z, Blockizer.DawnBush);
  418. } else {
  419. this.worldObj.setBlock(x, y, z, Blockizer.DawnFlower);
  420. }
  421. }
  422. }
  423.  
  424. x = var4 + this.rand.nextInt(16);
  425. z = var5 + this.rand.nextInt(16);
  426. y = this.worldObj.getHeightValue(x, z);
  427.  
  428. Random rand = new Random();
  429. int randomNum = rand.nextInt((5 - 1) + 1) + 1;
  430. int willGenIt = rand.nextInt((5 - 1) + 1) + 1;
  431.  
  432. if (randomNum == 3) {
  433. if (willGenIt == 2)
  434. cage1.generate(this.worldObj, this.rand, x, y, z);
  435. } else if (randomNum == 2) {
  436. stone1.generate(this.worldObj, this.rand, x, y, z);
  437. } else if (randomNum == 4) {
  438. if (willGenIt == 3)
  439. cage2.generate(this.worldObj, this.rand, x, y, z);
  440. } else if (randomNum == 5) {
  441. if (willGenIt == 4)
  442. cage3.generate(this.worldObj, this.rand, x, y, z);
  443. } else {
  444. stone2.generate(this.worldObj, this.rand, x, y, z);
  445. }
  446.  
  447. for (i = 0; i < 45; i++) {
  448. x = var4 + this.rand.nextInt(16);
  449. z = var5 + this.rand.nextInt(16);
  450. y = this.worldObj.getHeightValue(x, z);
  451.  
  452. if (this.worldObj.getBlock(x, y - 1, z) == Blockizer.GrassDustopia)
  453. this.worldObj.setBlock(x, y, z, Blockizer.DawnGrassTop);
  454. }
  455.  
  456. if (rand.nextInt(500) == 331) {
  457. x = var4 + this.rand.nextInt(16);
  458. z = var5 + this.rand.nextInt(16);
  459. y = this.worldObj.getHeightValue(x, z);
  460. (new PrimordialShrine()).generate(this.worldObj, this.rand, x, y, z);
  461. }
  462.  
  463.  
  464. if (rand.nextInt(400) == 226) {
  465. x = var4 + this.rand.nextInt(16);
  466. z = var5 + this.rand.nextInt(16);
  467. y = this.worldObj.getHeightValue(x+1, z+1);
  468. if (this.worldObj.getBlock(x, y-1, z) == Blockizer.GrassDustopia)
  469. (new LottoCage()).generate(this.worldObj, this.rand, x, y, z);
  470. }
  471.  
  472. if (rand.nextInt(500) == 331) {
  473. x = var4 + this.rand.nextInt(16);
  474. z = var5 + this.rand.nextInt(16);
  475. y = this.worldObj.getHeightValue(x + 4, z + 4);
  476. if (this.worldObj.getBlock(x, y-1, z) == Blockizer.GrassDustopia)
  477. (new DustopiaVillage()).generate(this.worldObj, this.rand, x, y - 1, z);
  478. }
  479.  
  480. if (rand.nextInt(600) == 442) {
  481. x = var4 + this.rand.nextInt(16);
  482. z = var5 + this.rand.nextInt(16);
  483. y = this.worldObj.getHeightValue(x + 3, z + 3);
  484. if (this.worldObj.getBlock(x, y-1, z) == Blockizer.GrassDustopia)
  485. (new MerkyreTower()).generate(this.worldObj, this.rand, x, y - 1, z);
  486. }
  487.  
  488. }
  489.  
  490. @Override
  491. public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) {
  492. return true;
  493. }
  494.  
  495. @Override
  496. public void saveExtraData() {}
  497.  
  498. @Override
  499. public boolean unloadQueuedChunks() {
  500. return false;
  501. }
  502.  
  503. @Override
  504. public boolean canSave() {
  505. return true;
  506. }
  507.  
  508. @Override
  509. public String makeString() {
  510. return "Dustopia";
  511. }
  512.  
  513. @Override
  514. public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) {
  515. BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4);
  516. return biomegenbase.getSpawnableList(par1EnumCreatureType);
  517. }
  518.  
  519. @Override
  520. public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) {
  521. return null;
  522. }
  523.  
  524. @Override
  525. public int getLoadedChunkCount() {
  526. return 0;
  527. }
  528.  
  529. @Override
  530. public void recreateStructures(int par1, int par2) {}
  531. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement