Paste #107228: Unnamed Denizen Script Paste

Date: 2023/03/11 16:15:46 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


wardinglantern:
  type: item
  debug: true
  material: PAPER
  display name: <&color[#FFDFD3]>Lantern of warding
  lore:
  - <&[lore]><&color[#CF9FFF]><strikethrough><element[ ].repeat[44]>
  - <&[lore]>
  - <&[lore]><&color[#6bb0e8]> Ward off unwanted guests
  - <&[lore]>
  - <&[lore]><&color[#c9f0f2]> Prevents hostile mobs spawning
  - <&[lore]><&color[#c9f0f2]> within 15 blocks in all directions
  - <&[lore]>
  - <&[lore]> ➡ Place to activate
  - <&[lore]>
  - <&[lore]><&color[#CF9FFF]><strikethrough><element[ ].repeat[14]><reset><&color[WHITE]><strikethrough><&color[#CF9FFF]><strikethrough><element[ ].repeat[15]>
  mechanisms:
    custom_model_data: 10677
    hides: ALL
  flags:
    lantern: true



lantern_of_warding:
    type: world
    debug: true
    events:
        on player right clicks block with:item_flagged:lantern type:!air:
            - if <context.relative> == <context.location.add[0,1,0]> && !<context.location.add[0,1,0].has_flag[lantern_of_warding]>:
              - determine passively cancelled
              - spawn item_frame[rotation=up;framed=wardinglantern;visible=false] <context.location.add[0,1,0]>
              - flag <context.location.add[0,1,0]> lantern_of_warding
              - actionbar "<&c>Lantern of Warding placed"
              - take item:wardinglantern
              - define loc <context.location.add[0,1,0]>
              - define cuboid <cuboid[<[loc].world.name>,<[loc].x.add[15]>,<[loc].y>,<[loc].z.add[15]>,<[loc].x.add[-15]>,<[loc].y>,<[loc].z.add[-15]>]>
              - flag <context.location.add[0,1,0]> cuboid:<[cuboid]>
            - if !<cuboid[lantern_of_warding_<player.world.name>].exists>:
                - note <[cuboid]> as:lantern_of_warding_<player.world.name>
            - else:
                - note <cuboid[lantern_of_warding_<player.world.name>].add_member[<[cuboid]>]> as:lantern_of_warding_<player.world.name>
        after item_frame damaged by player:
            - if <context.entity.location.has_flag[lantern_of_warding].if_null[false]>:
                - actionbar "<&c>Lantern of Warding broken"
                - flag <context.entity.location> lantern_of_warding:!
                - define index 1
                - if <cuboid[lantern_of_warding_<player.world.name>].members_size> == 1:
                    - note remove as:lantern_of_warding_<player.world.name>
                - else:
                    - foreach <cuboid[lantern_of_warding_<player.world.name>].list_members> as:entry:
                        - if <[entry]> == <context.entity.location.flag[cuboid]>:
                            - adjust <cuboid[lantern_of_warding_<context.entity.location.world.name>]> remove_member:<[index]>
                            - foreach stop
                        - define index <[index].add[1]>
                - remove <context.entity>
                - determine NOTHING

        on hanging breaks:
            - if <context.hanging.location.has_flag[lantern_of_warding]>:
               - flag <context.hanging.location> lantern_of_warding:!
               - remove <context.hanging.entity>
               - determine passively cancelled



        on entity spawns in:lantern_of_warding_*:
        - if !<context.entity.is_monster>:
            - stop
        - playeffect effect:END_ROD at:<context.location> quantity:5 data:0.1
        - determine cancelled