Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 87.96 KB | None | 0 0
  1. from PIL import Image
  2. from Bo3_Bulkedit_Lib_ObjectLayout import DefaultObject_Start, DefaultObject_End
  3. from Bo3_Bulkedit_Lib_MatDictionary import MaterialDic
  4.  
  5. import os;
  6. import glob
  7. import thread
  8. import sys
  9. import nbt
  10. import time
  11.  
  12. #####################
  13. ### - Functions - ###
  14. #####################
  15.  
  16. wait_text = {}
  17. wait_text[0] = "[INFO]"
  18. wait_text[1] = "[INFO]"+" Work it, ..."
  19. wait_text[2] = "[INFO]"+" Make it, ..."
  20. wait_text[3] = "[INFO]"+" Do it, ..."
  21. wait_text[4] = "[INFO]"+" Makes us, ..."
  22. wait_text[5] = "[INFO]"
  23. wait_text[6] = "[INFO]"+" Harder, "
  24. wait_text[7] = "[INFO]"+" Better, "
  25. wait_text[8] = "[INFO]"+" Faster, "
  26. wait_text[9] = "[INFO]"+" Stronger, "
  27. wait_text[10] = "[INFO]"
  28. wait_text[11] = "[INFO]"+" More than, "
  29. wait_text[12] = "[INFO]"+" Hour, "
  30. wait_text[13] = "[INFO]"+" Our, "
  31. wait_text[14] = "[INFO]"+" Never, "
  32. wait_text[15] = "[INFO]"+" Ever, "
  33. wait_text[16] = "[INFO]"+" After, "
  34. wait_text[17] = "[INFO]"+" Work is, "
  35. wait_text[18] = "[INFO]"+" Over, "
  36. wait_text[19] = "[INFO]"
  37. wait_text[20] = "[INFO]"+" Work it harder, "
  38. wait_text[21] = "[INFO]"+" Make it better, "
  39. wait_text[22] = "[INFO]"+" Do it faster, "
  40. wait_text[23] = "[INFO]"+" Makes us stronger, "
  41. wait_text[24] = "[INFO]"
  42. wait_text[25] = "[INFO]"+" More than ever, "
  43. wait_text[26] = "[INFO]"+" Hour after, "
  44. wait_text[27] = "[INFO]"+" Our work is, "
  45. wait_text[28] = "[INFO]"+" Never over, "
  46. def iterate_nbt(nbt_object):
  47. def cycle_data(nbt, depth, list):
  48. data = ""
  49. string = ""
  50. name = ""
  51. string_add = ""
  52. name_add = ""
  53. indend = ""
  54. for i in range(0, depth): indend = indend+" "
  55. depth += 1
  56. id = 0
  57. for data in nbt:
  58. if list == True:
  59. key = id
  60. else:
  61. key = data
  62. string_add = ""
  63. data_type = str(type(nbt[key]))[str(type(nbt[key])).find("TAG",0):len(str(type(nbt[key])))-2]
  64. if data_type not in known_tags:
  65. print nbt[key].tag_info()
  66. print data_type
  67. print string
  68. raw_input()
  69. if data_type in value_tags:
  70. #if str(nbt[key]) != "0" and str(nbt[key]) != "0.0":
  71. if id >=1 : string = string+","
  72. if list == True:
  73. string = string+''+str(nbt[key])+''
  74. else:
  75. string = string+str(key)+":"+''+str(nbt[key])+''
  76. id += 1
  77. elif data_type == "TAG_List":
  78. data_add , string_add , name_add = cycle_data(nbt[key] , 1 , True)
  79. #if "["+string_add+"]" != "[]":
  80. if id >=1 : string = string+","
  81. string += key+":["+string_add+"]"
  82. id += 1
  83. elif data_type == "TAG_Compound":
  84. try:
  85. if "'" in str(nbt[key].tag_info()):
  86. comp_name = str(nbt[key].tag_info())
  87. comp_name = comp_name[comp_name.find("'",0)+1:]
  88. comp_name = comp_name[:comp_name.find("'",0)]
  89. else:
  90. comp_name = ""
  91. except:
  92. comp_name = ""
  93. data_add , string_add , name_add = cycle_data(nbt[key] , 1 , False)
  94. #if "{"+string_add+"}" != "{}":
  95. if id >=1 : string+=","
  96. if comp_name != "":
  97. string +=comp_name+":{"+string_add+"}"
  98. else:
  99. string +="{"+string_add+"}"
  100. id += 1
  101. elif data_type == "TAG_String":
  102. if str(nbt[key]) != "":
  103. if id >=1 : string = string+","
  104. string = string+str(key)+":"+'"'+str(nbt[key])+'"'
  105. id += 1
  106. elif data_type == "TAG_Float":
  107. #if str(nbt[key]) != "0" and str(nbt[key]) != "0.0":
  108. if id >=1 : string = string+","
  109. if list == True:
  110. string = string+''+str(nbt[key])+''
  111. else:
  112. string = string+str(key)+":"+''+str(nbt[key])+'f'
  113. id += 1
  114.  
  115. string_add = ""
  116. return data, string, name
  117.  
  118. newNBT = nbt.NBTFile()
  119. string = "{"
  120. string_add = ""
  121. name_add = ""
  122. try:
  123. name = str(nbt_object["id"])[str(nbt_object["id"]).find(":",0)+1:]
  124. except:
  125. name = ""
  126. id = 0
  127. known_tags = ["TAG_Byte","TAG_Long","TAG_Int","TAG_Short","TAG_Double","TAG_List","TAG_Compound","TAG_String","TAG_Float"]
  128. value_tags = ["TAG_Byte","TAG_Long","TAG_Int","TAG_Short","TAG_Double"]
  129. ignore_tags = ["x","y","z","Spigot.ticksLived","UUIDLeast","UUIDMost","WorldUUIDLeast","WorldUUIDMost","Pos","Bukkit.updateLevel","PortalCooldown","OnGround","Dimension","Air","Fire","HurtTime","HurtByTimestamp"]
  130. for data in nbt_object:
  131. if data not in ignore_tags:
  132. string_add = ""
  133. newNBT.tags.append(nbt_object[data])
  134. data_type = str(type(nbt_object[data]))[str(type(nbt_object[data])).find("TAG",0):len(str(type(nbt_object[data])))-2]
  135. if data_type not in known_tags:
  136. print nbt_object[data].tag_info()
  137. print data_type
  138. print string
  139. raw_input()
  140. if data_type in value_tags:
  141. #if str(nbt_object[data]) != "0" and str(nbt_object[data]) != "0.0":
  142. if id >=1 : string = string+","
  143. string = string+str(data)+":"+''+str(nbt_object[data])+''
  144. id += 1
  145. elif data_type == "TAG_List":
  146. data_add , string_add , name_add = cycle_data(nbt_object[data] , 1 , True)
  147. #if "["+string_add+"]" != "[]":
  148. if id >=1 : string = string+","
  149. string += data+":["+string_add+"]"
  150. id += 1
  151. elif data_type == "TAG_Compound":
  152. try:
  153. if "'" in str(nbt_object[data].tag_info()):
  154. comp_name = str(nbt_object[data].tag_info())
  155. comp_name = comp_name[comp_name.find("'",0)+1:]
  156. comp_name = comp_name[:comp_name.find("'",0)]
  157. else:
  158. comp_name = ""
  159. except:
  160. comp_name = ""
  161. data_add , string_add , name_add = cycle_data(nbt_object[data] , 1 , False)
  162. #if "{"+string_add+"}" != "{}":
  163. if id >=1 : string+=","
  164. if comp_name != "":
  165. string +=comp_name+":{"+string_add+"}"
  166. else:
  167. string +="{"+string_add+"}"
  168. id += 1
  169. elif data_type == "TAG_String":
  170. if str(nbt_object[data]) != "":
  171. if id >=1 : string = string+","
  172. string = string+str(data)+":"+'"'+str(nbt_object[data])+'"'
  173. id += 1
  174. elif data_type == "TAG_Float":
  175. #if str(nbt_object[data]) != "0" and str(nbt_object[data]) != "0.0" and str(nbt_object[data]) != "":
  176. if id >=1 : string = string+","
  177. string = string+str(data)+":"+''+str(nbt_object[data])+'f'
  178. id += 1
  179.  
  180. name = name+name_add
  181. string = string+"}"
  182. if "minecraft:" in str(newNBT["id"]):
  183. newNBT["id"].value = str(nbt_object["id"])[str(nbt_object["id"]).find(":",0)+1:]
  184. return newNBT, string, name
  185.  
  186. def busy_progress():
  187. global progress_time
  188. global progress_time_first
  189. global progress_time_amt
  190. global wait_text
  191. global debug
  192. if debug != "true":
  193. if progress_time_first == False:
  194. if time.time() > progress_time + 10:
  195. progress_time_first = True
  196. print "[INFO] This is taking much Work, ..."
  197. progress_time = time.time()
  198. else:
  199. if time.time() > progress_time + 10:
  200. print wait_text[progress_time_amt]
  201. progress_time_amt = progress_time_amt + 1
  202. progress_time = time.time()
  203. if progress_time_amt > 28:
  204. progress_time_amt = 20
  205.  
  206. def find_nth(haystack, needle, n):
  207. start = haystack.find(needle)
  208. while start >= 0 and n > 1:
  209. start = haystack.find(needle, start+len(needle))
  210. n -= 1
  211. return start
  212. def indexstring(value):
  213. if value < 10:
  214. return str("0" + str(value))
  215. else:
  216. return str(value)
  217. def create_settings(name):
  218. Object_Comments[name] = "-NONE-"
  219. Object_Splits[name] = "False"
  220. Object_Desc[name] = "-NONE-"
  221. Object_Tree[name] = "-NONE-"
  222. Object_Freq[name] = "-NONE-"
  223. Object_Rare[name] = "-NONE-"
  224. Object_Rot[name] = "-NONE-"
  225. Object_Spawn[name] = "-NONE-"
  226. Object_Offset[name] = "-NONE-"
  227. Object_Var[name] = "-NONE-"
  228. Object_Min[name] = "-NONE-"
  229. Object_Max[name] = "-NONE-"
  230. Object_Ext[name] = "-NONE-"
  231. Object_ExtBlocks[name] = "-NONE-"
  232. Object_Branches[name] = "-NONE-"
  233. Object_Biomes[name] = "-NONE-"
  234. Object_SourceBlocks[name] = "-NONE-"
  235. Object_SourcePercent[name] = "-NONE-"
  236. Object_SourcePlacement[name] = "-NONE-"
  237. Object_Shift_X[name] = 0
  238. Object_Shift_Y[name] = 0
  239. Object_Shift_Z[name] = 0
  240. Object_Preview[name] = 0
  241. counter = 0
  242. listaddress = name + "_" + str(counter)
  243. PlaceHolder_Air[name] = ""
  244. PlaceHolder_Remove[name] = ""
  245. PlaceHolder_Check[name] = ""
  246. PlaceHolder_Branch[name] = ""
  247. PlaceHolder_Center[name] = ""
  248. Change_Operation[name] = 0
  249. Change_Type[listaddress] = "-NONE-"
  250. Change_Type_To[listaddress] = "-NONE-"
  251. Change_Block[listaddress] = "-NONE-"
  252. Change_Block_To[listaddress] = "-NONE-"
  253.  
  254. ########################
  255. ### Funny Start Text ###
  256. ########################
  257. print "\n\n\n\n"
  258. print "#####".center(50, " ")
  259. print "###########".center(50, " ")
  260. print "###################".center(50, " ")
  261. print "Starting - Sanctuary BO3-Editor".center(50, " ")
  262. print "###################".center(50, " ")
  263. print "###########".center(50, " ")
  264. print "#####".center(50, " ")
  265. print "\n"
  266. print "___...--{Bastard AI from Hell at your Service}--...___".center(50, " ")
  267. print "\n\n"
  268. print "\n\n"
  269. error = "false"
  270.  
  271. ############################
  272. ### - Creating Folders - ###
  273. ############################
  274. ### - Object Folder - ###
  275. if os.path.exists("./Objects/"):
  276. pathexist = "true"
  277. else:
  278. try:
  279. os.mkdir("./Objects/")
  280. print "[INFO] I created a Folder 'Objects'."
  281. print "[INFO] Move your *.Bo3 files to that Folder'."
  282. print "[INFO] BulkEdit will modify all *.Bo3 files located there.'"
  283. except:
  284. error = "true"
  285. print "[--!Error!--] I could not Create a Neccessary Folder."
  286. print "[INFO] Create a Folder Called 'Objects' at this location."
  287. print "[INFO] Move your *.Bo3 files to that Folder'."
  288. print "[INFO] BulkEdit will modify all *.Bo3 files located there.'"
  289. ### - Result Folder - ###
  290. if os.path.exists("./Results/"):
  291. pathexist = "true"
  292. else:
  293. try:
  294. os.mkdir("./Results/")
  295. print "[INFO] I created a Folder 'Results'."
  296. print "[INFO] Processed Objects will be placed there."
  297. except:
  298. error = "true"
  299. print "[--!Error!--] I could not Create a Neccessary Folder."
  300. print "[INFO] Create a Folder Called 'Results' at this location."
  301. print "[INFO] Processed Objects will be placed there."
  302. if os.path.exists("./Results/NBT/"):
  303. pathexist = "true"
  304. else:
  305. try:
  306. os.mkdir("./Results/NBT/")
  307. print "[INFO] I created a Folder 'NBT'."
  308. print "[INFO] Processed NBT data will be placed there."
  309. except:
  310. error = "true"
  311. print "[--!Error!--] I could not Create a Neccessary Folder."
  312. print "[INFO] Create a Folder Called 'Results/NBT/' at this location."
  313. print "[INFO] Processed Objects will be placed there."
  314. if os.path.exists("./Results/Preview/"):
  315. pathexist = "true"
  316. else:
  317. try:
  318. os.mkdir("./Results/Preview/")
  319. print "[INFO] I created a Folder 'Results'."
  320. print "[INFO] Processed Objects will be placed there."
  321. except:
  322. error = "true"
  323. print "[--!Error!--] I could not Create a Neccessary Folder."
  324. print "[INFO] Create a Folder Called 'Results/Preview/' at this location."
  325. print "[INFO] Processed Previews will be placed there."
  326.  
  327. #############################################
  328. ### - Reading and Generating ConfigFile - ###
  329. #############################################
  330. debug = "false"
  331. debug_msg = []
  332. debug_faulty = []
  333. progress_time = time.time()
  334. progress_time_amt = 0
  335. progress_time_first = False
  336. object_region = {}
  337. branchspace = []
  338.  
  339. naming_Block = ["Block(", "block(", "BLOCK(", "b(", "B("]
  340. naming_RandomBlock = ["RandomBlock(", "randomblock(", "RANDOMBLOCK(", "rb(", "RB("]
  341. naming_Branch = ["Branch(", "branch(", "BRANCH(", "br(", "BR"]
  342. naming_WeightedBranch = ["WeightedBranch(", "weightedbranch(", "WEIGHTEDBRANCH(", "wbr(", "WBR("]
  343. naming_Object = ["MinecraftObject(", "minecraftobject(", "MINECRAFTOBJECT(", "mco(", "MCO("]
  344. naming_BlockCheck = ["BlockCheck(", "blockcheck(", "BLOCKCHECK(", "bc(", "BC("]
  345. naming_BlockCheckNot = ["BlockCheckNot(", "blockchecknot(", "BLOCKCHECKNOT(", "bcn(", "BCN("]
  346. naming_LightCheck = ["LightCheck(", "lightcheck(", "LIGHTCHECK(", "lc(", "LC("]
  347. naming_Entity = ["Entity(", "entity(", "ENTITY(", "e(", "E("]
  348. naming_list = naming_Block + naming_RandomBlock + naming_Branch + naming_WeightedBranch + naming_Object + naming_BlockCheck + naming_BlockCheckNot + naming_LightCheck + naming_Entity
  349. ### Preparing Variables ###
  350. ### --- BO3 Settings --- ###
  351. ### Main Object Settings ###
  352. BlackList_NBT = []
  353. Blacklist_Entity = []
  354. Object_Settings = []
  355. Object_Comments = {}
  356. Object_Splits = {}
  357. Object_SplitSize = {}
  358. Object_Desc = {}
  359. Object_Tree = {}
  360. Object_Freq = {}
  361. Object_Rare = {}
  362. Object_Rot = {}
  363. Object_Spawn = {}
  364. Object_Offset = {}
  365. Object_Var = {}
  366. Object_Min = {}
  367. Object_Max = {}
  368. Object_Ext = {}
  369. Object_ExtBlocks = {}
  370. Object_Branches = {}
  371. Object_Biomes = {}
  372. Object_SourceBlocks = {}
  373. Object_SourcePercent = {}
  374. Object_SourcePlacement = {}
  375. Object_Shift_X = {}
  376. Object_Shift_Y = {}
  377. Object_Shift_Z = {}
  378. Object_Preview = {}
  379. ### PlaceHolders ###
  380. PlaceHolder_Air = {}
  381. PlaceHolder_Remove = {}
  382. PlaceHolder_Check = {}
  383. PlaceHolder_Branch = {}
  384. PlaceHolder_Center = {}
  385. ### Changes ###
  386. Change_Operation = {}
  387. Change_Type = {}
  388. Change_Type_To = {}
  389. Change_Block = {}
  390. Change_Block_To = {}
  391. ### Material list ###
  392. BulkeEdit_Materials = {}
  393. Missing_ID_List = []
  394. Missing_Image_List = []
  395. Config_Version = ""
  396.  
  397. global temp_file
  398.  
  399. if debug == "true":
  400. for line in debug_msg:
  401. print "[DEBUG] " + line
  402. del debug_msg[:]
  403. raw_input()
  404. ##########################
  405. ####Read Material List####
  406. ##########################
  407.  
  408. BulkeEdit_Materials, debug_add = MaterialDic(debug)
  409. debug_msg + debug_add
  410.  
  411. ##########################
  412. #### Read Config File ####
  413. ##########################
  414. Settings_Current = ""
  415. try:
  416. File_Settings = open('./Bo3_BulkEdit_Settings.ini', 'r')
  417. for line in File_Settings:
  418. line = line.strip('\n')
  419. if line.startswith("Version: "):
  420. Config_Version = line[line.find(":",0)+2:]
  421. if "#" not in line[0:10]:
  422. if "Obj_" in line[0:4]:
  423. debug_msg.append("Found new Setting:" + line[4:line.find(":",0)])
  424. Object_Settings.append(line[4:line.find(":",0)])
  425. Settings_Current = line[4:line.find(":",0)]
  426. create_settings(Settings_Current)
  427. Change_Counter = 0
  428. if "BlackList_NBT:" in line:
  429. BlackList_NBT = line[line.find(":",0)+2:].split(" ")
  430. debug_msg.append("Changed BlackList_NBT to [" + str(BlackList_NBT) +"]")
  431. if "Blacklist_Entity:" in line:
  432. Blacklist_Entity = line[line.find(":",0)+2:].split(" ")
  433. debug_msg.append("Changed Blacklist_Entity to [" + str(Blacklist_Entity) +"]")
  434. if "RemoveComments:" in line:
  435. Object_Comments[Settings_Current] = line[line.find(":",0)+2:]
  436. debug_msg.append("Changed RemoveComments to [" + line[line.find(":",0)+2:] +"]")
  437. if "SplitObjects:" in line:
  438. Object_Splits[Settings_Current] = line[line.find(":",0)+2:]
  439. debug_msg.append("Changed SplitObjects to [" + line[line.find(":",0)+2:] +"]")
  440. if "SplitSize:" in line:
  441. Object_SplitSize[Settings_Current] = int(line[line.find(":",0)+2:])
  442. debug_msg.append("Changed SplitSize to [" + line[line.find(":",0)+2:] +"]")
  443. if "Description:" in line:
  444. Object_Desc[Settings_Current] = line[line.find(":",0)+2:]
  445. debug_msg.append("Changed Description to [" + line[line.find(":",0)+2:] +"]")
  446. if "Tree:" in line:
  447. Object_Tree[Settings_Current] = line[line.find(":",0)+2:]
  448. debug_msg.append("Changed Tree to [" + line[line.find(":",0)+2:] +"]")
  449. if "Frequency:" in line:
  450. Object_Freq[Settings_Current] = line[line.find(":",0)+2:]
  451. debug_msg.append("Changed Frequency to [" + line[line.find(":",0)+2:] +"]")
  452. if "Rarity:" in line:
  453. Object_Rare[Settings_Current] = line[line.find(":",0)+2:]
  454. debug_msg.append("Changed Rarity to [" + line[line.find(":",0)+2:] +"]")
  455. if "RotateRandomly:" in line:
  456. Object_Rot[Settings_Current] = line[line.find(":",0)+2:]
  457. debug_msg.append("Changed RotateRandomly to [" + line[line.find(":",0)+2:] +"]")
  458. if "SpawnHeight:" in line:
  459. Object_Spawn[Settings_Current] = line[line.find(":",0)+2:]
  460. debug_msg.append("Changed SpawnHeight to [" + line[line.find(":",0)+2:] +"]")
  461. if "SpawnHeightOffset:" in line:
  462. Object_Offset[Settings_Current] = line[line.find(":",0)+2:]
  463. debug_msg.append("Changed SpawnHeightOffset to [" + line[line.find(":",0)+2:] +"]")
  464. if "SpawnHeightVariance:" in line:
  465. Object_Var[Settings_Current] = line[line.find(":",0)+2:]
  466. debug_msg.append("Changed SpawnHeightVariance to [" + line[line.find(":",0)+2:] +"]")
  467. if "MinHeight:" in line:
  468. Object_Min[Settings_Current] = line[line.find(":",0)+2:]
  469. debug_msg.append("Changed MinHeight to [" + line[line.find(":",0)+2:] +"]")
  470. if "MaxHeight:" in line:
  471. Object_Max[Settings_Current] = line[line.find(":",0)+2:]
  472. debug_msg.append("Changed MaxHeight to [" + line[line.find(":",0)+2:] +"]")
  473. if "ExtrudeMode:" in line:
  474. Object_Ext[Settings_Current] = line[line.find(":",0)+2:]
  475. debug_msg.append("Changed ExtrudeMode to [" + line[line.find(":",0)+2:] +"]")
  476. if "ExtrudeThroughBlocks:" in line:
  477. Object_ExtBlocks[Settings_Current] = line[line.find(":",0)+2:]
  478. debug_msg.append("Changed ExtrudeThroughBlocks to [" + line[line.find(":",0)+2:] +"]")
  479. if "MaxBranchDepth:" in line:
  480. Object_Branches[Settings_Current] = line[line.find(":",0)+2:]
  481. debug_msg.append("Changed MaxBranchDepth to [" + line[line.find(":",0)+2:] +"]")
  482. if "ExcludedBiomes:" in line:
  483. Object_Biomes[Settings_Current] = line[line.find(":",0)+2:]
  484. debug_msg.append("Changed ExcludedBiomes to [" + line[line.find(":",0)+2:] +"]")
  485. if "SourceBlocks:" in line:
  486. Object_SourceBlocks[Settings_Current] = line[line.find(":",0)+2:]
  487. debug_msg.append("Changed SourceBlocks to [" + line[line.find(":",0)+2:] +"]")
  488. if "MaxPercentageOutsideSourceBlock:" in line:
  489. Object_SourcePercent[Settings_Current] = line[line.find(":",0)+2:]
  490. debug_msg.append("Changed MaxPercentageOutsideSourceBlock to [" + line[line.find(":",0)+2:] +"]")
  491. if "OutsideSourceBlock:" in line:
  492. Object_SourcePlacement[Settings_Current] = line[line.find(":",0)+2:]
  493. debug_msg.append("Changed OutsideSourceBlock to [" + line[line.find(":",0)+2:] +"]")
  494. if "Shift_X:" in line:
  495. Object_Shift_X[Settings_Current] = line[line.find(":",0)+2:]
  496. debug_msg.append("Changed Shift X to [" + line[line.find(":",0)+2:] +"]")
  497. if "Shift_Y:" in line:
  498. Object_Shift_Y[Settings_Current] = line[line.find(":",0)+2:]
  499. debug_msg.append("Changed Shift Y to [" + line[line.find(":",0)+2:] +"]")
  500. if "Shift_Z:" in line:
  501. Object_Shift_Z[Settings_Current] = line[line.find(":",0)+2:]
  502. debug_msg.append("Changed Shift Z to [" + line[line.find(":",0)+2:] +"]")
  503. if "Preview:" in line:
  504. Object_Preview[Settings_Current] = line[line.find(":",0)+2:]
  505. debug_msg.append("Changed Preview to [" + line[line.find(":",0)+2:] +"]")
  506. ### PlaceHolders ###
  507. if "AIR_Block:" in line:
  508. PlaceHolder_Air[Settings_Current] += ","+line[line.find(":",0)+2:]
  509. if ":" not in line[line.find(":",0)+2:]:
  510. PlaceHolder_Air[Settings_Current] += ","+line[line.find(":",0)+2:]+":0"
  511. debug_msg.append("Changed Air Placeholder to [" + PlaceHolder_Air[Settings_Current] +"]")
  512. if "REMOVE_Block:" in line:
  513. PlaceHolder_Remove[Settings_Current] += ","+line[line.find(":",0)+2:]
  514. if ":" not in line[line.find(":",0)+2:]:
  515. PlaceHolder_Remove[Settings_Current] += ","+line[line.find(":",0)+2:]+":0"
  516. debug_msg.append("Changed Remove Placeholder to [" + PlaceHolder_Remove[Settings_Current] +"]")
  517. if "CHECK_Block:" in line:
  518. PlaceHolder_Check[Settings_Current] += ","+line[line.find(":",0)+2:]
  519. if ":" not in line[line.find(":",0)+2:]:
  520. PlaceHolder_Check[Settings_Current] += ","+line[line.find(":",0)+2:]+":0"
  521. debug_msg.append("Changed BlockCheck Placeholder to [" + PlaceHolder_Check[Settings_Current] +"]")
  522. if "BRANCH_Block:" in line:
  523. PlaceHolder_Branch[Settings_Current] += ","+line[line.find(":",0)+2:]
  524. if ":" not in line[line.find(":",0)+2:]:
  525. PlaceHolder_Branch[Settings_Current] += ","+line[line.find(":",0)+2:]+":0"
  526. debug_msg.append("Changed Branch Placeholder to [" + PlaceHolder_Branch[Settings_Current] +"]")
  527. if "CENTER_Block:" in line:
  528. PlaceHolder_Center[Settings_Current] += ","+line[line.find(":",0)+2:]
  529. if ":" not in line[line.find(":",0)+2:]:
  530. PlaceHolder_Center[Settings_Current] += ","+line[line.find(":",0)+2:]+":0"
  531. debug_msg.append("Changed Center Placeholder to [" + PlaceHolder_Center[Settings_Current] +"]")
  532. ### Changes ###
  533. if "Change:" in line:
  534. listaddress = Settings_Current + "_" + str(Change_Counter)
  535. Change_Operation[Settings_Current] = Change_Counter
  536. Change_Counter += 1
  537. Change_Type[listaddress] = line[line.find(":",0)+2:find_nth(line, "->", 1)-1]
  538. Change_Type_To[listaddress] = line[find_nth(line, "->", 1)+3:find_nth(line, "|", 1)-1]
  539. Change_Block[listaddress] = line[find_nth(line, "|", 1)+2:find_nth(line, "->", 2)-1]
  540. Change_Block_To[listaddress] = line[find_nth(line, "->", 2)+3:]
  541. debug_msg.append(str(Change_Operation[Settings_Current]) + ":" + Change_Type[listaddress] + "->" + Change_Type_To[listaddress] + " | " + Change_Block[listaddress] + "->" + Change_Block_To[listaddress])
  542. File_Settings.close()
  543. except:
  544. print "[WARN] Config File missing or contains Errors."
  545. print "[WARN] Config File will be Regenerated."
  546. print "[INFO] Press ANY-Key to continue."
  547. raw_input()
  548. print "[INFO] Writing..."
  549. create_settings("default")
  550. Object_Settings.append("default")
  551. File_Settings = open("./Bo3_BulkEdit_Settings.ini", "wb")
  552. File_Settings.write("### Default Settings ###\n");
  553. File_Settings.write("Version: 1.05\n");
  554. File_Settings.write("Obj_default:\n");
  555. File_Settings.write(" ######################\n");
  556. File_Settings.write(" ### Basic Settings ###\n");
  557. File_Settings.write(" ######################\n");
  558. File_Settings.write(" RemoveComments: false\n");
  559. File_Settings.write(" SplitObjects: true\n");
  560. File_Settings.write(" Description: -NONE-\n");
  561. File_Settings.write(" Tree: -NONE-\n");
  562. File_Settings.write(" Frequency: -NONE-\n");
  563. File_Settings.write(" Rarity: -NONE-\n");
  564. File_Settings.write(" RotateRandomly: -NONE-\n");
  565. File_Settings.write(" SpawnHeight: -NONE-\n");
  566. File_Settings.write(" SpawnHeightOffset: -NONE-\n");
  567. File_Settings.write(" SpawnHeightVariance: -NONE-\n");
  568. File_Settings.write(" MinHeight: -NONE-\n");
  569. File_Settings.write(" MaxHeight: -NONE-\n");
  570. File_Settings.write(" ExtrudeMode: -NONE-\n");
  571. File_Settings.write(" ExtrudeThroughBlocks: -NONE-\n");
  572. File_Settings.write(" MaxBranchDepth: -NONE-\n");
  573. File_Settings.write(" ExcludedBiomes: -NONE-\n");
  574. File_Settings.write(" SourceBlocks: -NONE-\n");
  575. File_Settings.write(" MaxPercentageOutsideSourceBlock: -NONE-\n");
  576. File_Settings.write(" OutsideSourceBlock: -NONE-\n");
  577. File_Settings.write(" ### Preview - BO3 Bulk Edit will generate an Object Preview ###\n");
  578. File_Settings.write(" Preview: false\n");
  579. File_Settings.write(" #################################################\n");
  580. File_Settings.write(" ### PlaceHolder Settings ###\n");
  581. File_Settings.write(" ### You may use these Settings Multiple times ###\n");
  582. File_Settings.write(" #################################################\n");
  583. File_Settings.write(" AIR_Block: SPONGE:1\n");
  584. File_Settings.write(" REMOVE_Block: IRON_BLOCK\n");
  585. File_Settings.write(" CHECK_Block: EMERALD_BLOCK\n");
  586. File_Settings.write(" BRANCH_Block: GOLD_BLOCK\n");
  587. File_Settings.write(" CENTER_Block: DIAMOND_BLOCK\n");
  588. File_Settings.write(" ###############################\n");
  589. File_Settings.write(" ### Shift Object ###\n");
  590. File_Settings.write(" ### Moves the Object around ###\n");
  591. File_Settings.write(" ###############################\n");
  592. File_Settings.write(" Shift_X: 0\n");
  593. File_Settings.write(" Shift_Y: 0\n");
  594. File_Settings.write(" Shift_Z: 0\n");
  595. File_Settings.write(" ######################################################################################################\n");
  596. File_Settings.write(" ### Block Changes: ###\n");
  597. File_Settings.write(" ### EXAMPLE: Change: Block -> RandomBlock | SMOOTH_BRICK:1 -> SMOOTH_BRICK:1,50,SMOOTH_BRICK:2,100 ###\n");
  598. File_Settings.write(" ######################################################################################################\n");
  599. File_Settings.write(" Change: Block -> RandomBlock | SMOOTH_BRICK:1 -> SMOOTH_BRICK,40,SMOOTH_BRICK:1,50,SMOOTH_BRICK:2,40,COBBLESTONE,100\n");
  600. File_Settings.close()
  601. print "[INFO] Done."
  602.  
  603. #############################
  604. #### Process Objects ####
  605. #############################
  606. if debug == "true":
  607. for line in debug_msg:
  608. print "[DEBUG] " + line
  609. del debug_msg[:]
  610. raw_input()
  611. if error == "false":
  612. print "[INFO] Reading Objects, ..."
  613. Processed_Blocks = 0
  614. Processed_Objects = 0
  615. Processed_Remove = 0
  616. Processed_Checks = 0
  617. Processed_Branches = 0
  618. BlockChecks = []
  619. Branches = []
  620. Object_Blocks = {}
  621. temp_file = []
  622. Object_Files = glob.glob('.\Objects\*.bo3')
  623. Object_Files.extend(glob.glob('.\Objects\*.schematic'))
  624. Object_Files.extend(glob.glob('.\Objects\*.bo2'))
  625.  
  626. for object in Object_Files:
  627. ### - Getting Object Name and Type - ###
  628. Use_Settings = "default"
  629. object_name = object[10:]
  630. debug_msg.append("Starting Object: "+ object_name +".")
  631. Is_Schematic = False
  632. Is_BO2 = False
  633. if ".schematic".lower() in object_name.lower():
  634. object_name = object_name[:object_name.find(".",0)]+".bo3"
  635. debug_msg.append("Dropping '.schematic' Extension.")
  636. Is_Schematic = True
  637. if ".bo2".lower() in object_name.lower():
  638. object_name = object_name[:object_name.find(".",0)]+".bo3"
  639. debug_msg.append("Dropping '.bo2' Extension.")
  640. Is_BO2 = True
  641. if "we-" in object_name[0:3]:
  642. object_name = object_name[3:]
  643. debug_msg.append("Dropping 'we-' prefix.")
  644. if "Obj-" in object_name[0:4]:
  645. Use_Settings = object_name[4:object_name.find("_",0)]
  646. debug_msg.append("Attempting to use Settings:[" + Use_Settings + "]")
  647. if Use_Settings not in Object_Settings:
  648. debug_msg.append("Settings dont Exist:[" + Use_Settings + "]")
  649. print "[WARN] Settings for '" + Use_Settings + "' are not set. Using default"
  650. Use_Settings = "default"
  651. object_name = object_name[object_name.find("_",0)+1:]
  652. ############################
  653. ### List Object Settings ###
  654. ############################
  655. if Object_Desc[Use_Settings] != "-NONE-":
  656. debug_msg.append("Adjusting Setting: [Description: " + Object_Desc[Use_Settings] + "]")
  657. if Object_Tree[Use_Settings] != "-NONE-":
  658. debug_msg.append("Adjusting Setting: [Tree: " + Object_Tree[Use_Settings] + "]")
  659. if Object_Freq[Use_Settings] != "-NONE-":
  660. debug_msg.append("Adjusting Setting: [Frequency: " + Object_Freq[Use_Settings] + "]")
  661. if Object_Rare[Use_Settings] != "-NONE-":
  662. debug_msg.append("Adjusting Setting: [Rarity: " + Object_Rare[Use_Settings] + "]")
  663. if Object_Rot[Use_Settings] != "-NONE-":
  664. debug_msg.append("Adjusting Setting: [RotateRandomly: " + Object_Rot[Use_Settings] + "]")
  665. if Object_Spawn[Use_Settings] != "-NONE-":
  666. debug_msg.append("Adjusting Setting: [SpawnHeight: " + Object_Spawn[Use_Settings] + "]")
  667. if Object_Offset[Use_Settings] != "-NONE-":
  668. debug_msg.append("Adjusting Setting: [SpawnHeightOffset: " + Object_Offset[Use_Settings] + "]")
  669. if Object_Var[Use_Settings] != "-NONE-":
  670. debug_msg.append("Adjusting Setting: [SpawnHeightVariance: " + Object_Var[Use_Settings] + "]")
  671. if Object_Min[Use_Settings] != "-NONE-":
  672. debug_msg.append("Adjusting Setting: [MinHeight: " + Object_Min[Use_Settings] + "]")
  673. if Object_Max[Use_Settings] != "-NONE-":
  674. debug_msg.append("Adjusting Setting: [MaxHeight: " + Object_Max[Use_Settings] + "]")
  675. if Object_Ext[Use_Settings] != "-NONE-":
  676. debug_msg.append("Adjusting Setting: [ExtrudeMode: " + Object_Ext[Use_Settings] + "]")
  677. if Object_ExtBlocks[Use_Settings] != "-NONE-":
  678. debug_msg.append("Adjusting Setting: [ExtrudeThroughBlocks: " + Object_ExtBlocks[Use_Settings] + "]")
  679. if Object_Branches[Use_Settings] != "-NONE-":
  680. debug_msg.append("Adjusting Setting: [MaxBranchDepth: " + Object_Branches[Use_Settings] + "]")
  681. if Object_Biomes[Use_Settings] != "-NONE-":
  682. debug_msg.append("Adjusting Setting: [ExcludedBiomes: " + Object_Biomes[Use_Settings] + "]")
  683. if Object_SourceBlocks[Use_Settings] != "-NONE-":
  684. debug_msg.append("Adjusting Setting: [SourceBlocks: " + Object_SourceBlocks[Use_Settings] + "]")
  685. if Object_SourcePercent[Use_Settings] != "-NONE-":
  686. debug_msg.append("Adjusting Setting: [MaxPercentageOutsideSourceBlock: " + Object_SourcePercent[Use_Settings] + "]")
  687. if Object_SourcePlacement[Use_Settings] != "-NONE-":
  688. debug_msg.append("Adjusting Setting: [OutsideSourceBlock: " + Object_SourcePlacement[Use_Settings] + "]")
  689. ############################
  690. ############################
  691. ############################
  692. debug_msg.append("Object will be saved as:[" + object_name + "]")
  693.  
  694. ### - Processing of Object - ###
  695. print "[INFO] Object: " + object_name
  696. with open(object, 'r') as object_file, open("./Results/" + object_name, 'wb') as new_object:
  697. ### - First Read Through for Center Blocks - ###
  698. progress_time_first = False
  699. del temp_file[:]
  700. del BlockChecks[:]
  701. del Branches[:]
  702. Processed_Objects += 1
  703. bo2_lines = 0
  704.  
  705. Object_DimX0 = 0
  706. Object_DimX1 = 0
  707. Object_DimY0 = 0
  708. Object_DimY1 = 0
  709. Object_DimZ0 = 0
  710. Object_DimZ1 = 0
  711. Obj_Block_amt = 0
  712.  
  713. Shift_X = int(Object_Shift_X[Use_Settings])
  714. Shift_Y = int(Object_Shift_Y[Use_Settings])
  715. Shift_Z = int(Object_Shift_Z[Use_Settings])
  716.  
  717. if debug == "true":
  718. i = 0
  719. while i <= Change_Operation[Use_Settings]:
  720. address = Use_Settings + "_" + str(i)
  721. debug_msg.append("Using these BlockChange Settings:")
  722. debug_msg.append("[" + str(i) + "] " + Change_Type[address] + " -> " + Change_Type_To[address] + " | " + Change_Block[address] + " -> " + Change_Block_To[address] + "")
  723. i += 1
  724. for line in debug_msg:
  725. print "[DEBUG] " + line
  726. del debug_msg[:]
  727. raw_input()
  728.  
  729. if Is_BO2 == True:
  730. debug_msg.append("Converting BO2 Object for use.")
  731. temp_file = temp_file + DefaultObject_Start()
  732. BO2_Data = False
  733. progress_time = time.time()
  734. for line in object_file:
  735. busy_progress()
  736. bo2_lines += 1
  737. line = line.strip('\n')
  738. BO2_Blocks = True
  739. if "=" in line:
  740. BO2_Blocks = False
  741. if "spawnOnBlockType=" in line:
  742. SpawnOnBlocks = str(line[line.find("=",0)+1:]).split(",")
  743. SpawnOnBlock = ""
  744. for sourceblock in SpawnOnBlocks:
  745. try:
  746. sourceblock = str(BulkeEdit_Materials[str(sourceblock)])
  747. except:
  748. sourceblock = str(sourceblock)
  749. print '[WARN] Material: "' +sourceblock+ '" is not regocnized. Will not be Changed.'
  750. if str(sourceblock) not in Missing_ID_List:
  751. Missing_ID_List.append(str(sourceblock))
  752. if object_name not in debug_faulty:
  753. debug_faulty.append(object_name + "(BO2 Conversion)")
  754. if SpawnOnBlock != "":
  755. SpawnOnBlock += "," + sourceblock
  756. else:
  757. SpawnOnBlock = sourceblock
  758. debug_msg.append("" + SpawnOnBlock +" is found as BlockCheck")
  759. BlockChecks.append("BlockCheck(0,-1,0," + SpawnOnBlock + ")\n")
  760. if "tree=" in line:
  761. BO2_Tree = str(line[line.find("=",0)+1:])
  762. debug_msg.append("Relevant Setting found: tree=" + BO2_Tree +"")
  763. if "randomRotation=" in line:
  764. BO2_Rotate = str(line[line.find("=",0)+1:])
  765. debug_msg.append("Relevant Setting found: randomRotation=" + BO2_Rotate +"")
  766. if "rarity=" in line:
  767. BO2_Rarity = str(line[line.find("=",0)+1:])
  768. debug_msg.append("Relevant Setting found: rarity=" + BO2_Rarity +"")
  769. if "collisionPercentage=" in line:
  770. BO2_Collision = str(line[line.find("=",0)+1:])
  771. debug_msg.append("Relevant Setting found: collisionPercentage=" + BO2_Collision +"")
  772. if "spawnElevationMin=" in line:
  773. BO2_YMin = str(line[line.find("=",0)+1:])
  774. debug_msg.append("Relevant Setting found: spawnElevationMin=" + BO2_YMin +"")
  775. if "spawnElevationMax=" in line:
  776. BO2_YMax = str(line[line.find("=",0)+1:])
  777. debug_msg.append("Relevant Setting found: spawnElevationMax=" + BO2_YMax +"")
  778. if "[DATA]" in line:
  779. BO2_Data = True
  780. BO2_Blocks = False
  781. debug_msg.append("Relevant Setting found: [Data] Starting to Collect Blocks")
  782. if BO2_Data == True and BO2_Blocks == True and "," in line and ":" in line:
  783.  
  784. x = line[:find_nth(line, ",", 1)]
  785. z = line[find_nth(line, ",", 1)+1:find_nth(line, ",", 2)]
  786. y = line[find_nth(line, ",", 2)+1:find_nth(line, ":", 1)]
  787. if "." in line:
  788. process_block_a = line[find_nth(line, ":", 1)+1:find_nth(line, ".", 1)]
  789. process_block_b = line[find_nth(line, ".", 1)+1:]
  790. else:
  791. process_block_a = line[find_nth(line, ":", 1)+1:]
  792. process_block_b = ""
  793. try:
  794. process_block = str(BulkeEdit_Materials[str(process_block_a)])
  795. except:
  796. process_block = str(process_block_a)
  797. if str(process_block_a) not in Missing_ID_List:
  798. print '[WARN] Material: "' +process_block_a+ '" is not regocnized. Will not be Changed.'
  799. Missing_ID_List.append(str(process_block_a))
  800. if object_name not in debug_faulty:
  801. debug_faulty.append(object_name + "(Missing Blocknames)")
  802. if str(process_block_a) != "0" and process_block_b != "":
  803. process_block = process_block +":"+ str(process_block_b)
  804. else:
  805. process_block = process_block
  806.  
  807. newline = "Block("+str(x)+","+str(y)+","+str(z)+","+str(process_block)+")"
  808.  
  809. debug_msg.append("Add Block: " + newline +"")
  810. temp_file.append(newline)
  811.  
  812. temp_file = temp_file + DefaultObject_End()
  813. #del object_file[:]
  814. object_file = temp_file[:]
  815. del temp_file[:]
  816.  
  817. if Is_Schematic == False:
  818. debug_msg.append("File is Object -> Object Processing")
  819. progress_time = time.time()
  820. for line in object_file:
  821. busy_progress()
  822. if any(x in line for x in ["Block(","RandomBlock(","MinecraftObject(","B(","RB(","block(","randomblock(","minecraftobject(","b(","rb("]):
  823. process_type = line[:line.find("(",0)]
  824. x = line[find_nth(line, "(", 1)+1:find_nth(line, ",", 1)]
  825. y = line[find_nth(line, ",", 1)+1:find_nth(line, ",", 2)]
  826. z = line[find_nth(line, ",", 2)+1:find_nth(line, ",", 3)]
  827. process_block = line[find_nth(line, ",", 3)+1:find_nth(line, ")", 1)]
  828. if process_type == "Block" and process_block in PlaceHolder_Center[Use_Settings]:
  829. Shift_X -= int(x)
  830. Shift_Y -= int(y)
  831. Shift_Z -= int(z)
  832. debug_msg.append("Adjusting Object: [" + str(Shift_X) + "," + str(Shift_Y) + "," + str(Shift_Z) + "]")
  833. temp_file.append(line)
  834.  
  835. else:
  836. debug_msg.append("File is Schematic -> Schematic Processing")
  837.  
  838. temp_file = temp_file + DefaultObject_Start()
  839.  
  840. Object_Schematic = nbt.NBTFile(object)
  841. debug_msg.append("Opening Schematic")
  842. Schematic_Height = int(Object_Schematic['Height'].value)
  843. debug_msg.append("Schematic Height:" + str(Schematic_Height))
  844. Schematic_Length = int(Object_Schematic['Length'].value)
  845. debug_msg.append("Schematic Length:" + str(Schematic_Length))
  846. Schematic_Width = int(Object_Schematic['Width'].value)
  847. debug_msg.append("Schematic Width:" + str(Schematic_Width))
  848. moddedblocks = True
  849. try:
  850. Schematic_Blocks_B = bytearray(Object_Schematic['AddBlocks'])
  851. Schematic_Blocks = Object_Schematic['Blocks']
  852. Schematic_Data = Object_Schematic['Data']
  853. except:
  854. Schematic_Blocks = Object_Schematic['Blocks']
  855. Schematic_Data = Object_Schematic['Data']
  856. moddedblocks = False
  857. #####################
  858. ### Read NBT Data ###
  859. #####################
  860.  
  861. try:
  862. NBT_Blocks = Object_Schematic['TileEntities']
  863. NBT_strings = {}
  864. NBT_strings_list = []
  865. NBT_name = {}
  866. for Block in NBT_Blocks:
  867. try:
  868. nbt_placement = str(Block["x"].value)+","+str(Block["y"].value)+","+str(Block["z"].value)
  869. NBT_Block_temp, NBT_string_temp, NBT_name_temp = iterate_nbt(Block)
  870.  
  871. #print NBT_name_temp+":"+NBT_string_temp
  872. #print NBT_strings
  873. if NBT_string_temp != "{}" and NBT_name_temp not in BlackList_NBT:
  874. if NBT_name_temp+":"+NBT_string_temp in NBT_strings_list:
  875. NBT_name[nbt_placement] = list(NBT_strings.keys())[list(NBT_strings.values()).index(NBT_name_temp+":"+NBT_string_temp)]
  876. else:
  877. number = 0
  878. while True:
  879. if NBT_name_temp+"_"+str(number) in NBT_strings.keys():
  880. number += 1
  881. else:
  882. NBT_strings[NBT_name_temp+"_"+str(number)] = NBT_name_temp+":"+NBT_string_temp
  883. NBT_strings_list.append(NBT_name_temp+":"+NBT_string_temp)
  884. NBT_Block_temp.write_file("./Results/NBT/"+NBT_name_temp+"_"+str(number)+".nbt")
  885. NBT_name[nbt_placement] = str(NBT_name_temp+"_"+str(number))
  886. break
  887. except:
  888. debug_msg.append("Error Reading Specific Block NBT Data")
  889. except:
  890. debug_msg.append("Error Reading Block NBT Data")
  891.  
  892. if debug == "true":
  893. for line in debug_msg:
  894. print "[DEBUG] " + line
  895. del debug_msg[:]
  896. raw_input()
  897. #####################
  898. ### Read Entity Data ###
  899. #####################
  900.  
  901. #try:
  902. Entity_List = []
  903. del Entity_List[:]
  904. NBT_Entity = Object_Schematic['Entities']
  905. NBT_strings = {}
  906. NBT_strings_list = []
  907. NBT_Entity_name = {}
  908. for Entity in NBT_Entity:
  909. #try:
  910. entity_temp_x = int(str(Entity["Pos"][0])[:str(Entity["Pos"][0]).find(".",0)]) - int(str(Object_Schematic['WEOriginX']))
  911. entity_temp_y = int(str(Entity["Pos"][1])[:str(Entity["Pos"][1]).find(".",0)]) - int(str(Object_Schematic['WEOriginY']))
  912. entity_temp_z = int(str(Entity["Pos"][2])[:str(Entity["Pos"][2]).find(".",0)]) - int(str(Object_Schematic['WEOriginZ'])) - 1
  913.  
  914. nbt_placement = str(entity_temp_x)+","+str(entity_temp_y)+","+str(entity_temp_z)
  915. NBT_Block_temp, NBT_string_temp, NBT_name_temp = iterate_nbt(Entity)
  916.  
  917. #print NBT_name_temp+":"+NBT_string_temp
  918. #print NBT_strings
  919. if NBT_string_temp != "{}" and NBT_name_temp not in Blacklist_Entity:
  920. if NBT_name_temp+":"+NBT_string_temp in NBT_strings_list:
  921. NBT_Entity_name[nbt_placement] = list(NBT_strings.keys())[list(NBT_strings.values()).index(NBT_name_temp+":"+NBT_string_temp)]
  922. else:
  923. number = 0
  924. while True:
  925. if NBT_name_temp+"_"+str(number) in NBT_strings.keys():
  926. number += 1
  927. else:
  928. NBT_strings[NBT_name_temp+"_"+str(number)] = NBT_name_temp+":"+NBT_string_temp
  929. NBT_strings_list.append(NBT_name_temp+":"+NBT_string_temp)
  930.  
  931. nbt_file = open("./Results/NBT/"+NBT_name_temp+"_"+str(number)+".txt", "wb")
  932. nbt_file.write(NBT_string_temp);
  933. nbt_file.close()
  934. NBT_Block_temp.write_file("./Results/NBT/"+NBT_name_temp+"_"+str(number)+".nbt")
  935. NBT_Entity_name[nbt_placement] = str(NBT_name_temp+"_"+str(number))
  936. break
  937. Entity_List.append(nbt_placement+","+str(Entity["id"].value)[str(Entity["id"]).find(":",0)+1:]+",1,./NBT/"+str(NBT_name_temp+"_"+str(number))+".txt")
  938. #except:
  939. # debug_msg.append("Error Reading Specific Entity NBT Data")
  940. #except:
  941. # debug_msg.append("Error Reading Entity NBT Data")
  942.  
  943. if debug == "true":
  944. for line in debug_msg:
  945. print "[DEBUG] " + line
  946. del debug_msg[:]
  947. raw_input()
  948.  
  949.  
  950. #Schematic_Blocks = Schematic_Blocks.split(" ")
  951. #Schematic_Data = Schematic_Blocks.split(" ")
  952.  
  953. x = 0
  954. y = 0
  955. z = 0
  956. byte_pos_A = 0
  957. byte_pos_B = 0
  958. process_ID = 0
  959. progress_time = time.time()
  960.  
  961. tmp_conversion_centerfound = False
  962. for Schematic_Block in Schematic_Blocks:
  963. busy_progress()
  964.  
  965. if moddedblocks == True:
  966. byte_pos_hl = int(byte_pos_A%2)
  967. if byte_pos_A > 0:
  968. byte_pos_B = int(byte_pos_A/2)
  969. high, low = Schematic_Blocks_B[byte_pos_B] >> 4, Schematic_Blocks_B[byte_pos_B] & 0x0F
  970. if byte_pos_hl == 0:
  971. Schematic_Block = int(Schematic_Block + (low << 8))
  972. if byte_pos_hl == 1:
  973. Schematic_Block = int(Schematic_Block + (high << 8))
  974. byte_pos_A = byte_pos_A + 1
  975.  
  976.  
  977. try:
  978. process_block = str(BulkeEdit_Materials[str(Schematic_Block)])
  979. except:
  980. process_block = str(Schematic_Block)
  981. if str(Schematic_Block) not in Missing_ID_List:
  982. print '[WARN] Material: "' +str(Schematic_Block)+ '" is not regocnized. Will not be Changed.'
  983. Missing_ID_List.append(str(Schematic_Block))
  984. if object_name + "(Missing Blocknames)" not in debug_faulty:
  985. debug_faulty.append(object_name + "(Missing Blocknames)")
  986. if str(Schematic_Data[process_ID]) != "0":
  987. process_block = process_block +":"+ str(Schematic_Data[process_ID])
  988. else:
  989. process_block = process_block +":"+ str(Schematic_Data[process_ID])
  990. if x > Schematic_Width - 1:
  991. z += 1
  992. x = 0
  993. if z > Schematic_Length - 1:
  994. y += 1
  995. z = 0
  996.  
  997. if process_block in PlaceHolder_Center[Use_Settings]:
  998. print "Center Found"
  999. tmp_conversion_centerfound = True
  1000. Shift_X -= int(x)
  1001. Shift_Y -= int(y)
  1002. Shift_Z -= int(z)
  1003. debug_msg.append("Adjusting Object: [" + str(Shift_X) + "," + str(Shift_Y) + "," + str(Shift_Z) + "]")
  1004. #### Add NBT ####
  1005. if process_block not in BlackList_NBT:
  1006. try:
  1007. process_block = process_block+",./NBT/"+NBT_name[str(x)+","+str(y)+","+str(z)]+".nbt"
  1008. except:
  1009. process_block = process_block
  1010. line = "Block("+str(x)+","+str(y)+","+str(z)+","+str(process_block)+")"
  1011. debug_msg.append(line)
  1012.  
  1013. x += 1
  1014. process_ID += 1
  1015. temp_file.append(line)
  1016. for Entity in Entity_List:
  1017. temp_file.append("Entity("+Entity+")")
  1018. if tmp_conversion_centerfound == False:
  1019. Shift_X -= 0 + int(Schematic_Width/2)
  1020. Shift_Y -= 0
  1021. Shift_Z -= 0 + int(Schematic_Length/2)
  1022. temp_file = temp_file + DefaultObject_End()
  1023. cursor = "settings"
  1024. branches_written = "false"
  1025. checks_written = "false"
  1026.  
  1027. if debug == "true":
  1028. for line in debug_msg:
  1029. print "[DEBUG] " + line
  1030. del debug_msg[:]
  1031. raw_input()
  1032. progress_time = time.time()
  1033. for line in temp_file:
  1034. busy_progress()
  1035. ### - Modify Object - ###
  1036. line = line.strip('\n')
  1037. skip = "false"
  1038. if "#" in line[0:1] and Object_Comments[Use_Settings] == "true":
  1039. ### - Removing Comments - ###
  1040. skip = "true"
  1041. debug_msg.append("Removing Comment: [" + line + "]")
  1042. if line == "" and Object_Comments[Use_Settings] == "true":
  1043. skip = "true"
  1044. if "#" not in line[0:1]:
  1045. ###################################
  1046. ### - Chaning Settings to BO3 - ###
  1047. ###################################
  1048. if Is_BO2 == True:
  1049. try:
  1050. if "Rarity:" in line[0:30]:
  1051. line = "Rarity: " + BO2_Rarity
  1052. debug_msg.append("Adjusting Setting: [" + line + "]")
  1053. if "RotateRandomly:" in line[0:30]:
  1054. line = "RotateRandomly: " + BO2_Rotate
  1055. debug_msg.append("Adjusting Setting: [" + line + "]")
  1056. if "MinHeight:" in line[0:30]:
  1057. line = "MinHeight: " + BO2_YMin
  1058. debug_msg.append("Adjusting Setting: [" + line + "]")
  1059. if "MaxHeight:" in line[0:30]:
  1060. line = "MaxHeight: " + BO2_YMax
  1061. debug_msg.append("Adjusting Setting: [" + line + "]")
  1062. if "MaxPercentageOutsideSourceBlock:" in line[0:56]:
  1063. line = "MaxPercentageOutsideSourceBlock: " + BO2_Collision
  1064. debug_msg.append("Adjusting Setting: [" + line + "]")
  1065. if "Tree:" in line[0:30] and Object_Tree[Use_Settings] != "-NONE-":
  1066. line = "Tree: " + BO2_Tree
  1067. debug_msg.append("Adjusting Setting: [" + line + "]")
  1068. except:
  1069. print '[WARN] There was an Error with your BO2 settings.'
  1070. if object_name not in debug_faulty:
  1071. debug_faulty.append(object_name + "(BO2 Conversion)")
  1072.  
  1073. if "Description:" in line[0:30] and Object_Desc[Use_Settings] != "-NONE-":
  1074. line = "Description: " + Object_Desc[Use_Settings]
  1075. debug_msg.append("Adjusting Setting: [" + line + "]")
  1076. if "Tree:" in line[0:30] and Object_Tree[Use_Settings] != "-NONE-":
  1077. line = "Tree: " + Object_Tree[Use_Settings]
  1078. debug_msg.append("Adjusting Setting: [" + line + "]")
  1079. if "Frequency:" in line[0:30] and Object_Freq[Use_Settings] != "-NONE-":
  1080. line = "Frequency: " + Object_Freq[Use_Settings]
  1081. debug_msg.append("Adjusting Setting: [" + line + "]")
  1082. if "Rarity:" in line[0:30] and Object_Rare[Use_Settings] != "-NONE-":
  1083. line = "Rarity: " + Object_Rare[Use_Settings]
  1084. debug_msg.append("Adjusting Setting: [" + line + "]")
  1085. if "RotateRandomly:" in line[0:30] and Object_Rot[Use_Settings] != "-NONE-":
  1086. line = "RotateRandomly: " + Object_Rot[Use_Settings]
  1087. debug_msg.append("Adjusting Setting: [" + line + "]")
  1088. if "SpawnHeight:" in line[0:30] and Object_Spawn[Use_Settings] != "-NONE-":
  1089. line = "SpawnHeight: " + Object_Spawn[Use_Settings]
  1090. debug_msg.append("Adjusting Setting: [" + line + "]")
  1091. if "SpawnHeightOffset:" in line[0:30] and Object_Offset[Use_Settings] != "-NONE-":
  1092. line = "SpawnHeightOffset: " + Object_Offset[Use_Settings]
  1093. debug_msg.append("Adjusting Setting: [" + line + "]")
  1094. if "SpawnHeightVariance:" in line[0:30] and Object_Var[Use_Settings] != "-NONE-":
  1095. line = "SpawnHeightVariance: " + Object_Var[Use_Settings]
  1096. debug_msg.append("Adjusting Setting: [" + line + "]")
  1097. if "MinHeight:" in line[0:30] and Object_Min[Use_Settings] != "-NONE-":
  1098. line = "MinHeight: " + Object_Min[Use_Settings]
  1099. debug_msg.append("Adjusting Setting: [" + line + "]")
  1100. if "MaxHeight:" in line[0:30] and Object_Max[Use_Settings] != "-NONE-":
  1101. line = "MaxHeight: " + Object_Max[Use_Settings]
  1102. debug_msg.append("Adjusting Setting: [" + line + "]")
  1103. if "ExtrudeMode:" in line[0:30] and Object_Ext[Use_Settings] != "-NONE-":
  1104. line = "ExtrudeMode: " + Object_Ext[Use_Settings]
  1105. debug_msg.append("Adjusting Setting: [" + line + "]")
  1106. if "ExtrudeThroughBlocks:" in line[0:30] and Object_ExtBlocks[Use_Settings] != "-NONE-":
  1107. line = "ExtrudeThroughBlocks: " + Object_ExtBlocks[Use_Settings]
  1108. debug_msg.append("Adjusting Setting: [" + line + "]")
  1109. if "MaxBranchDepth:" in line[0:30] and Object_Branches[Use_Settings] != "-NONE-":
  1110. line = "MaxBranchDepth: " + Object_Branches[Use_Settings]
  1111. debug_msg.append("Adjusting Setting: [" + line + "]")
  1112. if "ExcludedBiomes:" in line[0:30] and Object_Biomes[Use_Settings] != "-NONE-":
  1113. line = "ExcludedBiomes: " + Object_Biomes[Use_Settings]
  1114. debug_msg.append("Adjusting Setting: [" + line + "]")
  1115. if "SourceBlocks:" in line[0:30] and Object_SourceBlocks[Use_Settings] != "-NONE-":
  1116. line = "SourceBlocks: " + Object_SourceBlocks[Use_Settings]
  1117. debug_msg.append("Adjusting Setting: [" + line + "]")
  1118. if "MaxPercentageOutsideSourceBlock:" in line[0:56] and Object_SourcePercent[Use_Settings] != "-NONE-":
  1119. line = "MaxPercentageOutsideSourceBlock: " + Object_SourcePercent[Use_Settings]
  1120. debug_msg.append("Adjusting Setting: [" + line + "]")
  1121. if "OutsideSourceBlock:" in line[0:30] and Object_SourcePlacement[Use_Settings] != "-NONE-":
  1122. line = "OutsideSourceBlock: " + Object_SourcePlacement[Use_Settings]
  1123. debug_msg.append("Adjusting Setting: [" + line + "]")
  1124. ###############################
  1125. ### - Chaning Blocks here - ###
  1126. ###############################
  1127. #if any(x in line for x in ["Block(","RandomBlock(","MinecraftObject(","Entity(","B(","RB(","block(","randomblock(","minecraftobject(","b(","rb(","entity(", "E", "e", "mco", "MCO"]):
  1128. if line.startswith(tuple(naming_list)):
  1129. Processed_Blocks += 1
  1130. cursor = "blocks"
  1131. process_type = line[:line.find("(",0)]
  1132. x = int(line[find_nth(line, "(", 1)+1:find_nth(line, ",", 1)]) + Shift_X
  1133. y = int(line[find_nth(line, ",", 1)+1:find_nth(line, ",", 2)]) + Shift_Y
  1134. z = int(line[find_nth(line, ",", 2)+1:find_nth(line, ",", 3)]) + Shift_Z
  1135. process_block = line[find_nth(line, ",", 3)+1:find_nth(line, ")", 1)]
  1136.  
  1137. if process_type == "Block":
  1138. if process_block in PlaceHolder_Remove[Use_Settings]:
  1139. Processed_Remove += 1
  1140. skip = "true"
  1141. if process_block in PlaceHolder_Air[Use_Settings]: process_block = "AIR"
  1142. if process_block in PlaceHolder_Center[Use_Settings]: skip = "true"
  1143. if process_block in PlaceHolder_Check[Use_Settings]:
  1144. Processed_Checks += 1
  1145. BlockChecks.append("BlockCheck("+str(x)+","+str(y)+","+str(z)+",Solid)\n")
  1146. skip = "true"
  1147. if process_block in PlaceHolder_Branch[Use_Settings]:
  1148. Processed_Branches += 1
  1149. Branches.append("Branch("+str(x)+","+str(y)+","+str(z)+",<Branch>,NORTH,100)\n")
  1150. skip = "true"
  1151.  
  1152. i = 0
  1153. Entity_Placement = False
  1154. while i <= Change_Operation[Use_Settings]:
  1155. address = Use_Settings + "_" + str(i)
  1156. i += 1
  1157. short_type = "false"
  1158. if process_type == "B" or process_type == "b":
  1159. process_type = "Block"
  1160. short_type = "true"
  1161. if process_type == "RB" or process_type == "rb":
  1162. process_type = "RandomBlock"
  1163. short_type = "true"
  1164. if Change_Type[address] == process_type:
  1165. if Change_Block[address] == process_block or Change_Block[address]+":0" == process_block:
  1166. process_type = Change_Type_To[address]
  1167. process_block = Change_Block_To[address]
  1168. if Change_Type_To[address] == "Entity":
  1169. Entity_Placement = True
  1170.  
  1171. if short_type == "true":
  1172. if process_type == "Block" or process_type == "block":
  1173. process_type = "B"
  1174. if process_type == "RandomBlock" or process_type == "randomblock":
  1175. process_type = "RB"
  1176.  
  1177. if Entity_Placement == True:
  1178. line = "Block" + "("+str(x)+","+str(y)+","+str(z)+","+ "AIR" +")\n"+ process_type + "("+str(x)+","+str(y)+","+str(z)+","+ process_block +")"
  1179. else:
  1180. line = process_type + "("+str(x)+","+str(y)+","+str(z)+","+ process_block +")"
  1181.  
  1182.  
  1183. coords = str(x) + "," + str(y) + "," + str(z)
  1184. if Object_DimX0 > x: Object_DimX0 = x
  1185. if Object_DimX1 < x: Object_DimX1 = x
  1186. if Object_DimY0 > y: Object_DimY0 = y
  1187. if Object_DimY1 < y: Object_DimY1 = y
  1188. if Object_DimZ0 > z: Object_DimZ0 = z
  1189. if Object_DimZ1 < z: Object_DimZ1 = z
  1190. if any(x in line for x in ["Block(","RandomBlock(","B(","RB(","block(","randomblock(","b(","rb("]) and skip == "false":
  1191. if "," in process_block:
  1192. Object_Blocks[coords] = process_block[0:process_block.find(",",0)]
  1193. else:
  1194. Object_Blocks[coords] = process_block
  1195. if skip != "true": Obj_Block_amt +=1
  1196. if cursor == "checks" and any(x in line for x in ["BlockCheckNot(","LightCheck(","BlockCheck("]):
  1197. process_type = line[:line.find("(",0)]
  1198. x = int(line[find_nth(line, "(", 1)+1:find_nth(line, ",", 1)]) + Shift_X
  1199. y = int(line[find_nth(line, ",", 1)+1:find_nth(line, ",", 2)]) + Shift_Y
  1200. z = int(line[find_nth(line, ",", 2)+1:find_nth(line, ",", 3)]) + Shift_Z
  1201. process_block = line[find_nth(line, ",", 3)+1:find_nth(line, ")", 1)]
  1202. line = process_type + "("+str(x)+","+str(y)+","+str(z)+","+ process_block +")"
  1203. if cursor == "checks" and any(x not in line for x in ["BlockCheckNot(","LightCheck(","BlockCheck("]):
  1204. for check in BlockChecks:
  1205. line += check
  1206. debug_msg.append(check)
  1207. checks_written = "true"
  1208. if cursor == "branches" and any(x in line for x in ["Branch(","WeightedBranch("]):
  1209. process_type = line[:line.find("(",0)]
  1210. x = int(line[find_nth(line, "(", 1)+1:find_nth(line, ",", 1)]) + Shift_X
  1211. y = int(line[find_nth(line, ",", 1)+1:find_nth(line, ",", 2)]) + Shift_Y
  1212. z = int(line[find_nth(line, ",", 2)+1:find_nth(line, ",", 3)]) + Shift_Z
  1213. process_block = line[find_nth(line, ",", 3)+1:find_nth(line, ")", 1)]
  1214. line = process_type + "("+str(x)+","+str(y)+","+str(z)+","+ process_block +")"
  1215. if cursor == "branches" and any(x not in line for x in ["Branch(","WeightedBranch("]):
  1216. for branch in Branches:
  1217. line += branch
  1218. debug_msg.append(branch)
  1219. branches_written = "true"
  1220.  
  1221. if cursor == "checks" and any(x not in line for x in ["Block(","RandomBlock(","MinecraftObject(","BlockCheckNot(","LightCheck(","BlockCheck(","B(","RB(","block(","randomblock(","b(","rb("]) and Object_Comments[Use_Settings] == "true" and skip == "false":
  1222. cursor = "branches"
  1223. #line += "\n"
  1224. if cursor == "blocks" and any(x not in line for x in ["Block(","RandomBlock(","MinecraftObject(","minecraftobject(","B(","RB(","block(","randomblock(","b(","rb("]) and Object_Comments[Use_Settings] == "true" and skip == "false":
  1225. cursor = "checks"
  1226. #line += "\n"
  1227. if "# LightCheck(0,0,0,0,1) Require almost complete darkness just below the object" in line[0:1] and Object_Comments[Use_Settings] != "true":
  1228. cursor = "checks"
  1229. if "# MaxChanceOutOf - The chance all branches have to spawn out of, assumed to be 100 when left blank" in line[0:1] and Object_Comments[Use_Settings] != "true":
  1230. cursor = "branches"
  1231. if skip == "false":
  1232. new_object.write(line + "\n");
  1233. if checks_written == "false":
  1234. for check in BlockChecks:
  1235. line = check
  1236. debug_msg.append(check)
  1237. new_object.write(line);
  1238. if branches_written == "false":
  1239. for branch in Branches:
  1240. line = branch
  1241. debug_msg.append(branch)
  1242. new_object.write(line);
  1243.  
  1244. print "[INFO] Done: " + object_name + " with [" + str(Obj_Block_amt) + "] Blocks"
  1245. if debug == "true":
  1246. for line in debug_msg:
  1247. print "[DEBUG] " + line
  1248. del debug_msg[:]
  1249. raw_input()
  1250.  
  1251. new_object.close()
  1252. #############################
  1253. #### - Split up Object - ####
  1254. #############################
  1255. object_will_split = "False"
  1256. try:
  1257. object_split_size = int(Object_SplitSize[Use_Settings] / 2)
  1258. except:
  1259. object_split_size = 8
  1260. print object_split_size
  1261. print "I dont have a Valid Setting here"
  1262. object_region.clear()
  1263. del branchspace[:]
  1264. object_region_size_x = 0
  1265. object_region_size_z = 0
  1266.  
  1267. object_region_center_x = 0
  1268. object_region_center_z = 0
  1269.  
  1270. if Object_DimX1 > -1 + object_split_size:
  1271. object_will_split = "True"
  1272. if Object_DimX0 < 0 - object_split_size:
  1273. object_will_split = "True"
  1274. if Object_DimZ1 > -1 + object_split_size:
  1275. object_will_split = "True"
  1276. if Object_DimZ0 < 0 - object_split_size:
  1277. object_will_split = "True"
  1278. if Object_Splits[Use_Settings] == "true":
  1279. if object_will_split == "True":
  1280. print "[INFO] Object: " + object_name + " will be Split into a Structure"
  1281. debug_msg.append("Calculating Object Size")
  1282.  
  1283. tmp = Object_DimX1
  1284. while tmp > -1 + object_split_size:
  1285. object_region_size_x += 1
  1286. tmp -= object_split_size * 2
  1287. tmp = Object_DimZ1
  1288. while tmp > -1 + object_split_size:
  1289. object_region_size_z += 1
  1290. tmp -= object_split_size * 2
  1291. tmp = Object_DimX0
  1292. while tmp < 0 - object_split_size:
  1293. object_region_size_x += 1
  1294. object_region_center_x += 1
  1295. tmp += object_split_size * 2
  1296. tmp = Object_DimZ0
  1297. while tmp < 0 - object_split_size:
  1298. object_region_size_z += 1
  1299. object_region_center_z += 1
  1300. tmp += object_split_size * 2
  1301.  
  1302. debug_msg.append("Structure will be: [" + str(object_region_size_x+1) + "x" + str(object_region_size_z+1) + "] in size.")
  1303.  
  1304. if debug == "true":
  1305. for line in debug_msg:
  1306. print "[DEBUG] " + line
  1307. del debug_msg[:]
  1308. raw_input()
  1309.  
  1310. debug_msg.append("Generate Object Index")
  1311. counter_x = 0
  1312. counter_z = 0
  1313. while counter_z <= object_region_size_z:
  1314. counter_x = 0
  1315. if counter_z < 10:
  1316. index_z = str("0" + str(counter_z))
  1317. else:
  1318. index_z = str(counter_z)
  1319. while counter_x <= object_region_size_x:
  1320. if counter_x < 10:
  1321. index_x = str("0" + str(counter_x))
  1322. else:
  1323. index_x = str(counter_x)
  1324. object_region[str(index_x) + "_" + str(index_z)] = []
  1325. object_region[str(index_x) + "_" + str(index_z)] += DefaultObject_Start()
  1326. if debug == "true":
  1327. for line in debug_msg:
  1328. print "[DEBUG] " + line
  1329. del debug_msg[:]
  1330. counter_x += 1
  1331. counter_z += 1
  1332.  
  1333. debug_msg.append("Reading Object")
  1334. if debug == "true":
  1335. for line in debug_msg:
  1336. print "[DEBUG] " + line
  1337. del debug_msg[:]
  1338. structure_whole = open("./Results/" + object_name, 'r')
  1339. structure_main = []
  1340. for line in structure_whole.readlines():
  1341. if line.startswith(tuple(naming_list)):
  1342. process_type = line[:line.find("(",0)]
  1343. x = int(line[find_nth(line, "(", 1)+1:find_nth(line, ",", 1)])
  1344. y = int(line[find_nth(line, ",", 1)+1:find_nth(line, ",", 2)])
  1345. z = int(line[find_nth(line, ",", 2)+1:find_nth(line, ",", 3)])
  1346. process_block = line[find_nth(line, ",", 3)+1:find_nth(line, ")", 1)]
  1347. coords_x = object_region_center_x
  1348. coords_z = object_region_center_z
  1349. while x < (0 - object_split_size) or x > (-1 + object_split_size):
  1350. if x < (0 - object_split_size):
  1351. x += object_split_size*2
  1352. coords_x -= 1
  1353. if x > (-1 + object_split_size):
  1354. x -= object_split_size*2
  1355. coords_x += 1
  1356. while z < (0 - object_split_size) or z > (-1 + object_split_size):
  1357. if z < (0 - object_split_size):
  1358. z += object_split_size*2
  1359. coords_z -= 1
  1360. if z > (-1 + object_split_size):
  1361. z -= object_split_size*2
  1362. coords_z += 1
  1363.  
  1364.  
  1365. if coords_x < 10:
  1366. index_x = str("0" + str(coords_x))
  1367. else:
  1368. index_x = str(coords_x)
  1369. if coords_z < 10:
  1370. index_z = str("0" + str(coords_z))
  1371. else:
  1372. index_z = str(coords_z)
  1373.  
  1374. line = process_type + "("+str(x+object_split_size)+","+str(y)+","+str(z+object_split_size)+","+ process_block +")"
  1375. object_region[str(index_x) + "_" + str(index_z)].append(line)
  1376. else:
  1377. structure_main.append(line)
  1378. ### Creating Objects ###
  1379. debug_msg.append("Generating Object")
  1380. if debug == "true":
  1381. for line in debug_msg:
  1382. print "[DEBUG] " + line
  1383. del debug_msg[:]
  1384.  
  1385. object = object_name[:object_name.find(".",0)]
  1386. structure_whole.close();
  1387. process_x = object_region_center_x
  1388. while process_x >= 0:
  1389. process_z = object_region_center_z
  1390. if not indexstring(process_x-1) + "-" + str(indexstring(process_z)) in branchspace and process_x > 0:
  1391. line = "Branch(" + str(0 - object_split_size*2) + ",0,0,"+ object +"_" + indexstring(process_x-1) + "-" + str(indexstring(process_z)) + ",NORTH,100)"
  1392. object_region[str(indexstring(process_x)) + "_" + str(indexstring(process_z))].append(line)
  1393. branchspace.append(indexstring(process_x-1) + "-" + str(indexstring(process_z)))
  1394. while process_z > 0:
  1395. if not indexstring(process_x) + "-" + str(indexstring(process_z-1)) in branchspace:
  1396. line = "Branch(0,0," + str(0 - object_split_size*2) + ","+ object +"_" + indexstring(process_x) + "-" + str(indexstring(process_z-1)) + ",NORTH,100)"
  1397. object_region[str(indexstring(process_x)) + "_" + str(indexstring(process_z))].append(line)
  1398. branchspace.append(indexstring(process_x) + "-" + str(indexstring(process_z-1)))
  1399. process_z -= 1
  1400. process_z = object_region_center_z
  1401. while process_z < object_region_size_z:
  1402. if not indexstring(process_x) + "-" + str(indexstring(process_z+1)) in branchspace:
  1403. line = "Branch(0,0," + str(0 + object_split_size*2) + ","+ object +"_" + indexstring(process_x) + "-" + str(indexstring(process_z+1)) + ",NORTH,100)"
  1404. object_region[str(indexstring(process_x)) + "_" + str(indexstring(process_z))].append(line)
  1405. branchspace.append(indexstring(process_x) + "-" + str(indexstring(process_z+1)))
  1406. process_z += 1
  1407. process_x -=1
  1408. process_x = object_region_center_x
  1409. while process_x <= object_region_size_x:
  1410. process_z = object_region_center_z
  1411. if not indexstring(process_x+1) + "-" + str(indexstring(process_z)) in branchspace and process_x < object_region_size_x:
  1412. line = "Branch(" + str(0 + object_split_size*2) + ",0,0,"+ object +"_" + indexstring(process_x+1) + "-" + str(indexstring(process_z)) + ",NORTH,100)"
  1413. object_region[str(indexstring(process_x)) + "_" + str(indexstring(process_z))].append(line)
  1414. branchspace.append(indexstring(process_x+1) + "-" + str(indexstring(process_z)))
  1415. while process_z > 0:
  1416. if not indexstring(process_x) + "-" + str(indexstring(process_z-1)) in branchspace:
  1417. line = "Branch(0,0," + str(0 - object_split_size*2) + ","+ object +"_" + indexstring(process_x) + "-" + str(indexstring(process_z-1)) + ",NORTH,100)"
  1418. object_region[str(indexstring(process_x)) + "_" + str(indexstring(process_z))].append(line)
  1419. branchspace.append(indexstring(process_x) + "-" + str(indexstring(process_z-1)))
  1420. process_z -= 1
  1421. process_z = object_region_center_z
  1422. while process_z < object_region_size_z:
  1423. if not indexstring(process_x) + "-" + str(indexstring(process_z+1)) in branchspace:
  1424. line = "Branch(0,0," + str(0 + object_split_size*2) + ","+ object +"_" + indexstring(process_x) + "-" + str(indexstring(process_z+1)) + ",NORTH,100)"
  1425. object_region[str(indexstring(process_x)) + "_" + str(indexstring(process_z))].append(line)
  1426. branchspace.append(indexstring(process_x) + "-" + str(indexstring(process_z+1)))
  1427. process_z += 1
  1428. process_x +=1
  1429. count_x = 0
  1430. count_z = 0
  1431.  
  1432. debug_msg.append("Creating Files")
  1433. if debug == "true":
  1434. for line in debug_msg:
  1435. print "[DEBUG] " + line
  1436. del debug_msg[:]
  1437.  
  1438. count_z = 0
  1439. while count_z <= object_region_size_z:
  1440. count_x = 0
  1441. while count_x <= object_region_size_x:
  1442. if not os.path.exists("./Results/"+ object +"/"):
  1443. try:
  1444. os.mkdir("./Results/"+ object +"/")
  1445. except:
  1446. error = "true"
  1447. print "[--!Error!--] I could not Create a Neccessary Folder."
  1448. new_file = open("./Results/"+ object +"/" + object + "_" + indexstring(count_x) + "-" + str(indexstring(count_z)) + ".bo3" , 'wb')
  1449. debug_msg.append("File:" + object + "_" + indexstring(count_x) + "-" + str(indexstring(count_z)) + ".bo3")
  1450. for line in object_region[str(indexstring(count_x)) + "_" + str(indexstring(count_z))]:
  1451. new_file.write(line+"\n");
  1452. new_file.close();
  1453. count_x +=1
  1454. count_z +=1
  1455. new_file = open("./Results/" + object + ".bo3" , 'wb')
  1456. structure_main.append("\nBranch(0,0,0,"+ object +"_" + indexstring(object_region_center_x) + "-" + str(indexstring(object_region_center_z)) + ",NORTH,100)")
  1457. for line in structure_main:
  1458. new_file.write(line);
  1459. new_file.close();
  1460. print "[INFO] "+ object_name + " was split into: " + str((object_region_size_x+1)*(object_region_size_z+1)) + " parts."
  1461.  
  1462. else:
  1463. if object_will_split == "True":
  1464. print "[INFO] Object: " + object_name + " is so Large it Should be Split"
  1465. print '[WARN] Object Splitting is Disabled, your Object might cause problems or wont spawn at all.'
  1466. if object_name not in debug_faulty:
  1467. debug_faulty.append(object_name + "(To Large)")
  1468.  
  1469. if debug == "true":
  1470. for line in debug_msg:
  1471. print "[DEBUG] " + line
  1472. del debug_msg[:]
  1473. raw_input()
  1474. ########################
  1475. #### - Draw Image - ####
  1476. ########################
  1477. if Object_Preview[Use_Settings] == "true":
  1478. print "[INFO] Generating Image"
  1479. Object_Size_X = 1 + (Object_DimX1 - Object_DimX0)
  1480. Object_Size_Y = 1 + (Object_DimY1 - Object_DimY0)
  1481. Object_Size_Z = 1 + (Object_DimZ1 - Object_DimZ0)
  1482.  
  1483. pic_size_x = (Object_Size_X * 14) + (Object_Size_Z * 14) + 32
  1484. pic_size_y = (Object_Size_Y * 16) + (Object_Size_X * 8) + (Object_Size_Z * 8) + 32
  1485. pic_center_x = (pic_size_x / 2) - (Object_DimX0 * 14) + (Object_DimZ0 * 14)
  1486. pic_center_y = (pic_size_y - 16) + (Object_DimY0 * 16) + (Object_DimX0 * 7) + (Object_DimZ0 * 7) - 16
  1487.  
  1488. debug_msg.append("Object Size: " + str(Object_Size_X) + "," + str(Object_Size_Y) + "," + str(Object_Size_Z) +"")
  1489. background = Image.new('RGBA', (pic_size_x, pic_size_y), (0, 0, 0, 0))
  1490. x = Object_DimX0
  1491. y = Object_DimY0
  1492. z = Object_DimZ0
  1493. air = 0
  1494. render_amt = 0
  1495. percent = 0
  1496. print '[INFO] Progres: ' + str(Obj_Block_amt) +'Blocks'
  1497. sys.stdout.write('[')
  1498. sys.stdout.flush()
  1499. #mask = Image.open('./Images/STONE.png', 'r')
  1500. while y <= Object_DimY1:
  1501. z = Object_DimZ0
  1502. while z <= Object_DimZ1:
  1503. x = Object_DimX0
  1504. while x <= Object_DimX1:
  1505. #print str(render_amt) + "/" + str(Obj_Block_amt) + "=" + str(render_amt / Obj_Block_amt)
  1506. if int((render_amt * 10) / (Obj_Block_amt + 1)) > percent:
  1507. for i in (percent,int((render_amt * 10) / (Obj_Block_amt + 1))):
  1508. sys.stdout.write('|')
  1509. percent = int((render_amt * 10) / (Obj_Block_amt + 1))
  1510. sys.stdout.flush()
  1511. coords = str(x) + "," + str(y) + "," + str(z)
  1512. blockfound = "false"
  1513. try:
  1514. if Object_Blocks[coords] != "":
  1515. blockfound = "true"
  1516. except:
  1517. air += 1
  1518. if blockfound == "true":
  1519.  
  1520. try:
  1521. Object_Blocks[coords] = str(BulkeEdit_Materials[str(Object_Blocks[coords])])
  1522. except:
  1523. Object_Blocks[coords] = str(Object_Blocks[coords])
  1524.  
  1525. try:
  1526. Object_Blocks_Base = Object_Blocks[coords]
  1527. block = Image.open("./Images/" + Object_Blocks_Base.replace(":", "-") + ".png", 'r').convert('RGBA')
  1528. except:
  1529. try:
  1530. Object_Blocks_Base = Object_Blocks[coords]
  1531. block = Image.open("./Images/" + Object_Blocks_Base[:Object_Blocks_Base.find(":",0)] + ".png", 'r').convert('RGBA')
  1532. except:
  1533. try:
  1534.  
  1535. Object_Blocks_Base = Object_Blocks[coords]
  1536. Object_Blocks_Base = Object_Blocks_Base[Object_Blocks_Base.find(":",1)+1:]
  1537. block = Image.open("./Images/" + Object_Blocks_Base.replace(":", "-") + ".png", 'r').convert('RGBA')
  1538. except:
  1539. try:
  1540. Object_Blocks_Base = Object_Blocks[coords]
  1541. Object_Blocks_Base = Object_Blocks_Base[Object_Blocks_Base.find(":",1)+1:]
  1542. block = Image.open("./Images/" + Object_Blocks_Base[:Object_Blocks_Base.find(":",0)] + ".png", 'r').convert('RGBA')
  1543. except:
  1544. if str(Object_Blocks_Base) not in Missing_Image_List:
  1545. Missing_Image_List.append(str(Object_Blocks_Base))
  1546. block = Image.open('./Images/MISSING.png', 'r').convert('RGBA')
  1547.  
  1548. offset = (pic_center_x - (x * 14) + (z * 14))-16, (pic_center_y - (y * 16) + (x * 7)+ (z * 7))-16
  1549. background.paste(block, offset, block)
  1550. render_amt += 1
  1551. x += 1
  1552. z+= 1
  1553. y+= 1
  1554. print ']'
  1555. background.save('./Results/Preview/' + object_name + '.png')
  1556. Object_Blocks.clear()
  1557.  
  1558. print "[INFO] Done"
  1559. print "[INFO] Total [" + str(Processed_Objects) + "] Objects Processed."
  1560. print "[INFO] Total [" + str(Processed_Remove) + "] Blocks Removed."
  1561. print "[INFO] Total [" + str(Processed_Checks) + "] BlockChecks created."
  1562. print "[INFO] Total [" + str(Processed_Branches) + "] Branches created."
  1563. if len(debug_faulty) > 0:
  1564. counter = 0
  1565. print "[INFO] Faulty Objects [" + str(len(debug_faulty)) + "] These Objects had some kind of Error"
  1566. sys.stdout.write("[LIST] ")
  1567. for item in debug_faulty:
  1568. if counter > 0:
  1569. sys.stdout.write(', ')
  1570. sys.stdout.write(item)
  1571. counter += 1
  1572. sys.stdout.write('\n')
  1573. if len(Missing_ID_List) > 0:
  1574. counter = 0
  1575. print "[INFO] There were some BlockIDs that I did not understood. You should add them to the Material List:"
  1576. sys.stdout.write("[LIST] ")
  1577. for item in Missing_ID_List:
  1578. if counter > 0:
  1579. sys.stdout.write(', ')
  1580. sys.stdout.write(item)
  1581. counter += 1
  1582. sys.stdout.write('\n')
  1583. if len(Missing_Image_List) > 0:
  1584. counter = 0
  1585. print "[INFO] I didnt have Images for these Blocks:"
  1586. sys.stdout.write("[LIST] ")
  1587. for item in Missing_Image_List:
  1588. if counter > 0:
  1589. sys.stdout.write(', ')
  1590. sys.stdout.write(item)
  1591. counter += 1
  1592. sys.stdout.write('\n')
  1593. if Config_Version != "1.05":
  1594. print ""
  1595. print ""
  1596. print "[INFO] Your Configuration is Out of Date. I will regenerate it if you Remove or Rename it."
  1597. print "[INFO] You can also update your Configuration manually."
  1598. print "[INFO] Check the WikiPage on the OTG wiki for Changes."
  1599. raw_input()
  1600. if debug == "true":
  1601. for line in debug_msg:
  1602. print "[DEBUG] " + line
  1603. del debug_msg[:]
  1604. raw_input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement