wardinglantern: type: item debug: true material: PAPER display name: <&color[#FFDFD3]>Lantern of warding lore: - <&[lore]><&color[#CF9FFF]> - <&[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]><&color[WHITE]><&color[#CF9FFF]> 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 == && !: - determine passively cancelled - spawn item_frame[rotation=up;framed=wardinglantern;visible=false] - flag lantern_of_warding - actionbar "<&c>Lantern of Warding placed" - take item:wardinglantern - define loc - define cuboid ,<[loc].x.add[2]>,<[loc].y>,<[loc].z.add[2]>,<[loc].x.add[-2]>,<[loc].y>,<[loc].z.add[-2]>]> - flag cuboid:<[cuboid]> - if !].exists>: - note <[cuboid]> as:lantern_of_warding_ - else: - note ].add_member[<[cuboid]>]> as:lantern_of_warding_ after item_frame damaged by player: - if : - actionbar "<&c>Lantern of Warding broken" - flag lantern_of_warding:! - define index 1 - if ].members_size> == 1: - note remove as:lantern_of_warding_ - else: - foreach ].list_members> as:entry: - if <[entry]> == : - adjust ]> remove_member:<[index]> - foreach stop - define index <[index].add[1]> - remove - determine NOTHING on hanging breaks because PHYSICS: - if : - flag lantern_of_warding:! - spawn [item=wardinglantern] - remove - determine cancelled - flag lantern_of_warding:! - define index 1 - if ].members_size> == 1: - note remove as:lantern_of_warding_ - else: - foreach ].list_members> as:entry: - if <[entry]> == : - adjust ]> remove_member:<[index]> - foreach stop - define index <[index].add[1]> - remove - determine NOTHING on entity spawns in:lantern_of_warding_*: - if !: - stop - playeffect effect:END_ROD at: quantity:5 data:0.1 - determine cancelled