Date: 2023/03/11 17:09:53 UTC-08:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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[2]>,<[loc].y>,<[loc].z.add[2]>,<[loc].x.add[-2]>,<[loc].y>,<[loc].z.add[-2]>]>
- 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 because PHYSICS:
- if <context.hanging.location.has_flag[lantern_of_warding]>:
- flag <context.hanging.location> lantern_of_warding:!
- spawn [item=wardinglantern] <context.hanging.location>
- remove <context.hanging>
- determine cancelled
- 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 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