# ========================================== # # || MAILBOXES || # # ========================================== # Blue_Mailbox: type: item material: player_head display name: "Blue Mailbox" post: birch_fence mechanisms: skull_skin: 9287f1f0-817a-457c-9a92-cb6959cb304c|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjZhNDllZmFhYWI1MzI1NTlmZmY5YWY3NWRhNmFjNGRkNzlkMTk5ZGNmMmZkNDk3Yzg1NDM4MDM4NTY0In19fQ== Green_Mailbox: type: item material: player_head display name: "Green Mailbox" post: dark_oak_fence mechanisms: skull_skin: fd0879d9-fb75-422c-8343-adeb816183e1|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTVmYmJjNjI1ZmE0ZWI2NDk2YmU4ZGJiZjBhYTJiMjhmMTAyOTdjZmZiY2Y1ZTBhYWY2Y2IxMWU4ZjI2MTZlZCJ9fX0= Iron_Mailbox: type: item material: player_head display name: "Iron Mailbox" post: iron_bars mechanisms: skull_skin: fe3576bd-28c3-47d9-a9a7-2d4dc46a5106|eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDZhYWVmMDEyMGFmNzFiYTNiODNmYmRkYWJjMzM0YmM2M2YyMzExNTk5Njk4YTMxODI0M2JlNjlmMDYwN2RhMyJ9fX0= Mailbox_Physics: type: world debug: false events: # Always keeps the Mailboxes.yml file loaded. on server prestart: - yaml load:mailboxes.yml id:mailboxes # Handles the placement of a mailbox on the ground or a wall. Forward compatible with # more mailbox designs. on player places *_mailbox: - determine passively cancelled - if == player_wall_head: - define location: - wait 1t - modifyblock <[location]> player_wall_head[direction=] - else: - define location: - wait 1t - modifyblock <[location]> player_head[direction=] - modifyblock <[location].below> ].yaml_key[post]> - adjust <[location]> skull_skin:].yaml_key[mechanisms.skull_skin]> - flag server mailbox_locations:->:<[location]> - if !: - take iteminhand quantity:1 # The next three events destroy the mailbox if the player breaks any block that is part # of its construction. on player breaks *_fence|iron_bars: - if ]||false>: - determine passively cancelled - wait 1t - modifyblock air - if : - modifyblock air - else: - modifyblock air naturally - flag server mailbox_locations:<-: on player breaks player_head: - if ]||false>: - determine passively cancelled - wait 1t - if : - modifyblock air - else: - modifyblock air naturally - modifyblock air - flag server mailbox_locations:<-: on player breaks player_wall_head: - if ]||false>: - determine passively cancelled - wait 1t - if : - modifyblock air - else: - modifyblock air naturally - flag server mailbox_locations:<-: # When player interacts with a mailbox, runs the script that will handle mailbox # functionality. Supports the shift-right-click behavior of other interactive blocks. on player right clicks player_head|player_wall_head: - if ]||false> && !: - determine passively cancelled - inject Mailbox_Task_Open Mailbox_Task_Open: type: task debug: false script: # If the player doesn't yet have a Mailbox Inventory stored in the YAML file, creates # a default inventory for them. - if !]||false>: - yaml id:mailboxes set inventories.: - yaml savefile:mailboxes.yml id:mailboxes - inventory open d:in@generic[size=18;title=Mailbox;contents=]>] # ========================================== # # || MAIL || # # ========================================== # New_Mail_Item: type: item material: writable_book[flags=HIDE_ENCHANTS] display name: "New Mail" enchantments: - Luck lore: - "Click here to start writing..." Mail_Behavior: type: world debug: false events: on player clicks new_mail_item in inventory: # When a player clicks "New Mail" inside of a mailbox. - if == Mailbox: - determine passively cancelled - narrate "Click a recipient..." - title "subtitle:Click a recipient..." - inject New_Mail_Task on player clicks letter in inventory: # When a player opens received mail. - if == Mailbox: - determine passively cancelled - narrate "Opening letter from " on new_mail_command command: # When a player clicks a recipient. - if ]>: - determine passively fulfilled - define Recipient:]].get[1]> - if ]].size||0> > 0: - narrate "You already have a letter to <[Recipient].name> in your inventory." - else: - if >= 0: - give "i@writable_book[book=pages|Dear <[Recipient].name>,

;display_name=New Letter to <[Recipient].name>;nbt=Player/<[Recipient].uuid>;lore=Letter to <[Recipient].name>]" - narrate "Check your inventory for your new blank letter to <[Recipient].name>." - else: - narrate "Your inventory is full!" on player signs book: # When a player finishes writing a letter. - if : - narrate "<&n><&hover[Drag and drop an item from your inventory onto the letter to attach it.]>Attach items<&end_hover><&r> if you wish, then place this letter in a mailbox to send it to !" - title "subtitle:Letter created with subject " - define title: - wait 1t - inventory adjust display_name:<[title]> origin: slot: on player clicks written_book in inventory: # When a player attempts to attach an item to a letter. - if ]||false>: - if == RIGHT: - if != i@air: - determine passively cancelled - define Letter: - define Attachment: - adjust item_on_cursor:air # - inventory adjust nbt:->:Attachment/<[Attachment]> origin:<[Letter]> # - else if ]||false>: # - if == RIGHT: # - if == i@air: # - determine passively cancelled # - define Gift: # - adjust item_on_cursor:<[Gift]> # - inventory adjust nbt:<-:Attachment/<[Gift]> origin:<[Letter]> New_Mail_Task: type: task debug: false script: # Creates the "Choose a Recipient" list. - inventory close - wait 1t - define Author:Mailbox - define 'Title:New Mail' - define 'MailList:Choose A Recipient<&r>

' - foreach ].parse[name].alphabetical> as:Person: - define 'Hover:Click to send <[Person]> a letter!' - define Text:<[Person]> - define 'Command:new_mail_command <[Person]>' - define MailList:->:<&hover[<[Hover]>]><&click[/<[Command]>]><&n><[Text]><&end_click><&end_hover><&nl> - adjust show_book:i@written_book[book=author|<[Author]>|title|<[Title]>|pages|<[MailList].as_string.unescaped>] Mail_Delivery: type: world debug: false events: on player closes inventory: - if == Mailbox: - define Outgoing:]]> - if <[Outgoing].size||0> > 0: - inject Mailbox_Task_Send - else: - yaml id:mailboxes set inventories.: - yaml savefile:mailboxes.yml id:mailboxes Mailbox_Task_Send: type: task debug: false script: - foreach <[Outgoing]> as:Letter: - define Recipient:<[Letter].nbt[Player]> - define Inbox:]> - if <[Inbox].contains[i@air]>: - define Inbox:<[Inbox].set[<[Letter]>].at[<[Inbox].find[air]>]> - yaml id:mailboxes set inventories.<[Recipient]>:<[Inbox]> - yaml savefile:mailboxes.yml id:mailboxes - narrate "Sent <[Letter].book_title> to <[Recipient].as_player.name>"