Paste #62245: Custom Block Handler

Date: 2019/11/23 09:49:47 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


custom_blocks_handler_events:
  type: world
  events:
    on player places sponge:
      - if <player.item_in_hand.nbt[is_custom_block]||false>:
        - determine passively cancelled
        - define uuid <util.random.uuid>
        - wait 1t
        - spawn armor_stand[equipment=air|air|air|<item[<player.item_in_hand.scriptname>]>;gravity=false] <context.location.center.below[1.66]> save:as
        - modifyblock <context.location> spawner
        - adjust <context.location> spawner_type:<entity[dropped_item]>
        - note <context.location> as:customBlock_block_<[uuid]>
        - flag server customBlock_stand_<[uuid]>:<entry[as].spawned_entity>

    on player breaks spawner:
      - if <context.location.notable_name.starts_with[customBlock_block_]||false>:
        - define uuid <context.location.notable_name.after[_].after[_]>
        - determine passively <list[<item[<entity[<server.flag[customBlock_stand_<[uuid]>]>].equipment.helmet.scriptname>]>]>
        - wait 1t
        - remove <entity[<server.flag[customBlock_stand_<[uuid]>]>]>
        - note remove as:customBlock_block_<[uuid]>
        - flag server customBlock_stand_<[uuid]>:!