Paste #69389: Edit of P#69372 - Decorator Tool

Date: 2020/05/21 23:42:38 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Decorator_Tool:
  type: item
  material: stick
  display name: <blue>Decorate!
  lore:
  - Right-click to mark location as decorative.
  - Left-click to unmark location.
  - Shift-right-click to toggle block state.

Decorate_Command:
  type: command
  name: decorate
  usage: /decorate
  description: Toggles Decorator Mode.
  ## Set your permissions here.
  #permission: my.permission.node
  allowed help:
  ## Change this line to match your permission needs.
  #- determine <player.is_op>
  script:
      - if !<player.inventory.contains[decorator_tool]>:
        - give decorator_tool
        - narrate "<aqua>Decorator Mode <green>[ENABLED]"
        - narrate "<gray>Use the <blue>Decorate! <gray>stick to decorate."
        - narrate "<gray>Right-click to add, left-click to remove."
        - narrate "<gray>Right-click while sneaking to toggle open/closed."
      - else:
        - take decorator_tool
        - narrate "<aqua>Decorator Mode <red>[DISABLED]"

Decorative_Blocks:
  type: world
  debug: false
  misc_blocks:
  - loom
  - crafting_table
  - cartography_table
  - anvil
  - chipped_anvil
  - damaged_anvil
  - enchanting_table
  - grindstone
  - smithing_table
  - stonecutter
  - fletching_table
  events:
    on player right clicks block priority:1:
      - if <server.has_flag[decorative_block.<context.location.simple>]>:
        - determine cancelled
    on player stands on material:
      - if <server.has_flag[decorative_block.<context.location.simple>]>:
        - determine cancelled
    # Decorator tool functionality.
    on player clicks block with decorator_tool:
      - determine passively cancelled
      - if <player.is_sneaking> && <context.click_type> == right_click_block:
        - switch <context.location>
        - stop
      - choose <context.click_type>:
        - case right_click_block:
          - if !<context.location.material.is_switchable> && !<context.location.has_inventory> && !<script.yaml_key[misc_blocks].contains[<context.location.material.name>]> && !<context.location.material.name.ends_with[_bed]>:
            - narrate "<dark_gray>You cannot make <context.location.material.item.formatted> decorative."
            - stop
          - if <server.has_flag[decorative_block.<context.location.simple>]>:
            - narrate "<dark_gray>This <context.location.material.item.formatted.after[ ]> is already decorative!"
            - stop
          - narrate "<aqua>Made this <context.location.material.item.formatted.after[ ]> decorative."
          - flag server decorative_block.<context.location.simple>
        - case left_click_block:
          - if !<server.has_flag[decorative_block.<context.location.simple>]>:
            - narrate "<dark_gray>This <context.location.material.item.formatted.after[ ]> is not decorative!"
            - stop
          - narrate "<red>This <context.location.material.item.formatted.after[ ]> is no longer decorative."
        - flag server decorative_block.<context.location.simple>:!
    # If any player breaks a decorative block, alerts them and removes decoration flag.
    on player breaks block priority:1:
      - if <server.has_flag[decorative_block.<context.location.simple>]>:
        - narrate "<red>You broke a decorative <context.location.material.item.formatted.after[ ]>."
        - flag server decorative_block.<context.location.simple>:!