Paste #41996: Untitled Paste

Date: 2017/05/17 13:07:06 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


on player breaks block: 
    - if <context.location.is_within[gardenspawn]> {
      - determine cancelled
      }
    - if <s@Config.list_keys[materials].contains_any[<context.material.bukkit_enum>].not.and[<context.material.contains_text[podzol].not>]> {
      - determine cancelled
      } 
    - determine passively cancelled 
    - modifyblock <context.location> bedrock
    - define item <player.item_in_hand>
    - if <def[item].enchantments.contains_text[Unbreaking]> {
      - choose <def[item].enchantments.level[Unbreaking]> {
        - case "1" {
          - if <util.random.int[1].to[4].is[>=].than[2]> {
            - ^inject s@ToolDamage instantly
            }
          }
        - case "2" {
          - if <util.random.int[1].to[3].is[>=].than[2]> {
            - ^inject s@ToolDamage instantly
            }
          }
        - case "3" {
          - if <util.random.int[1].to[2].is[==].to[2]> {
            - ^inject s@ToolDamage instantly
            }
          }
        }
      }

ToolDamage:
  type: task
  debug: true
  script:
  - adjust <def[item]> "durability:<player.item_in_hand.durability.add[1]>" save:item
  - take iteminhand
  - if <entry[item].result.durability.is[LESS].than[<def[item].max_durability>]> {
    - give <entry[item].result>
    }
    else {
    - playsound <player> sound:ENTITY_ITEM_BREAK
    }