Created by erenkara

Other available versions. Ordered by newest to oldest versions:

Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.


function runButtonFunction(id: string, p: player, l: location):
  set {_fun} to function reference "button_%{_id}%" called with ({_p} and {_l})
  set {_functions::run} to {_fun}
  set {_proxy} to new proxy instance of Runnable using {_functions::*}

command /givebuttonblock <string> [<item type>] [<string>]:
  usage: /givebuttonblock <id> [item type] [display text]
  permission: give.button.block
    set {_i} to (arg-2 ? glass) named "&eButton with id %arg-1%"
    set {_n} to nbt of {_i}
    set tag "button;id" of {_n} to arg-1
    set tag "button;display" of {_n} to arg-3 ? "Press <yellow>_key"
    give {_i} to player

on place:
  set {_item.nbt} to nbt of player's tool
  {_item.nbt} has tag "button"
  le spawn text display at event-block
  set {_e} to last spawned entity
  set display billboard of {_e} to center
  set {_n} to nbt of {_e}
  set float tag "view_range" of {_n} to 0.15   # skbee's expression is broken.
  set {_text} to tag "button;display" of {_item.nbt}
  replace all "_key" in {_text} with "<key:key.swapOffhand>"
  set display text component of {_e} to mini message from {_text}

  set {button::%location of event-block%} to tag "button;id" of {_item.nbt}

on break:
  {button::%location of event-block%} is set
  delete {button::%location of event-block%}
  kill all entities within radius 0.1 of event-block

on swap hand items:
  {button::%location of targeted block%} is set
  cancel event
  runButtonFunction({button::%location of targeted block%}, player, location of targeted block)