Advertisement
akon1248

Item Display

May 18th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. command /displayitem [<text>]:
  2. permission: skript.admin
  3. trigger:
  4. if target block is glass:
  5. if player's tool is not air:
  6. set {_name} to colored arg
  7. if {_name} is not set:
  8. set {_name} to check [name of player's tool is set] ? name of player's tool : "%type of player's tool%"
  9. spawn an armor stand at location 0.5 meter below location of target block
  10. set {_base} to last spawned armor stand
  11. add "{Invulnerable:1b,NoGravity:1b,Invisible:1b,NoBasePlate:1b,ShowArms:1b,Small:1b,Marker:1b}" to nbt of {_base}
  12. drop 1 of player's tool at {_base} without velocity
  13. set {_item} to dropped item
  14. add "{PickupDelay:32767s,Age:-32768,Invulnerable:1b}" to nbt of {_item}
  15. make {_item} ride {_base}
  16. spawn an armor stand at location 0.5 meter above target block
  17. set {_hologram} to last spawned armor stand
  18. add "{CustomName:""%{_name}%"",Invulnerable:1b,NoGravity:1b,Invisible:1b,NoBasePlate:1b,ShowArms:1b,Small:1b,Marker:1b}" to nbt of {_hologram}
  19. set {_uuid} to uuid of {_base}
  20. set {itemdisplay.location::%{_uuid}%} to target block
  21. set {itemdisplay.item::%{_uuid}%} to UUID of {_item}
  22. set {itemdisplay.hologram::%{_uuid}%} to UUID of {_hologram}
  23. send "&6アイテムを飾りました"
  24. else:
  25. send "&c手にアイテムを持ってください"
  26. else:
  27. send "&cガラスブロックに向けてコマンドを実行してください"
  28. every tick:
  29. loop {itemdisplay.location::*}:
  30. set {_base} to entity from uuid loop-index
  31. set {_item} to entity from uuid {itemdisplay.item::%loop-index%}
  32. set {_hologram} to entity from uuid {itemdisplay.hologram::%loop-index%}
  33. make {_item} ride {_base}
  34. if block at loop-value is not glass:
  35. kill {_base}
  36. kill {_item}
  37. kill {_hologram}
  38. delete {itemdisplay.location::%loop-index%}
  39. delete {itemdisplay.item::%loop-index%}
  40. delete {itemdisplay.hologram::%loop-index%}
  41. else:
  42. loop all players:
  43. if target block of loop-player is block at loop-value-1:
  44. showCustomNameToPlayer({_hologram}, loop-player)
  45. else:
  46. hideCustomNameFromPlayer({_hologram}, loop-player)
  47.  
  48. function hideCustomNameFromPlayer(e: entity, p: player):
  49. set {_packet} to new play_server_entity_metadata packet
  50. set int pnum 0 of {_packet} to id of {_e}
  51. set {_json::3} to false
  52. set "WatchableCollection" pjson 0 of {_packet} to json from listvar {_json::*}
  53. send {_p} packet {_packet}
  54.  
  55. function showCustomNameToPlayer(e: entity, p: player):
  56. set {_packet} to new play_server_entity_metadata packet
  57. set int pnum 0 of {_packet} to id of {_e}
  58. set {_json::3} to true
  59. set "WatchableCollection" pjson 0 of {_packet} to json from listvar {_json::*}
  60. send {_p} packet {_packet}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement