Advertisement
Rezzing

SethBling's CreateShops MCEdit Filter for Minecraft 1.8

Sep 17th, 2014
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. # Feel free to modify and use this filter however you wish. If you do,
  2. # please give credit to SethBling.
  3. # http://youtube.com/SethBling
  4. #
  5. # Fixed for MC 1.8 by Rezzing, September 6, 2014
  6. #
  7. # PLEASE READ: The unusable trade won't prevent new trades anymore but I
  8. # solved it by adding a very high career level. So only use it if you like
  9. # the fancy stop sign. This traders won't walk away anymore. Their speed
  10. # is set to zero by "movement["Base"] = TAG_Double(0)". The default value
  11. # would be 0.5 or something. You can rename them at ["CustomName"].
  12. # And big thanks to SethBling for this awesome MCEdit filter :)
  13.  
  14. from pymclevel import TAG_Compound
  15. from pymclevel import TAG_Int
  16. from pymclevel import TAG_Short
  17. from pymclevel import TAG_Byte
  18. from pymclevel import TAG_String
  19. from pymclevel import TAG_Float
  20. from pymclevel import TAG_Double
  21. from pymclevel import TAG_List
  22.  
  23. Professions = {
  24. "Farmer (brown)": 0,
  25. "Librarian (white)": 1,
  26. "Priest (purple)": 2,
  27. "Blacksmith (black apron)": 3,
  28. "Butcher (white apron)": 4,
  29. "Villager (green)": 5,
  30. }
  31.  
  32. ProfessionKeys = ()
  33. for key in Professions.keys():
  34. ProfessionKeys = ProfessionKeys + (key,)
  35.  
  36.  
  37. inputs = (
  38. ("Profession", ProfessionKeys),
  39. ("Add Unusable Trade", False),
  40. ("Invincible Villagers", False),
  41. ("Unlimited Trades", True),
  42. )
  43.  
  44. displayName = "Create Shops"
  45.  
  46.  
  47. def perform(level, box, options):
  48. emptyTrade = options["Add Unusable Trade"]
  49. invincible = options["Invincible Villagers"]
  50. unlimited = options["Unlimited Trades"]
  51.  
  52. for x in range(box.minx, box.maxx):
  53. for y in range(box.miny, box.maxy):
  54. for z in range(box.minz, box.maxz):
  55. if level.blockAt(x, y, z) == 54:
  56. createShop(level, x, y, z, emptyTrade, invincible, Professions[options["Profession"]], unlimited)
  57.  
  58. def createShop(level, x, y, z, emptyTrade, invincible, profession, unlimited):
  59. chest = level.tileEntityAt(x, y, z)
  60. if chest == None:
  61. return
  62.  
  63. priceList = {}
  64. priceListB = {}
  65. saleList = {}
  66.  
  67. for item in chest["Items"]:
  68. slot = item["Slot"].value
  69. if slot >= 0 and slot <= 8:
  70. priceList[slot] = item
  71. elif slot >= 9 and slot <= 17:
  72. priceListB[slot-9] = item
  73. elif slot >= 18 and slot <= 26:
  74. saleList[slot-18] = item
  75.  
  76. villager = TAG_Compound()
  77. villager["CustomNameVisible"] = TAG_Byte(0)
  78. villager["Invulnerable"] = TAG_Byte(1)
  79. villager["OnGround"] = TAG_Byte(1)
  80. villager["Air"] = TAG_Short(300)
  81. villager["AttackTime"] = TAG_Short(0)
  82. villager["DeathTime"] = TAG_Short(0)
  83. villager["Fire"] = TAG_Short(-1)
  84. villager["Health"] = TAG_Short(20)
  85. villager["HurtTime"] = TAG_Short(0)
  86. villager["Age"] = TAG_Int(0)
  87. villager["Career"] = TAG_Int(1)
  88. villager["CareerLevel"] = TAG_Int(1000)
  89. villager["Profession"] = TAG_Int(profession)
  90. villager["Riches"] = TAG_Int(200)
  91. villager["FallDistance"] = TAG_Float(0)
  92. villager["CustomName"] = TAG_String("Trader")
  93. villager["id"] = TAG_String("Villager")
  94. villager["Motion"] = TAG_List()
  95. villager["Motion"].append(TAG_Double(0))
  96. villager["Motion"].append(TAG_Double(0))
  97. villager["Motion"].append(TAG_Double(0))
  98. villager["Pos"] = TAG_List()
  99. villager["Pos"].append(TAG_Double(x + 0.5))
  100. villager["Pos"].append(TAG_Double(y))
  101. villager["Pos"].append(TAG_Double(z + 0.5))
  102. villager["Rotation"] = TAG_List()
  103. villager["Rotation"].append(TAG_Float(0))
  104. villager["Rotation"].append(TAG_Float(0))
  105.  
  106. villager["Offers"] = TAG_Compound()
  107. villager["Offers"]["Recipes"] = TAG_List()
  108. for i in range(9):
  109. if (i in priceList or i in priceListB) and i in saleList:
  110. offer = TAG_Compound()
  111. if unlimited:
  112. offer["rewardExp"] = TAG_Byte(0)
  113. offer["maxUses"] = TAG_Int(1000)
  114. offer["uses"] = TAG_Int(-2000000000)
  115. else:
  116. offer["uses"] = TAG_Int(0)
  117.  
  118. if i in priceList:
  119. offer["buy"] = priceList[i]
  120. if i in priceListB:
  121. if i in priceList:
  122. offer["buyB"] = priceListB[i]
  123. else:
  124. offer["buy"] = priceListB[i]
  125.  
  126. offer["sell"] = saleList[i]
  127. villager["Offers"]["Recipes"].append(offer)
  128.  
  129. villager["Attributes"] = TAG_List()
  130. movement = TAG_Compound()
  131. movement["Base"] = TAG_Double(0)
  132. movement["Name"] = TAG_String("generic.movementSpeed")
  133. villager["Attributes"].append(movement)
  134.  
  135. if emptyTrade:
  136. offer = TAG_Compound()
  137. offer["buy"] = TAG_Compound()
  138. offer["buy"]["Count"] = TAG_Byte(1)
  139. offer["buy"]["Damage"] = TAG_Short(0)
  140. offer["buy"]["id"] = TAG_Short(166)
  141. offer["sell"] = TAG_Compound()
  142. offer["sell"]["Count"] = TAG_Byte(1)
  143. offer["sell"]["Damage"] = TAG_Short(0)
  144. offer["sell"]["id"] = TAG_Short(166)
  145. villager["Offers"]["Recipes"].append(offer)
  146.  
  147. if invincible:
  148. if "ActiveEffects" not in villager:
  149. villager["ActiveEffects"] = TAG_List()
  150.  
  151. resist = TAG_Compound()
  152. resist["Amplifier"] = TAG_Byte(4)
  153. resist["Id"] = TAG_Byte(11)
  154. resist["Duration"] = TAG_Int(2000000000)
  155. villager["ActiveEffects"].append(resist)
  156.  
  157. level.setBlockAt(x, y, z, 0)
  158.  
  159. chunk = level.getChunk(x / 16, z / 16)
  160. chunk.Entities.append(villager)
  161. chunk.TileEntities.remove(chest)
  162. chunk.dirty = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement