Advertisement
marcopolo1613

bod 1.4.6/.7

May 19th, 2013
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.49 KB | None | 0 0
  1. //world gen minable
  2. package net.minecraft.src;
  3. import java.io.*;
  4. import java.util.*;
  5. import net.minecraft.client.Minecraft; // remove for multiplayer server
  6. import java.util.Random;
  7. import java.util.Arrays;
  8.  
  9. // Referenced classes of package net.minecraft.src:
  10. // WorldGenerator, MathHelper, World, Block
  11.  
  12. public class WorldGenMinable extends WorldGenerator
  13. {
  14.  
  15. public WorldGenMinable(int i, int j)
  16. {
  17. minableBlockId = i;
  18. }
  19.  
  20. public WorldGenMinable(int id, int meta, int number)
  21. {
  22. this(id, number);
  23. minableBlockMeta = meta;
  24. }
  25.  
  26. public boolean generateBeforeCheck() // takes a set of current global variables and checks to see if this ore has spawned before in this chunk
  27. {
  28. genBeforeCheck = false;
  29. genBeforeCheck = oreList.contains(Arrays.asList(MPBlockID, minableBlockMeta));
  30.  
  31. if(oreList.contains(Arrays.asList(MPBlockID, minableBlockMeta)) == false)
  32. {
  33. oreList.add(Arrays.asList(MPBlockID, minableBlockMeta));
  34.  
  35. }
  36. return genBeforeCheck;
  37. }
  38. public void genOverrides(World world, Random random, int xCoord, int zCoord)
  39. {
  40. BODFile = new File(configDirectory + "/BODprops/" + versionNum + "BOD-Overrides.txt");
  41. File f = new File(configDirectory + "/BODprops");
  42. Properties props = new Properties();
  43. if(f.exists()==false)// make the folder if it doesnt exist
  44. {
  45. f.mkdirs();
  46. }
  47. if(BODFile.exists()==false) // make the file if it doesnt exist
  48. {
  49. writeBODoverrides(BODFile);
  50. //System.out.println("write BODprops"); /// for debugging
  51. }
  52. if(BODFile.exists())
  53. {
  54. boolean overrideExists = true;
  55. int count = 1;
  56. try
  57. {
  58. props.load(new FileInputStream(BODFile));
  59. String valPass = "0";
  60. while(overrideExists) // loop until we dont have anymore overrids listed
  61. {
  62. valPass = String.valueOf(count + ".add_new_ore"); // find the override string
  63. if (props.getProperty(valPass)!= null) // make sure it exists
  64. {
  65. valPass = props.getProperty(valPass); // get the text data off the end
  66. String[] strobj = valPass.split(":");
  67. minableBlockId = Integer.valueOf(strobj[0]);
  68. minableBlockMeta = Integer.valueOf(strobj[1]);
  69. //System.out.println(minableBlockId +" " + minableBlockMeta + "outputs"); for debugging
  70. generate(world, random, xCoord, zCoord, 1);
  71. }
  72. else
  73. {
  74. overrideExists = false;
  75. }
  76. count++;
  77. }
  78. minableBlockId = 3; // set it back to dirt before leaving
  79. minableBlockMeta = 0;
  80. }
  81. catch(IOException e)
  82. {
  83.  
  84. }
  85. }
  86. }
  87. void createMine( World worldObj, Random rand, int x, int z)
  88. {
  89. for(int loopCount = 0; loopCount < veinAm; loopCount++)
  90. {
  91. int temp1 = mPCalculateDensity(diameter, hDens);
  92. int temp2 = mineHeight + mPCalculateDensity(height, vDens);
  93. int temp3 = mPCalculateDensity(diameter, hDens);
  94. int l5 = x + temp1;
  95. int i9 = temp2;
  96. int k13 = z + temp3;
  97. if(useMarcoVeins == false)
  98. {
  99. BODgenerate(worldObj, rand, l5, i9, k13, veinSi); // generate based on values
  100. }
  101. else
  102. {
  103. BODgenerateVein(worldObj, rand, l5, i9, k13, veinSi);
  104. }
  105. }
  106. }
  107. void createMineWithChance(World worldObj, Random rand, int x, int z)
  108. {
  109. if (rarity > 0){rarity = mPBiomeRarity(rarity, x, z, MPBlockID);} // retrieve rarity for this ore in this biome
  110. if (rarity == 1 || (rarity > 0 && rand.nextInt(rarity) == 0)) // use values
  111. {
  112. createMine(worldObj, rand, x, z);
  113. }
  114. }
  115. public boolean generate(World world, Random random, int i, int j, int k)//obsorb default system
  116. {
  117. configDirectory = new File(Minecraft.getMinecraftDir() + "");// used for switching the code to singleplayer
  118. //configDirectory = new File(new File(".").getAbsolutePath()); // used for switching the code to multiplayer
  119.  
  120. //System.out.println(" 1: call "+minableBlockId+":"+minableBlockMeta); // for debugging
  121. randomOut = random; // pad the seed so it's the same as vannila
  122. randomOut.nextFloat(); // |
  123. randomOut.nextInt(3); // |
  124. randomOut.nextInt(3); // |
  125. randomOut.nextDouble();// |
  126. if (minableBlockId==3)// this makes sure everything is on a once per ore gen basis, because dirt generates first it sets everything up
  127. {
  128. //System.out.println(" 1.2: found dirt, setting up"); /// for debugging
  129. MPChunk_X =((i / 16) * 16);// set output chunk x // snap to grid
  130. MPChunk_Z =((k / 16) * 16);// set output chunk z
  131.  
  132. /*----*/ Random randomz = new Random(world.getSeed()); // setup a random for BOD
  133. long l = (randomz.nextLong() / 2L) * 2L + 1L; // |
  134. long l1 = (randomz.nextLong() / 2L) * 2L + 1L; // |
  135. randomz.setSeed((long)i * l + (long)j * l1 ^ world.getSeed()); // |
  136. /*----*/ rand = randomz;
  137.  
  138. worldObj = world; // set world
  139. mineCount = 0; // this is a new chunk, so list gets set to the beginning
  140.  
  141. oreList.clear(); // clear the list of ores, this is a new chunk
  142.  
  143. }
  144.  
  145. MPBlockID = minableBlockId;// set output block ID
  146. if(MPChunk_X != MPPrevX || MPChunk_Z != MPPrevZ || MPPrevID != MPBlockID || minableBlockMeta != MPPrevMeta)// if it is a new x or z chunk, then generate // blockID stops dirt
  147. {
  148. //System.out.println(" 2: allowed ore chunk prev test"); /// for debugging
  149. if(minableBlockId==3)
  150. {
  151. genOverrides(worldObj, rand, MPChunk_X, MPChunk_Z);
  152. }
  153. if (generateBeforeCheck() == false)
  154. {
  155. //.out.println(" 2.2: procede with gen"); /// for debugging315 56 298
  156. MPPrevX = MPChunk_X;
  157. MPPrevZ = MPChunk_Z;
  158. x_Chunk = MPChunk_X;
  159. z_Chunk = MPChunk_Z;
  160. MPPrevID = MPBlockID;
  161. MPPrevMeta = minableBlockMeta;
  162. mineGen = 1;
  163. subMineGen = 1;
  164.  
  165. BODFile = new File(configDirectory + "/BODprops/" + versionNum + "BOD-Mine[1.1].txt");
  166. BODFileOres = BODFile;
  167. BODbiomesFile = new File(configDirectory + "/BODprops/" + versionNum + "BODbiomes-Mine[1.1].txt");
  168. File f=new File(configDirectory + "/BODprops"); // remove minecraft directy portion for multiplayer
  169. if(f.exists()==false)
  170. {
  171. f.mkdirs();
  172. }
  173.  
  174. if(BODFile.exists()==false)
  175. {
  176. writeBOD(BODFile);
  177. //System.out.println("write BODprops"); /// for debugging
  178. }
  179. if(BODbiomesFile.exists()==false)
  180. {
  181. writeBODbiomes(BODbiomesFile);
  182. //System.out.println("write BODbiomes"); /// for debugging
  183. }
  184.  
  185. while(BODFile.exists())
  186. {
  187. //System.out.println(" 2.3: bod file exists, checking rarity random"); /// for debugging
  188. betterOreDistribution(x_Chunk, z_Chunk, MPBlockID, minableBlockMeta); // gather ore gen values from .txt
  189.  
  190. if (rarity > 0){rarity = mPBiomeRarity(rarity, x_Chunk, z_Chunk, MPBlockID);} // retrieve rarity for this ore in this biome
  191. if (rarity == 1 || (rarity > 0 && rand.nextInt(rarity) == 0)) // use values
  192. {
  193. //System.out.println(" 2.3.1: rarity passed"); /// for debugging
  194. while(BODFile.exists())
  195. {
  196. //System.out.println(" 2.3.2: other bod file works"); /// for debugging
  197. betterOreDistribution(x_Chunk, z_Chunk, MPBlockID, minableBlockMeta); // gather ore gen values from .txt
  198. //System.out.println("makin a mine at " + (MPChunk_X / 16) + "," + (MPChunk_Z / 16) + ", id " + MPBlockID + "." + minableBlockMeta/* + "-" + MPPrevID3 + "-" + MPPrevID4*/ + ", settings: R " + rarity + ", VS " + veinSi + ", VA " + veinAm + ", H " + height + ", D " + diameter + ", VD " + vDens + ", HD " + hDens); // used for debugging
  199. //System.out.println("generate veins"); /// for debugging
  200. if(subMineGen == 1){createMine(worldObj, rand, x_Chunk, z_Chunk);}
  201. else{createMineWithChance(worldObj, rand, x_Chunk, z_Chunk);}
  202.  
  203. subMineGen++;
  204. BODFile = new File(configDirectory + "/BODprops/" + versionNum + "BOD-Mine["+ mineGen +"."+ subMineGen +"].txt");
  205. }
  206. }
  207. subMineGen = 1;
  208. mineGen++;
  209. BODFile = new File(configDirectory + "/BODprops/" + versionNum + "BOD-Mine["+ mineGen +"."+ subMineGen +"].txt");
  210. }
  211. }
  212. //else{System.out.println(" checked, and genned before!");}// for debugging
  213. }
  214. return true;
  215. }
  216.  
  217. public int mPCalculateDensity(int oreDistance, float oreDensity) // returns the density value
  218. {
  219.  
  220. int loopCount = 0;
  221. int densityValuePassInner = 0;
  222. int densityValuePass = 0;
  223. oreDensity = oreDensity * .01F;
  224. oreDensity = (oreDensity * (oreDistance >> 1)) + 1F;// establishes number of times to loop
  225. loopCount = (int)(oreDensity); //stores number of times to loop
  226. densityValuePassInner = ((oreDistance/loopCount)); // distance devided by number of times it will loop, establishes the number for randomization
  227. densityValuePassInner += (((oreDistance - (densityValuePassInner*loopCount))/loopCount));
  228. densityValuePass = 0;
  229. while (loopCount > 0) // loops to acumulate random values
  230. {
  231. densityValuePass = densityValuePass + rand.nextInt(densityValuePassInner); // acumulate randoms
  232. loopCount = loopCount - 1; // decriment loop
  233. }
  234. return densityValuePass; // return proccesed random value
  235. }
  236.  
  237. public int mPBiomeRarity(int biomeRar, int xChunkBio, int zChunkBio, int MPMinableBlockId)
  238. {
  239. worldChunkManager = worldObj.getWorldChunkManager();
  240. BiomeGenBase biomegenbase = worldChunkManager.getBiomeGenAt(xChunkBio, zChunkBio);
  241.  
  242. Properties props = new Properties();
  243. int biomeVals = rarity;
  244. String valPass = "1";
  245. String valPassB = "1";
  246. int inc1 = 1;
  247. try
  248. {
  249. BODbiomesFile = new File(configDirectory + "/BODprops/" + versionNum + "BOD-Biomes-Mine["+ mineGen +"."+ subMineGen +"].txt"); // setup file // remove the minecraft directory portion for multiplayer
  250. if(BODbiomesFile.exists())
  251. {
  252. props.load(new FileInputStream(BODbiomesFile));
  253.  
  254. valPass = String.valueOf("OreID[" + MPMinableBlockId + "." + minableBlockMeta + "]-BiomeID[" + biomegenbase.biomeID + "]");
  255.  
  256. if (props.getProperty(valPass)!= null) // make sure it exists first
  257. {
  258. valPassB = props.getProperty(valPass); // get new rarity value
  259. biomeVals = Integer.valueOf(valPassB);
  260. }
  261. }
  262. }
  263. catch(IOException j)
  264. {
  265. System.out.println("couldnt load BODbiomes"); /// for debugging
  266. }
  267. /*try
  268. {
  269. File List = new File(Minecraft.getMinecraftDir() + "/BODprops/(V2.4)BiomesList.txt"); // setup file // remove the minecraft directory portion for multiplayer
  270. props.load(new FileInputStream(List));
  271. }
  272. catch(IOException g)
  273. {
  274. try // Write Biome ID reference
  275. {
  276. BufferedWriter out = new BufferedWriter(new FileWriter(BODFile));
  277. inc1 = 0;
  278. out.write("This file acts as a reference to all Biomes used currently." + "\r\n" + "To refresh this list, delete this text file, and a new one will be made with updated biomes when new generation takes place");
  279. while (inc1 <= 255)
  280. {
  281. if(biomegenbase.biomeList[inc1] == null){ out.write("ID" + inc1 + ": unused ID" + "\r\n");}
  282. else
  283. {
  284. out.write("Biome ID " + inc1 + ": " + biomegenbase.biomeList[inc1] + "\r\n");
  285. }
  286. inc1++;
  287. }
  288. out.close();
  289. }
  290. catch(IOException k){}
  291. }*/
  292. if( valPass != null){biomeRar = biomeVals ;}
  293. else {biomeRar = rarity;}
  294. return biomeRar;
  295.  
  296. }
  297.  
  298. public boolean betterOreDistribution(int xChunk, int zChunk, int MPMinableBlockId, int MPMinableBlockMeta)
  299. {
  300. //System.out.println("assigning variables"); /// for debugging
  301. rarity = 2; // make sure all these dont have garbage data in them, for debugging mostly
  302. veinSi = 2;
  303. veinAm = 2;
  304. height = 2;
  305. mineHeight = 2;
  306. diameter = 2;
  307. vDens = 2;
  308. hDens = 2;
  309. useMarcoVeins = false;
  310. String valPass = "1";
  311.  
  312. Properties props = new Properties();
  313. //try retrieve data from file
  314. try
  315. {
  316.  
  317. BODFile = new File(configDirectory + "/BODprops/" + versionNum + "BOD-Mine["+ mineGen +"."+ subMineGen +"].txt");
  318. if(BODFile.exists())
  319. {
  320. props.load(new FileInputStream(BODFile));
  321. // assign value to ore variable only if it is not null
  322.  
  323. String valPass1 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "Rarity");
  324. String valPass2 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "VeinSize");
  325. String valPass3 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "VeinAmount");
  326. String valPass4 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "Height");
  327. String valPass8 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "VerticalShift");
  328. String valPass5 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "Diameter");
  329. String valPass6 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "VerticalDensity");
  330. String valPass7 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "HorizontalDensity");
  331. String valPass9 = String.valueOf(MPMinableBlockId + "." + MPMinableBlockMeta + "UseMarcoVeins");
  332. //System.out.println(MPMinableBlockId + "." + MPMinableBlockMeta + "HorizontalDensity"); /// for debugging
  333.  
  334. if(mineGen == 1 && subMineGen == 1 )
  335. {
  336. if (props.getProperty(valPass1)== null || props.getProperty(valPass2)== null || props.getProperty(valPass3)== null || props.getProperty(valPass4)== null || props.getProperty(valPass5)== null || props.getProperty(valPass6)== null || props.getProperty(valPass7)== null || props.getProperty(valPass9)== null)
  337. {
  338. try
  339. {
  340.  
  341. BufferedWriter out = new BufferedWriter(new FileWriter(BODFile,true));
  342. out.write("#NewBlock" + MPMinableBlockId + "." + MPMinableBlockMeta + "\r\n");
  343. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "Rarity=50" + "\r\n");
  344. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "VeinSize=10" + "\r\n");
  345. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "VeinAmount=70" + "\r\n");
  346. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "Height=95" + "\r\n");
  347. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "VerticalShift=0" + "\r\n");
  348. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "Diameter=48" + "\r\n");
  349. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "VerticalDensity=10" + "\r\n");
  350. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "HorizontalDensity=10" + "\r\n");
  351. out.write(MPMinableBlockId + "." + MPMinableBlockMeta + "UseMarcoVeins=false" + "\r\n" + "\r\n");
  352. out.close();
  353. //System.out.println(MPMinableBlockId + "." + MPMinableBlockMeta + "HorizontalDensity=10"); /// for debugging
  354. }
  355. catch (IOException h)
  356. {
  357. System.out.println("couldnt write in new ore settings for ore" + MPMinableBlockId + "." + MPMinableBlockMeta); /// for debugging
  358. }
  359. }
  360. }
  361. if (props.getProperty(valPass1)!= null){
  362. valPass = props.getProperty(valPass1); // rarity
  363. rarity = Integer.valueOf(valPass) ; }
  364.  
  365. if (props.getProperty(valPass2) != null){
  366. valPass = props.getProperty(valPass2); // size
  367. veinSi = Integer.valueOf(valPass) ; }
  368.  
  369. if (props.getProperty(valPass3) != null){
  370. valPass = props.getProperty(valPass3); // amount
  371. veinAm = Integer.valueOf(valPass) ; }
  372.  
  373. if (props.getProperty(valPass4) != null){
  374. valPass = props.getProperty(valPass4); // height
  375. height = Integer.valueOf(valPass) ; }
  376.  
  377. if (props.getProperty(valPass8) != null){
  378. valPass = props.getProperty(valPass8); // mineHeight
  379. mineHeight = Integer.valueOf(valPass) ; }
  380.  
  381. if (props.getProperty(valPass5) != null){
  382. valPass = props.getProperty(valPass5); // diameter
  383. diameter = Integer.valueOf(valPass) ; }
  384.  
  385. if (props.getProperty(valPass6) != null){
  386. valPass = props.getProperty(valPass6); // vertical dense.
  387. vDens = Integer.valueOf(valPass) ; }
  388.  
  389. if (props.getProperty(valPass7) != null){
  390. valPass = props.getProperty(valPass7); // horiz. dense.
  391. hDens = Integer.valueOf(valPass) ; }
  392.  
  393. if (props.getProperty(valPass9) != null){
  394. valPass = props.getProperty(valPass9); // marco veins?
  395. useMarcoVeins = Boolean.valueOf(valPass) ; }
  396. }
  397. //else{System.out.println("couldnt assign variables, BODfile doesnt exist: " + BODFile);} /// for debugging}
  398. }
  399.  
  400. //catch exception in case properties file does not exist
  401. catch(IOException e)
  402. {
  403. System.out.println("assigning variables had an exception!!!"); /// for debugging
  404. }
  405. // all variables set, continue to generate
  406. return true;
  407. }
  408.  
  409. public boolean BODgenerateVein(World world, Random rand, int parX, int parY, int parZ, int xyz)
  410. {
  411. //==========================================mp mod
  412. int posX = parX;
  413. int posY = parY;
  414. int posZ = parZ;
  415. int tempPosX =0;
  416. int tempPosY =0;
  417. int tempPosZ =0;
  418. int posX2 = 0;
  419. int posY2 = 0;
  420. int posZ2 = 0;
  421. int directionX =0;
  422. int directionY =0;
  423. int directionZ =0;
  424. int directionX2 = 0;
  425. int directionY2 = 0;
  426. int directionZ2 = 0;
  427. int directionX3 =0;
  428. int directionY3 =0;
  429. int directionZ3 =0;
  430. int directionChange =0;
  431. int directionChange2 =0;
  432. int blocksToUse = xyz;//input number of blocks per vein
  433. int blocksToUse2 =0;
  434. for(int blocksMade=0; blocksMade <= blocksToUse;) // make veins
  435. {
  436. blocksToUse2 = 1 + (blocksToUse/30);
  437. directionChange = rand.nextInt(6);
  438. directionX = rand.nextInt(2);
  439. directionY = rand.nextInt(2);
  440. directionZ = rand.nextInt(2);
  441.  
  442. for(int blocksMade1 = 0; blocksMade1 <= blocksToUse2; ) // make branch
  443. {
  444. if(directionX == 0 && directionChange != 1){posX = posX + rand.nextInt(2);}
  445. if(directionX == 1 && directionChange != 1){posX = posX - rand.nextInt(2);}
  446. if(directionY == 0 && directionChange != 2){posY = posY + rand.nextInt(2);}
  447. if(directionY == 1 && directionChange != 2){posY = posY - rand.nextInt(2);}
  448. if(directionZ == 0 && directionChange != 3){posZ = posZ + rand.nextInt(2);}
  449. if(directionZ == 1 && directionChange != 3){posZ = posZ - rand.nextInt(2);}
  450. if(rand.nextInt(4) == 0){
  451. posX2 = posX2 + rand.nextInt(2);
  452. posY2 = posY2 + rand.nextInt(2);
  453. posZ2 = posZ2 + rand.nextInt(2);
  454. posX2 = posX2 - rand.nextInt(2);
  455. posY2 = posY2 - rand.nextInt(2);
  456. posZ2 = posZ2 - rand.nextInt(2);
  457. }
  458. if(rand.nextInt(3) == 0) // make sub-branch
  459. {
  460. posX2 = posX;
  461. posY2 = posY;
  462. posZ2 = posZ;
  463.  
  464. directionX2 = rand.nextInt(2);
  465. directionY2 = rand.nextInt(2);
  466. directionZ2 = rand.nextInt(2);
  467. directionChange2 = rand.nextInt(6);
  468. if(directionX2 == 0 && directionChange2 != 0){posX2 = posX2 + rand.nextInt(2);}
  469. if(directionY2 == 0 && directionChange2 != 1){posY2 = posY2 + rand.nextInt(2);}
  470. if(directionZ2 == 0 && directionChange2 != 2){posZ2 = posZ2 + rand.nextInt(2);}
  471. if(directionX2 == 1 && directionChange2 != 0){posX2 = posX2 - rand.nextInt(2);}
  472. if(directionY2 == 1 && directionChange2 != 1){posY2 = posY2 - rand.nextInt(2);}
  473. if(directionZ2 == 1 && directionChange2 != 2){posZ2 = posZ2 - rand.nextInt(2);}
  474.  
  475.  
  476.  
  477. for(int blocksMade2 = 0; blocksMade2 <= (1 +(blocksToUse2/5)); )
  478. {
  479.  
  480. if(directionX2 == 0 && directionChange2 != 0){posX2 = posX2 + rand.nextInt(2);}
  481. if(directionY2 == 0 && directionChange2 != 1){posY2 = posY2 + rand.nextInt(2);}
  482. if(directionZ2 == 0 && directionChange2 != 2){posZ2 = posZ2 + rand.nextInt(2);}
  483. if(directionX2 == 1 && directionChange2 != 0){posX2 = posX2 - rand.nextInt(2);}
  484. if(directionY2 == 1 && directionChange2 != 1){posY2 = posY2 - rand.nextInt(2);}
  485. if(directionZ2 == 1 && directionChange2 != 2){posZ2 = posZ2 - rand.nextInt(2);}
  486. if(world.getBlockId(posX, posY, posZ) == Block.stone.blockID || world.getBlockId(posX, posY, posZ) == 87)
  487. {
  488. world.setBlockAndMetadata(posX, posY, posZ, MPBlockID, minableBlockMeta);
  489. }
  490. blocksMade++;
  491. blocksMade1++;
  492. blocksMade2++;
  493. }
  494. }
  495.  
  496. if(world.getBlockId(posX, posY, posZ) == Block.stone.blockID || world.getBlockId(posX, posY, posZ) == 87)
  497. {
  498. world.setBlockAndMetadata(posX, posY, posZ, MPBlockID, minableBlockMeta);
  499. }
  500.  
  501. blocksMade++;
  502. blocksMade1++;
  503.  
  504. }
  505.  
  506. parX = parX + (rand.nextInt(3) - 1);
  507. parY = parY + (rand.nextInt(3) - 1);
  508. parZ = parZ + (rand.nextInt(3) - 1);
  509. posX = parX;
  510. posY = parY;
  511. posZ = parZ;
  512.  
  513. }
  514.  
  515.  
  516. return true;
  517. }
  518.  
  519. public boolean BODgenerate(World world, Random rand, int par3, int par4, int par5, int xyz)
  520. {
  521.  
  522. //==========================================mp mod
  523. numberOfBlocks = xyz; //input number of blocks per vein
  524.  
  525. //==========================================mp mod
  526. float var6 = rand.nextFloat() * (float)Math.PI;
  527. double var7 = (double)((float)(par3 + 8) + MathHelper.sin(var6) * (float)numberOfBlocks / 8.0F);
  528. double var9 = (double)((float)(par3 + 8) - MathHelper.sin(var6) * (float)numberOfBlocks / 8.0F);
  529. double var11 = (double)((float)(par5 + 8) + MathHelper.cos(var6) * (float)numberOfBlocks / 8.0F);
  530. double var13 = (double)((float)(par5 + 8) - MathHelper.cos(var6) * (float)numberOfBlocks / 8.0F);
  531. double var15 = (double)(par4 + rand.nextInt(3) - 2);
  532. double var17 = (double)(par4 + rand.nextInt(3) - 2);
  533.  
  534. for (int var19 = 0; var19 <= numberOfBlocks; ++var19)
  535. {
  536. double var20 = var7 + (var9 - var7) * (double)var19 / (double)numberOfBlocks;
  537. double var22 = var15 + (var17 - var15) * (double)var19 / (double)numberOfBlocks;
  538. double var24 = var11 + (var13 - var11) * (double)var19 / (double)numberOfBlocks;
  539. double var26 = rand.nextDouble() * (double)this.numberOfBlocks / 16.0D;
  540. double var28 = (double)(MathHelper.sin((float)var19 * (float)Math.PI / (float)numberOfBlocks) + 1.0F) * var26 + 1.0D;
  541. double var30 = (double)(MathHelper.sin((float)var19 * (float)Math.PI / (float)numberOfBlocks) + 1.0F) * var26 + 1.0D;
  542. int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);
  543. int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);
  544. int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);
  545. int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);
  546. int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);
  547. int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);
  548.  
  549. for (int var38 = var32; var38 <= var35; ++var38)
  550. {
  551. double var39 = ((double)var38 + 0.5D - var20) / (var28 / 2.0D);
  552.  
  553. if (var39 * var39 < 1.0D)
  554. {
  555. for (int var41 = var33; var41 <= var36; ++var41)
  556. {
  557. double var42 = ((double)var41 + 0.5D - var22) / (var30 / 2.0D);
  558.  
  559. if (var39 * var39 + var42 * var42 < 1.0D)
  560. {
  561. for (int var44 = var34; var44 <= var37; ++var44)
  562. {
  563. double var45 = ((double)var44 + 0.5D - var24) / (var28 / 2.0D);
  564.  
  565. Block block = Block.blocksList[world.getBlockId(var38, var41, var44)];
  566. //if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (block != null && block.isGenMineableReplaceable(par1World, var38, var41, var44)))
  567. if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (block != null && (world.getBlockId(var38, var41, var44) == Block.stone.blockID || world.getBlockId(var38, var41, var44) == 87)))
  568. {
  569. world.setBlockAndMetadata(var38, var41, var44, minableBlockId, minableBlockMeta);
  570. //System.out.println("block at " + var38 +" "+var41+" "+var44); /// for debugging
  571. }
  572. }
  573. }
  574. }
  575. }
  576. }
  577. }
  578. //System.out.println("a vein was placed " + minableBlockId + "." + minableBlockMeta+ " at " + par3 +" "+par4+" "+par5); /// for debugging
  579. return true;
  580. }
  581.  
  582. public boolean writeBODoverrides(File writeTo)
  583. {
  584. try // write BOD(<version>).txt
  585. {
  586. BufferedWriter out = new BufferedWriter(new FileWriter(writeTo));
  587. out.write("# format:" + "\r\n");
  588. out.write("# X.add_new_ore=Y:Z" + "\r\n");
  589. out.write("# X = the override number, start counting from 1. once the progam doesnt see the next number it stops, so dont do 1, 2, 3, 5 because it will stop at 3" + "\r\n");
  590. out.write("# Y = the block ID" + "\r\n");
  591. out.write("# Z = the block meta data, almost all vanilla blocks are 0, with exceptions like colored wool, and half slabs" + "\r\n");
  592. out.write("# Note: If you enter an ID that isn't a block, then it will get stuck on Building terrain, or crash. This is an override after all" + "\r\n");
  593. out.write("1.add_new_ore=129:0" + "\r\n");
  594. out.close();
  595. }
  596. catch (IOException f)
  597. {
  598. System.out.println("could not write BODoverrides"); /// for debugging
  599. }
  600. return true;
  601. }
  602.  
  603. public boolean writeBOD(File writeTo)
  604. {
  605. try // write BOD(<version>).txt
  606. {
  607. BufferedWriter out = new BufferedWriter(new FileWriter(writeTo));
  608. out.write("#see forum for more instructions: http://www.minecraftforum.net/topic/330485-132spsmp-marcopolos-mods-better-ore-distributionv25beta3-trap-friendly-cactus-and-practical-tnt/" + "\r\n");
  609. out.write("#format X.Ysetting=Z" + "\r\n");
  610. out.write("# X = block ID" + "\r\n");
  611. out.write("# Y = meta data" + "\r\n");
  612. out.write("# Z = value for setting" + "\r\n");
  613.  
  614. out.write("#Dirt" + "\r\n"); // dirt
  615. out.write("3.0Rarity=50" + "\r\n");
  616. out.write("3.0VeinSize=30" + "\r\n");
  617. out.write("3.0VeinAmount=17" + "\r\n");
  618. out.write("3.0Height=128" + "\r\n");
  619. out.write("3.0VerticalShift=0" + "\r\n");
  620. out.write("3.0Diameter=32" + "\r\n");
  621. out.write("3.0VerticalDensity=1" + "\r\n");
  622. out.write("3.0HorizontalDensity=1" + "\r\n");
  623. out.write("3.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  624.  
  625. out.write("#Gravel" + "\r\n"); // gravel
  626. out.write("13.0Rarity=50" + "\r\n");
  627. out.write("13.0VeinSize=30" + "\r\n");
  628. out.write("13.0VeinAmount=17" + "\r\n");
  629. out.write("13.0Height=128" + "\r\n");
  630. out.write("13.0VerticalShift=0" + "\r\n");
  631. out.write("13.0Diameter=32" + "\r\n");
  632. out.write("13.0VerticalDensity=1" + "\r\n");
  633. out.write("13.0HorizontalDensity=1" + "\r\n");
  634. out.write("13.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  635.  
  636. out.write("#Gold" + "\r\n"); // gold
  637. out.write("14.0Rarity=140" + "\r\n");
  638. out.write("14.0VeinSize=8" + "\r\n");
  639. out.write("14.0VeinAmount=135" + "\r\n");
  640. out.write("14.0Height=80" + "\r\n");
  641. out.write("14.0VerticalShift=0" + "\r\n");
  642. out.write("14.0Diameter=60" + "\r\n");
  643. out.write("14.0VerticalDensity=20" + "\r\n");
  644. out.write("14.0HorizontalDensity=10" + "\r\n");
  645. out.write("14.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  646.  
  647. out.write("#Iron" + "\r\n"); // Iron
  648. out.write("15.0Rarity=75" + "\r\n");
  649. out.write("15.0VeinSize=8" + "\r\n");
  650. out.write("15.0VeinAmount=220" + "\r\n");
  651. out.write("15.0Height=80" + "\r\n");
  652. out.write("15.0VerticalShift=0" + "\r\n");
  653. out.write("15.0Diameter=65" + "\r\n");
  654. out.write("15.0VerticalDensity=15" + "\r\n");
  655. out.write("15.0HorizontalDensity=15" + "\r\n");
  656. out.write("15.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  657.  
  658. out.write("#Coal" + "\r\n"); // coal
  659. out.write("16.0Rarity=80" + "\r\n");
  660. out.write("16.0VeinSize=7" + "\r\n");
  661. out.write("16.0VeinAmount=330" + "\r\n");
  662. out.write("16.0Height=6" + "\r\n");
  663. out.write("16.0VerticalShift=45" + "\r\n");
  664. out.write("16.0Diameter=70" + "\r\n");
  665. out.write("16.0VerticalDensity=85" + "\r\n");
  666. out.write("16.0HorizontalDensity=10" + "\r\n");
  667. out.write("16.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  668.  
  669. out.write("#Lapis" + "\r\n"); // lapis
  670. out.write("21.0Rarity=225" + "\r\n");
  671. out.write("21.0VeinSize=8" + "\r\n");
  672. out.write("21.0VeinAmount=200" + "\r\n");
  673. out.write("21.0Height=50" + "\r\n");
  674. out.write("21.0VerticalShift=0" + "\r\n");
  675. out.write("21.0Diameter=70" + "\r\n");
  676. out.write("21.0VerticalDensity=20" + "\r\n");
  677. out.write("21.0HorizontalDensity=10" + "\r\n");
  678. out.write("21.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  679.  
  680. out.write("#Diamond" + "\r\n"); // daimond
  681. out.write("56.0Rarity=160" + "\r\n");
  682. out.write("56.0VeinSize=8" + "\r\n");
  683. out.write("56.0VeinAmount=220" + "\r\n");
  684. out.write("56.0Height=70" + "\r\n");
  685. out.write("56.0VerticalShift=0" + "\r\n");
  686. out.write("56.0Diameter=70" + "\r\n");
  687. out.write("56.0VerticalDensity=20" + "\r\n");
  688. out.write("56.0HorizontalDensity=10" + "\r\n");
  689. out.write("56.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  690.  
  691. out.write("#Redstone" + "\r\n"); // redstone
  692. out.write("73.0Rarity=110" + "\r\n");
  693. out.write("73.0VeinSize=12" + "\r\n");
  694. out.write("73.0VeinAmount=160" + "\r\n");
  695. out.write("73.0Height=12" + "\r\n");
  696. out.write("73.0VerticalShift=0" + "\r\n");
  697. out.write("73.0Diameter=160" + "\r\n");
  698. out.write("73.0VerticalDensity=20" + "\r\n");
  699. out.write("73.0HorizontalDensity=5"+ "\r\n");
  700. out.write("73.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  701.  
  702. out.write("#Emerald" + "\r\n"); // emerald
  703. out.write("129.0Rarity=110" + "\r\n");
  704. out.write("129.0VeinSize=3" + "\r\n");
  705. out.write("129.0VeinAmount=600" + "\r\n");
  706. out.write("129.0Height=60" + "\r\n");
  707. out.write("129.0VerticalShift=0" + "\r\n");
  708. out.write("129.0Diameter=60" + "\r\n");
  709. out.write("129.0VerticalDensity=20" + "\r\n");
  710. out.write("129.0HorizontalDensity=5"+ "\r\n");
  711. out.write("129.0UseMarcoVeins=false" + "\r\n" + "\r\n");
  712. out.close();
  713. }
  714. catch (IOException f)
  715. {
  716. System.out.println("could not write BODprops"); /// for debugging
  717. }
  718. return true;
  719. }
  720.  
  721. public boolean writeBODbiomes(File writeTo)
  722. {
  723. try
  724. {
  725. BufferedWriter out = new BufferedWriter(new FileWriter(writeTo));
  726. out.write("# 3.0=dirt, 13.0=gravel, 14.0=gold, 15.0=iron, 16.0=coal, 21.0=lapis, 56.0=diamond, 73.0=redstone" + "\r\n");
  727. out.write("\r\n");
  728. out.write("# ------------------------------------------------------------"+"\r\n");
  729. out.write("# format is OreID[X.Xo]-BiomeID[Y]=Z" + "\r\n");
  730. out.write("# X = Ore ID"+"\r\n");
  731. out.write("# Xo = meta data for Ore ID"+"\r\n");
  732. out.write("# Y = Biome ID"+"\r\n");
  733. out.write("# Z = the rarity you want for that ore in that biome"+"\r\n");
  734. out.write("# ------------------------------------------------------------"+"\r\n");
  735. out.write("\r\n");
  736. out.write("#-----------Ocean 0" + "\r\n");
  737. out.write("OreID[21.0]-BiomeID[0]=75" + "\r\n");
  738. out.write("\r\n");
  739.  
  740. out.write("#-----------Plains 1" + "\r\n");
  741. out.write("OreID[3.0]-BiomeID[1]=15" + "\r\n");
  742. out.write("OreID[13.0]-BiomeID[1]=15" + "\r\n");
  743. out.write("\r\n");
  744.  
  745. out.write("#-----------Desert 2" + "\r\n");
  746. out.write("OreID[15.0]-BiomeID[2]=37" + "\r\n");
  747. out.write("\r\n");
  748.  
  749. out.write("#-----------extremeHills 3" + "\r\n");
  750. out.write("OreID[14.0]-BiomeID[3]=70" + "\r\n");
  751. out.write("OreID[129.0]-BiomeID[3]=50" + "\r\n");
  752. out.write("\r\n");
  753.  
  754. out.write("#-----------Forest 4" + "\r\n");
  755. out.write("OreID[15.0]-BiomeID[4]=37" + "\r\n");
  756. out.write("\r\n");
  757.  
  758. out.write("#-----------Taiga 5" + "\r\n");
  759. out.write("OreID[16.0]-BiomeID[5]=42" + "\r\n");
  760. out.write("\r\n");
  761.  
  762. out.write("#-----------Swampland 6" + "\r\n");
  763. out.write("OreID[73.0]-BiomeID[6]=55" + "\r\n");
  764. out.write("\r\n");
  765.  
  766. out.write("#-----------River 7" + "\r\n");
  767. out.write("OreID[14.0]-BiomeID[7]=70" + "\r\n");
  768. out.write("\r\n");
  769.  
  770. out.write("#-----------FrozenOcean 10" + "\r\n");
  771. out.write("\r\n");
  772.  
  773. out.write("#-----------FrozenRiver 11" + "\r\n");
  774. out.write("\r\n");
  775.  
  776. out.write("#-----------IcePlains 12" + "\r\n");
  777. out.write("\r\n");
  778.  
  779. out.write("#-----------IceMountain 13" + "\r\n");
  780. out.write("\r\n");
  781.  
  782. out.write("#-----------MushroomIsland 14" + "\r\n");
  783. out.write("OreID[13.0]-BiomeID[14]=40" + "\r\n");
  784. out.write("OreID[14.0]-BiomeID[14]=50" + "\r\n");
  785. out.write("OreID[15.0]-BiomeID[14]=50" + "\r\n");
  786. out.write("OreID[16.0]-BiomeID[14]=50" + "\r\n");
  787. out.write("OreID[21.0]-BiomeID[14]=50" + "\r\n");
  788. out.write("OreID[56.0]-BiomeID[14]=50" + "\r\n");
  789. out.write("OreID[73.0]-BiomeID[14]=50" + "\r\n");
  790. out.write("\r\n");
  791. out.write("#-----------mushroomshore 15" + "\r\n");
  792. out.write("\r\n");
  793. out.write("#-----------Beach 16" + "\r\n");
  794. out.write("\r\n");
  795. out.write("#-----------DesertHills 17" + "\r\n");
  796. out.write("\r\n");
  797. out.write("#-----------ForestHills 18" + "\r\n");
  798. out.write("\r\n");
  799. out.write("#-----------taigaHills 19" + "\r\n");
  800. out.write("\r\n");
  801. out.write("#-----------ExtremeHillsEdge 20" + "\r\n");
  802. out.write("\r\n");
  803. out.write("#-----------Jungle 21" + "\r\n");
  804. out.write("\r\n");
  805. out.write("#-----------JungleHills 22" + "\r\n");
  806. out.write("\r\n");
  807.  
  808. out.close();
  809. }
  810. catch(IOException i)
  811. {
  812. System.out.println("could not write BODbiomes!!!"); /// for debugging
  813. }
  814. return true;
  815. }
  816.  
  817. //==========================================mp mod
  818. //private static int[] aOreCheck = new int[256];// setup array to store oreIDs for this chunk // has to be static to survive instance calls
  819. //private static int[] metaOreCheck = new int[16];// this is used to check the metaIDs of a given ore ID
  820. private static ArrayList oreList = new ArrayList();
  821. public static int MPChunk_X;
  822. public static int MPChunk_Z;
  823. private int x_Chunk;
  824. private int z_Chunk;
  825. public int MPBlockID;
  826. private int minableBlockMeta;
  827. public static int MPPrevX;
  828. public static int MPPrevZ;
  829. public static int MPPrevID;
  830. public static int MPPrevMeta;
  831. //public static int MPPrevID3;
  832. //public static int MPPrevID4;
  833. private static boolean genBeforeCheck;
  834. public static int mineCount;
  835. public static int mineCountM;
  836.  
  837. private static Random randomOut;
  838. private static Random rand;
  839. private static World worldObj;
  840. private File BODFileOres;
  841. static File BODFile;
  842. static File configDirectory;
  843. static File BODbiomesFile;
  844. String versionNum = "V(2.5.5)";
  845. private static WorldChunkManager worldChunkManager;
  846. private static WorldChunkManagerHell worldChunkManagerHell;
  847.  
  848. private int mineGen = 1;
  849. private int subMineGen = 1;
  850. private int rarity = 2;
  851. private int veinSi = 2;
  852. private int veinAm = 2;
  853. private int height = 2;
  854. private int mineHeight = 2;
  855. private int diameter = 2;
  856. private int vDens = 2;
  857. private int hDens = 2;
  858. private boolean useMarcoVeins = false;
  859.  
  860. //==========================================mp mod
  861. private int minableBlockId;
  862. private int numberOfBlocks;
  863. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement