Guest User

Untitled

a guest
Oct 18th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.18 KB | None | 0 0
  1. function addTab(name: string, skin: skin, players: players, uuid: string = "") :: string:
  2. set {_packet} to new play_server_player_info packet
  3. set "PlayerInfoAction" penum 0 of {_packet} to "ADD_PLAYER"
  4. set {_a::gamemode} to creative
  5. set {_a::gameprofile::name} to {_name}
  6. set {_a::gameprofile::skin} to {_skin}
  7. set {_a::latency} to 0
  8. set {_uuid} to ({_uuid} === "" ? new uuid : {_uuid})
  9. set {_a::gameprofile::uuid} to {_uuid}
  10. set "PlayerInfoData" array pjson 0 of {_packet} to json of listvar {_a::*}
  11. loop {_players::*}:
  12. send loop-value packet {_packet}
  13. return {_uuid}
  14. function skin(i: int = 0) :: skin:
  15. return skin with value "eyJ0aW1lc3RhbXAiOjE0OTkwMDg3MTU3MzQsInByb2ZpbGVJZCI6IjQzNTg3MjhkZGQ1NDQ5NDM4ZGYwZWRlMTkzODJmYmQ2IiwicHJvZmlsZU5hbWUiOiJ1bW1vYmVhciIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7Im1ldGFkYXRhIjp7Im1vZGVsIjoic2xpbSJ9LCJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FiYmYxZmY5YTdjMmIwMTRmMzI2YWQxZDg0ZDZmNzlkZThkYWYzNjk1NzIxOTg4MTNlZmI1Yzc2MDcxZTM2MCJ9fX0=" signature "YAzwJkE8Px8LPWmrNJBRH7QZbf2TlxuxfIzlJEiLM2pb19Hp6/osKO97Enxz1fdNFpFQ4nda/Q6IaOI5M0vj6zPjF1X+JEf5LVobYeuiLQsbP1i7EURegYH8fcQr4rZhWcSS3L3VzlXKxR3XqHEeWA0Cq/73k8NTlS4uh9syGTx44uqprZHKTH+Tj865mSkVF9J4E4AQx71m+jadBSAVVTmfAqTauHFTFLOw7oSoPHCa8WkhsgCqmWxxQvSKJAgfVsHGFd5W20fAYCGuce7381TpYLpKQlGELcEsLs1wQO16tSWGe77/lQzXhfmsCC7nKPFhgIT5fiRNQ8VFGIztS4UMe661DUIEMUYrYIT4qh/bZfmFyj1tVR054I6InhEth6rQ0h/wT6/8iPW8VWNR1K4jxW/wmvCq5ssoLyjHmwg8rMyOYf0vryli4fP1iMv3Gv3CTtCtZDriYsFMPhCLd8pxekWpitkysviEn6szJZKNAwyGbdcy/KECG10UqKdppudix0KJ+Df6i0TG2dF1jYwjbywGgIlf7Z2+4gZbWb7sReQsaUsYbbjIikDfjwOfRjTJVNezfRJ7FIfwFPU2KAH6I9nIwdascvelzJL4eFf3rZMWo397AljTa6wYIyxr0iDMZQLeZBGfodLbF2SXNxMlC04ifY1f+Y6jEUNymIs=="
  16. function newUUID(i: int = 0) :: string:
  17. return "%a random integer between 10000000 and 99999999%-%a random integer between 1000 and 9999%-%a random integer between 1000 and 9999%-%a random integer between 1000 and 9999%-%a random integer between 100000000000 and 999999999999%"
  18. on packet event play_server_named_entity_spawn:
  19. set {metadata} to "DataWatcherModifier" pinfo 0 of event-packet
  20. function spawnNPC(name: string, skin: skin, location: location, players: players, item: itemtype, uuid: string = ""):
  21. set {_npcspawn} to new play_server_named_entity_spawn packet
  22. set int pnum 0 of {_npcspawn} to a random integer from 5000 to 10000
  23. set "uuid" pinfo 0 of {_npcspawn} to ({_uuid} === "" ? addTab({_name}, {_skin}, {_players::*}) : addTab({_name}, {_skin}, {_players::*}, {_uuid}))
  24. set int pnum 1 of {_npcspawn} to x-loc of {_location} * 32
  25. set int pnum 2 of {_npcspawn} to y-loc of {_location} * 32
  26. set int pnum 3 of {_npcspawn} to z-loc of {_location} * 32
  27. set byte pnum 0 of {_npcspawn} to 0
  28. set byte pnum 1 of {_npcspawn} to 0
  29. set "DataWatcherModifier" pinfo 0 of {_npcspawn} to {metadata}
  30. set short pnum 0 of {_npcspawn} to 1
  31. loop {_players::*}:
  32. send loop-value packet {_npcspawn}
  33. function typeId(entity: string) :: object: #I have to use string here because the entitytype type is... weird, and not all of them match up with wiki.vg
  34. switch {_entity}: #everything is here except things marked as blue on wiki.vg
  35. case "Item":
  36. return 2
  37. case "AreaEffectCloud":
  38. return 3
  39. case "ElderGuardian":
  40. return 4
  41. case "WitherSkeleton":
  42. return 5
  43. case "Stray":
  44. return 6
  45. case "ThrownEgg":
  46. return 62
  47. case "LeashKnot":
  48. return 77
  49. case "Arrow":
  50. return 60
  51. case "Snowball":
  52. return 61
  53. case "Fireball":
  54. return 63
  55. case "SmallFireball":
  56. return 64
  57. case "ThrownEnderpearl":
  58. return 14
  59. case "EyeOfEnderSignal":
  60. return 72
  61. case "ThrownPotion":
  62. return 73
  63. case "ThrownExpBottle":
  64. return 75
  65. case "ItemFrame":
  66. return 71
  67. case "WitherSkull":
  68. return 66
  69. case "PrimedTnt":
  70. return 50
  71. case "FallingSand":
  72. return 70
  73. case "FireworksRocketEntity":
  74. return 76
  75. case "Husk":
  76. return 23
  77. case "SpectralArrow":
  78. return 91
  79. case "ShulkerBullet":
  80. return 67
  81. case "DragonFireball":
  82. return 93
  83. case "ZombieVillager":
  84. return 27
  85. case "SkeletonHorse":
  86. return 28
  87. case "ZombieHorse":
  88. return 29
  89. case "ArmorStand":
  90. return 30 #careful, this will crash your game if you don't send it right
  91. case "Donkey":
  92. return 31
  93. case "Mule":
  94. return 32
  95. case "EvocationFangs":
  96. return 79
  97. case "EvocationIllager":
  98. return 34
  99. case "Vex":
  100. return 35
  101. case "VindicationIllager":
  102. return 36
  103. case "IllusionIllager":
  104. return 37
  105. case "MinecartCommandBlock":
  106. return 10
  107. case "Boat":
  108. return 1
  109. case "MinecartRideable":
  110. return 10
  111. case "MinecartChest":
  112. return 10
  113. case "MinecartTNT":
  114. return 10
  115. case "MinecartHopper":
  116. return 10
  117. case "MinecartSpawner":
  118. return 10
  119. case "Creeper":
  120. return 50
  121. case "Skeleton":
  122. return 51
  123. case "Spider":
  124. return 52
  125. case "Giant":
  126. return 53
  127. case "Zombie":
  128. return 54
  129. case "Slime":
  130. return 55
  131. case "Ghast":
  132. return 56
  133. case "PigZombie":
  134. return 57
  135. case "Enderman":
  136. return 58
  137. case "CaveSpider":
  138. return 59
  139. case "Silverfish":
  140. return 60
  141. case "Blaze":
  142. return 61
  143. case "LavaSlime":
  144. return 62
  145. case "EnderDragon":
  146. return 63
  147. case "WitherBoss":
  148. return 64
  149. case "Bat":
  150. return 65
  151. case "Witch":
  152. return 66
  153. case "Endermite":
  154. return 67
  155. case "Guardian":
  156. return 68
  157. case "Shulker":
  158. return 69
  159. case "Pig":
  160. return 90
  161. case "Sheep":
  162. return 91
  163. case "Cow":
  164. return 92
  165. case "Chicken":
  166. return 93
  167. case "Squid":
  168. return 94
  169. case "Wolf":
  170. return 95
  171. case "MushroomCow":
  172. return 96
  173. case "SnowMan":
  174. return 97
  175. case "Ozelot":
  176. return 98
  177. case "VillagerGolem":
  178. return 99
  179. case "Horse":
  180. return 100
  181. case "EntityHorse":
  182. return 100
  183. case "Rabbit":
  184. return 101
  185. case "PolarBear":
  186. return 102
  187. case "Llama":
  188. return 103
  189. case "LlamaSpit":
  190. return 68
  191. case "Parrot":
  192. return 105
  193. case "Villager":
  194. return 120
  195. case "EnderCrystal":
  196. return 51
  197. return false
  198.  
  199. function spawnClientMob(entity: string, location: location, viewers: players, entityid: int = 69420) :: object:
  200. if typeId({_entity}) is false: #if the given entity isn't in the typeId() function, stop the function by returning false so that the calling code can detect there was an issue if it chooses to
  201. return false
  202. set {_packet} to new play_server_spawn_entity_living packet
  203. if {_entityid} is 69420: #if a custom id wasn't specified
  204. set int pnum 0 of {_packet} to a random integer from 50000 to 100000 #set the entity id to a number that won't realitically ever cause problems
  205. else: #if a custom id WAS specified
  206. set int pnum 0 of {_packet} to {_entityid} #set the entity id to the given id
  207. set int pnum 1 of {_packet} to "%typeId({_entity})%" parsed as a number #get the type id used to identify the given mob in packets, has to be parsed as a number because the function returns object
  208. #set the coordinates
  209. set int pnum 2 of {_packet} to {_location}'s x-loc * 32
  210. set int pnum 3 of {_packet} to {_location}'s y-loc * 32
  211. set int pnum 4 of {_packet} to {_location}'s z-loc * 32
  212. #set the pitch/yaw
  213. loop 5 and 6:
  214. set int pnum loop-value of {_packet} to 0
  215. #set the velocity
  216. loop 7, 8 and 9 :
  217. set int pnum loop-value of {_packet} to 0
  218. #send all the players that should see the mob the packet
  219. loop {_viewers::*}:
  220. send loop-value packet {_packet}
  221. return "%int pnum 0 of {_packet}%" parsed as an int #if we've gotten this far, return the entity id in case the calling code needs to use it to manipulate the spawned mob
  222.  
  223. function clientBlock(location: location, type: item, viewers: players):
  224. set {_packet} to new play_server_block_change packet
  225. set location pinfo 0 of {_packet} to {_location}
  226. set "BlockData" pinfo 0 of {_packet} to {_type} # as seen on packetwrapper, this uses the blockdata pinfo
  227. loop {_viewers::*}: #show peeps the new block
  228. send loop-value packet {_packet}
  229. function returnItem(i: item) :: item:
  230. return {_i}
Add Comment
Please, Sign In to add comment