Paste #79188: Untitled Paste

Date: 2020/12/26 04:25:05 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


mob_spawner_events:
  type: world
  debug: true
  events:
    on player places mob_spawner_completed:
    # - [check if item is valid]
    - if !<context.item_in_hand.has_flag[mob]>:
      - determine passively cancelled
      - narrate "<&4>This item was not marked correctly when created, please contact staff to claim a replacement."
      - stop
    - else:
      # - [set the entity type of the spawner]
      - define type <context.item_in_hand.flag[mob]>
      - wait 1t
      - adjust <context.location> spawner_type:<[type]>
      - flag server <context.location.simple>.spawner

    on player breaks spawner:
    # - [check for enchantment/item type]
    - if !<player.item_in_hand.enchantments.contains[silk_touch]> || !<player.item_in_hand.material.name.contains[pickaxe]>:
      - determine passively cancelled
      - ratelimit <player> 2s
      - actionbar "<&4>You must have silk touch pickaxe to break this!"
      - playsound <player.location> sound:entity_villager_no volume:2
    - else:
      # - [if vanilla spawner, give fragments]
      - if !<server.has_flag[<context.location.simple>.spawner]>:
          - determine <item[mob_spawner_fragment].with[quantity=25]>
      # - [ if not, give spawner with entity type attached]
      - else if <server.has_flag[<context.location.simple>.spawner]>:
        - define Type <context.location.spawner_type.entity_type.to_titlecase>
        - determine "<item[mob_spawner_completed].with_flag[mob:<[type]>].with[display_name=<&a><[Type]><&b> Spawner]>"
        - flag server <context.location.simple>.spawner:!
      - else:
      # - [ if neither, something bork and get halp]
        - determine passively cancelled
        - narrate "<&4>This location was not marked correctly when the spawner was placed. Contact staff to claim a spawner replacement please."