Guest User

Untitled

a guest
May 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. import copy
  2. import random
  3. import string
  4. import uuid
  5. import json
  6. import glob
  7. import os, sys
  8. import fnmatch
  9. import math
  10. import uuid
  11. import pymclevel.box
  12. from numpy import zeros, fromiter, append
  13. from copy import deepcopy
  14. from random import randrange
  15. from pymclevel import mclevel
  16. from pymclevel import MCSchematic
  17. from pymclevel import nbt
  18. from pymclevel.materials import alphaMaterials
  19. from pymclevel import TAG_Compound, TAG_Int, TAG_Int_Array, TAG_Short, TAG_Byte, TAG_String, TAG_Float, TAG_Double, TAG_List, TAG_Long
  20. from pymclevel import TileEntity, Entity
  21. import mcplatform
  22. import directories
  23.  
  24. displayName = "Create Entities"
  25.  
  26. inputs = (
  27. ("Entity: id", ("string", "width=200")),
  28. )
  29.  
  30. entity_dictionary = {
  31. "Creeper":{
  32. "id":TAG_String("minecraft:creeper"),
  33. "Attributes":{
  34. 0:{
  35. "Name":TAG_String("minecraft:speed"),
  36. "Base":TAG_Double(0.00)
  37. },
  38. 1:{
  39. "Name":TAG_String("minecraft:follow"),
  40. "Base":TAG_Double(16.00)
  41. },
  42. 2:{
  43. "Name":TAG_String("minecraft:health"),
  44. "Base":TAG_Double(20.00),
  45. },
  46. 3:{
  47. "Name":TAG_String("minecraft:health"),
  48. "Base":TAG_Double(20.00)
  49. },
  50. 4:{
  51. "Name":TAG_String("minecraft:horse"),
  52. "Base":TAG_Double(0.00)
  53. },
  54. 5:{
  55. "Name":TAG_String("minecraft:zombie"),
  56. "Base":TAG_Double(20.00)
  57. },
  58. 6:{
  59. "Name":TAG_String("minecraft:knockback"),
  60. "Base":TAG_Double(0.00)
  61. },
  62. 7:{
  63. "Name":TAG_String("minecraft:swimming"),
  64. "Base":TAG_Double(0.00)
  65. }
  66. },
  67. "Motion":TAG_List([TAG_Int(20), TAG_Int(20)]),
  68. "Armor":TAG_List([TAG_Compound(), TAG_Compound(), TAG_Compound(), TAG_Compound()]),
  69. "Arms":TAG_List([TAG_Compound(), TAG_Compound()]),
  70. "ItemDropChance":["Head", "Feet", "Legs", "Chest", "LeftArm", "RightArm"],
  71. "Health":TAG_Int(20),
  72. "Powered":TAG_Byte(0),
  73. "CustomName":TAG_String(""),
  74. "CustomNameIsVisible":TAG_Byte(0)
  75. }}
  76.  
  77. def getListTags():
  78. if isinstance(entity_json[tag], (TAG_List)):
  79. for tags in entity_json[tag]:
  80. if isinstance(entity_json[tag][tags], (TAG_Compound)):
  81. entity_json[tag].append(TAG_Compound())
  82.  
  83. entity[tag] = entity_json[tag]
  84.  
  85. def getBaseTags():
  86. #Gets Byte Tags, Short Tags, Int Tags, Long Tags, String Tags Handling acts like ints & floats
  87. if isinstance(entity_json[tag], (TAG_String, TAG_Long, TAG_Int, TAG_Byte, TAG_Short)):
  88. entity[tag] = entity_json[tag]
  89. return entity
  90.  
  91. def createEntityAt(level, ent_id, x, y, z):
  92. entity = TAG_Compound()
  93. entity["Pos"] = TAG_List([TAG_Double(x),TAG_Double(y),TAG_Double(z)])
  94.  
  95. for tag in entity_json:
  96. if isinstance(entity_json[tag], (TAG_List)):
  97. getListTags()
  98. getBaseTags()
  99.  
  100. return entity
  101.  
  102. def perform(level, box, options):
  103. mc = level.gamePlatform
  104. entity_json = entity_dictionary[options["Entity: id"]]
  105.  
  106. for x in xrange(box.minx, box.maxx):
  107. for y in xrange(box.miny, box.maxy):
  108. for z in xrange(box.minz, box.maxz):
  109.  
  110. chunk = level.getChunk(x / 16, z / 16)
  111. chunk.Entities.append(createEntity(level, options["Entity: id"], x+0.5, y, z+0.5))
Add Comment
Please, Sign In to add comment