TastesLikeBleach

jsongenerator.py

Feb 7th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.80 KB | None | 0 0
  1. __author__ = 'TastesLikeBleach'
  2.  
  3. class NVA():
  4.     array = None
  5.     def __init__(self, array):
  6.         self.array = array
  7.  
  8.     def hasElement(self, value):
  9.         i = 0
  10.         while i < len(self.array):
  11.             if self.array[i] == value:
  12.                 return True
  13.             i += 1
  14.         return False
  15.  
  16.     def append(self, o):
  17.         self.array.append(o)
  18.  
  19.     def remove(self, o):
  20.         self.array.remove(o)
  21.  
  22. def genoreblockstate(uN, domain,  hi = False):
  23.     if hi:
  24.         uN = input("What is the ore's unlocalized name?: ")
  25.     file = open(uN + '.json', 'w')
  26.     file.write('{\n    "variants": {\n')
  27.     file.write('        "type=overworld": {"model": "' + domain + ':' + uN + '_overworld"},\n')
  28.     file.write('        "type=nether": {"model": "' + domain + ':' + uN + '_nether"},\n')
  29.     file.write('        "type=end": {"model": "' + domain + ':' + uN + '_end"},\n')
  30.     file.close()
  31.  
  32.  
  33. def genoreblockmodel(uN, d, hi=False):
  34.     if hi:
  35.         uN = input('enter the unlocalized name: ')
  36.     file = open(uN + '_overworld.json', 'w')
  37.     file.write('{\n    "parent": "block/cube_all",\n    "textures": {\n    "all": "'+d+':blocks/'+uN+'_overworld"\n')
  38.     file.write('    }\n}')
  39.     file.close()
  40.     file = open(uN + '_nether.json', 'w')
  41.     file.write('{\n    "parent": "block/cube_all",\n    "textures": {\n    "all": "'+d+':blocks/'+uN+'_nether"\n')
  42.     file.write('    }\n}')
  43.     file.close()
  44.     file = open(uN + '_end.json', 'w')
  45.     file.write('{\n    "parent": "block/cube_all",\n    "textures": {\n    "all": "'+d+':blocks/'+uN+'_end"\n')
  46.     file.write('    }\n}')
  47.     file.close()
  48.  
  49.  
  50. def genoreitemmodel(uN, d, hi=False):
  51.     if hi:
  52.         uN = input('enter the (ORENAME): ')
  53.     file = open(uN + '_overworld.json', 'w')
  54.     file.write('{\n    "parent": "' + d + ':block/' + uN + '_overworld"\n}')
  55.     file.close()
  56.     file = open(uN + '_nether.json', 'w')
  57.     file.write('{\n    "parent": "' + d + ':block/' + uN + '_nether"\n}')
  58.     file.close()
  59.     file = open(uN + '_end.json', 'w')
  60.     file.write('{\n    "parent": "' + d + ':block/' + uN + '_end"\n}')
  61.     file.close()
  62.  
  63.  
  64. def genarmoritemmodel(uN, d, hi=False):
  65.     if hi:
  66.         uN = input("please enter the (METALNAME): ")
  67.     file = open(uN + 'helmet.json', 'w')
  68.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "'+d+':items/'+uN+'helmet"')
  69.     file.write('\n    }\n}')
  70.     file.close()
  71.     file = open(uN + 'chestplate.json', 'w')
  72.     file.write(
  73.         '{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "' + d + ':items/' + uN + 'chestpl')
  74.     file.write('ate"\n    }\n}')
  75.     file.close()
  76.     file = open(uN + 'leggings.json', 'w')
  77.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "'+d+':items/'+uN+'leggings"')
  78.     file.write('\n    }\n}')
  79.     file.close()
  80.     file = open(uN + 'boots.json', 'w')
  81.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "'+d+':items/'+uN+'boots"')
  82.     file.write('\n    }\n}')
  83.     file.close()
  84.  
  85.  
  86. def gentoolmodel(uN, d, hi=False):
  87.     if hi:
  88.         uN = input("please enter the (METALNAME): ")
  89.     file = open(uN + 'pickaxe.json', 'w')
  90.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "'+d+':items/' + uN)
  91.     file.write('pickaxe"\n' + '    }\n}')
  92.     file.close()
  93.     file = open(uN + 'axe.json', 'w')
  94.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "'+d+':items/' + uN + 'axe"')
  95.     file.write('\n    }\n}')
  96.     file.close()
  97.     file = open(uN + 'hoe.json', 'w')
  98.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "'+d+':items/' + uN + 'hoe"')
  99.     file.write('\n    }\n}')
  100.     file.close()
  101.     file = open(uN + 'shovel.json', 'w')
  102.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "'+d+':items/')
  103.     file.write(uN + 'shovel"' + '\n    }\n}')
  104.     file = open(uN + 'sword.json', 'w')
  105.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "tcm:items/' + uN + 'sword"')
  106.     file.write('\n    }\n}')
  107.     file.close()
  108.  
  109.  
  110. def genTALang(uN, n,  hi = False):
  111.     if hi:
  112.         uN = input('please enter the (METALNAME) for the tools and armor: ')
  113.         n = input('Please enter (METALDISPLAYNAME): ')
  114.     file = open('langfragment.txt', 'w')
  115.     file.write('item.' + uN + 'pickaxe.name=' + n + ' Pickaxe\n')
  116.     file.write('item.' + uN + 'sword.name=' + n + ' Sword\n')
  117.     file.write('item.' + uN + 'hoe.name=' + n + ' Hoe\n')
  118.     file.write('item.' + uN + 'axe.name=' + n + ' Axe\n')
  119.     file.write('item.' + uN + 'shovel.name=' + n + ' Shovel\n')
  120.     file.write('item.' + uN + 'helmet.name=' + n + ' Helmet\n')
  121.     file.write('item.' + uN + 'chestplate.name=' + n + ' Chestplate\n')
  122.     file.write('item.' + uN + 'leggings.name=' + n + ' Leggings\n')
  123.     file.write('item.' + uN + 'boots.name=' + n + ' Boots\n')
  124.     file.close()
  125.  
  126. def MakeItemModel(uN, d):
  127.     file = open(uN + '.json', 'w')
  128.     file.write('{\n    "parent": "item/generated",\n    "textures": {\n        "layer0": "' + d + ':items/' + uN + '"')
  129.     file.write('\n    }\n}')
  130.     file.close()
  131.  
  132.  
  133. def MakeBlockState(uN, d):
  134.     file = open(uN + '.json', 'w')
  135.     file.write('{ "variants": { "normal": { "model": "' + domain + ':' + uN + '" } } }')
  136.     file.close()
  137.  
  138.  
  139. def MakeBlockModel(uN, d):
  140.     file = open(uN + '.json', 'w')
  141.     file.write('{ "parent": "block/cube_all", "textures": { "all": "' + d + ':blocks/' + uN + '" } }')
  142.     file.close()
  143.  
  144. def MakeItemBlockModel(uN, d):
  145.     file = open(uN + '.json', 'w')
  146.     file.write('{ "parent": "' + d + ':block/' + uN + '" }')
  147.     file.close()
  148.  
  149.  
  150. closed = False
  151. domain = input("please enter your mod's (DOMAIN) / id: ")
  152. while not closed:
  153.     gen = input('What do you want to generate?: ')
  154.     if gen == 'close':
  155.         closed = True
  156.     if gen == 'tim':
  157.         gentoolmodel('', domain, True)
  158.     if gen == 'aim':
  159.         genarmoritemmodel('', domain, True)
  160.     if gen == 'obs':
  161.         genoreblockstate('', domain, True)
  162.     if gen == 'obm':
  163.         genoreblockmodel('', domain, True)
  164.     if gen == 'oim':
  165.         genoreitemmodel('', domain, True)
  166.     if gen == 'tal':
  167.         genTALang('', '', True)
  168.     if gen == 'im':
  169.         MakeItemModel(input("Enter the (UNLOCALIZEDNAME) please: "), domain)
  170.     if gen == 'bs':
  171.         MakeBlockState(input("Enter the (UNLOCALIZEDNAME) please: "), domain)
  172.     if gen == 'bm':
  173.         MakeBlockModel(input("Enter the (UNLOCALIZEDNAME) please: "), domain)
  174.     if gen == 'ibm':
  175.         MakeItemBlockModel(input("Enter the (UNLOCALIZEDNAME) please: "), domain)
  176.  
  177. # PLEASE READ THIS FOR A HOW TO GUIDE!
  178. #
  179. # The interface for this is text-based and is only intuitive if you've used python for file making before.
  180. # In order to enter input when requested type respective input and hit ENTER.
  181. #
  182. # The file name will always be (UNLOCALIZEDNAME).json and if previously generated files with the same name
  183. # are not moved they will be overwritten.
  184. #
  185. #  Block Models: enter 'bm' (excluding quotes)
  186. # Any generated model should something look like this after being but through a json verifier:
  187. #
  188. # {
  189. #   "parent": "block/cube_all",
  190. #       "textures": {
  191. #           "all": "(DOMAIN):blocks/(UNLOCALIZEDNAME)"
  192. #       }
  193. # }
  194. #
  195. # Basic Block States: enter 'bs'
  196. #
  197. # {
  198. #   "variants": {
  199. #       "normal": {
  200. #           "model": "(DOMAIN):(UNLOCALIZEDNAME)"
  201. #       }
  202. #   }
  203. # }
  204. #
  205. #
  206. #
  207. # Basic ItemBlock Model: enter 'ibm'
  208. #
  209. # {
  210. #   "parent": "(DOMAIN):block/(UNLOCALIZEDNAME)"
  211. # }
  212. #
  213. #
  214. # Basic Item Model: enter 'im'
  215. #
  216. # {
  217. #   "parent": "item/generated",
  218. #   "textures": {
  219. #       "layer0": "(DOMAIN):items/(UNLOCALIZEDNAME)"
  220. #    }
  221. # }
  222. #
  223. # Generated .lang file fragments for tools and armor: enter 'tal', in file 'langfragment.txt'
  224. #
  225. # item.(METALNAME)pickaxe.name=(METALDISPLAYNAME) Pickaxe
  226. # item.(METALNAME)axe.name=(METALDISPLAYNAME) Axe
  227. # item.(METALNAME)sword.name=(METALDISPLAYNAME) Sword
  228. # item.(METALNAME)shovel.name=(METALDISPLAYNAME) Shovel
  229. # item.(METALNAME)hoe.name=(METALDISPLAYNAME) Hoe
  230. # item.(METALNAME)helmet.name=(METALDISPLAYNAME) Helmet
  231. # item.(METALNAME)chestplate.name=(METALDISPLAYNAME) Chestplate
  232. # item.(METALNAME)leggings.name=(METALDISPLAYNAME) Leggings
  233. # item.(METALNAME)boots.name=(METALDISPLAYNAME) Boots
  234. #
  235. #
  236. # Generated tool item models: 'tim'
  237. # should look something like this and will generate several files like this, '(METALNAME)(ARMORPIECENAME).json'
  238. # {
  239. #   "parent": "item/generated",
  240. #   "textures": {
  241. #       "layer0": "(DOMAIN):items/(METALNAME)(TOOLNAME)"
  242. #   }
  243. # }
  244. #
  245. # Generated armor item models: 'aim'
  246. # {
  247. #   "parent": "item/generated",
  248. #   "textures": {
  249. #       "layer0": "(DOMAIN):items/(METALNAME)(ARMORPIECENAME)"
  250. #   }
  251. # }
  252. #
Advertisement
Add Comment
Please, Sign In to add comment