Date: 2018/07/04 10:54:59 UTC-07: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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
"Heavens Handler":
type: world
debug: true
events:
on player right clicks quartz_block with flint_and_steel in prosperus:
- if <context.location.add[0,1,0].material> != m@air
{
- queue clear
}
- if <context.location.add[1,0,0].material> == m@quartz_block && <context.location.add[-1,0,0].material> == m@quartz_block
{
- define axis-pos l@1,0,0
- define axis-neg l@-1,0,0
- define axis-data 1
}
else if <context.location.add[0,0,1].material> == m@quartz_block && <context.location.add[0,0,-1].material> == m@quartz_block
{
- define axis-pos l@0,0,1
- define axis-neg l@0,0,-1
- define axis-data 2
}
else
{
- queue clear
}
- define origin <context.location.add[0,1,0]>
- define node <def[origin]>
- define air-list li@
- define y-list li@
- define y-max <def[origin].y>
- define y-min <def[origin].y>
- define x-max <def[origin].x>
- define x-min <def[origin].x>
- define z-max <def[origin].z>
- define z-min <def[origin].z>
- while <def[node].material.is[==].to[m@air]>
{
- define air-list <def[air-list].include[<def[node]>]>
- define y-list <def[y-list].include[<def[node]>]>
- define y-max <def[y-max].max[<def[node].y>]>
- define y-min <def[y-min].min[<def[node].y>]>
- define node <def[node].add[0,1,0]>
}
- if <def[node].material> != m@quartz_block
{
- queue clear
}
else
{
- foreach <def[y-list]>
{
- define node <def[value]>
- while <def[node].material.is[==].to[m@air]>
{
- define air-list <def[air-list].include[<def[node]>]>
- if <def[axis-data]> == 1
{
- define x-max <def[x-max].max[<def[node].x>]>
- define x-min <def[x-min].min[<def[node].x>]>
}
- if <def[axis-data]> == 2
{
- define z-max <def[z-max].max[<def[node].z>]>
- define z-min <def[z-min].min[<def[node].z>]>
}
- define node <def[node].add[<def[axis-pos]>]>
}
- if <def[node].material> != m@quartz_block
{
- queue clear
}
- define node <def[value]>
- while <def[node].material.is[==].to[m@air]>
{
- define air-list <def[air-list].include[<def[node]>]>
- if <def[axis-data]> == 1
{
- define x-max <def[x-max].max[<def[node].x>]>
- define x-min <def[x-min].min[<def[node].x>]>
}
- if <def[axis-data]> == 2
{
- define z-max <def[z-max].max[<def[node].z>]>
- define z-min <def[z-min].min[<def[node].z>]>
}
- define node <def[node].add[<def[axis-neg]>]>
}
- if <def[node].material> != m@quartz_block
{
- queue clear
}
}
}
- modifyblock <def[air-list]> m@end_gateway,<def[axis-data]> no_physics
# - announce to_console "cu@<def[x-min].add[<def[axis-neg].x>]>,<def[y-min].add[-1]>,<def[z-min].add[<def[axis-neg].z>]>,prosperus|<def[x-max].add[<def[axis-pos].x>]>,<def[y-max].add[1]>,<def[z-max].add[<def[axis-pos].z>]>,prosperus as:heavens-portal-<util.random.duuid>"
- note cu@<def[x-min].add[<def[axis-neg].x>]>,<def[y-min].add[-1]>,<def[z-min].add[<def[axis-neg].z>]>,prosperus|<def[x-max].add[<def[axis-pos].x>]>,<def[y-max].add[1]>,<def[z-max].add[<def[axis-pos].z>]>,prosperus as:heavens-portal-<util.random.duuid>
on player breaks end_gateway:
- if <context.location.cuboids.contains_text[heavens-portal]>
{
- define notable <context.location.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1]>
- modifyblock <def[notable].blocks[end_gateway]> m@air
- note remove as:<def[notable].notable_name>
}
on player breaks quartz_block:
- if <context.location.cuboids.contains_text[heavens-portal]>
{
- define notable <context.location.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1]>
- modifyblock <def[notable].blocks[end_gateway]> m@air
- flag server <context.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1].notable_name>:!
- note remove as:<def[notable].notable_name>
}
on player enters notable cuboid:
- if <context.cuboids.contains_text[heavens-portal]>
{
- define target-location l@<context.from.x.div[2].as_int>,<context.from.y.as_int>,<context.from.z.div[2].as_int>,heavens
- announce to_console "def target-location: <def[target-location]>"
- define target-material <def[target-location].material>
- announce to_console "def target-material: <def[target-material]>"
- define portal <context.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1]>
- announce to_console "def portal: <def[portal]>"
- define portal-exit <context.cuboids.filter[notable_name.starts_with[heavens-portal]].get[1].notable_name>
- announce to_console "def portal-exit: <def[portal-exit]>"
- define portal-unsafe-exit <def[portal-exit]>-unsafe
- announce to_console "def portal-unsafe-exit: <def[portal-unsafe-exit]>"
- if <server.has_flag[<def[portal-exit]>]>
{
- teleport <server.flag[<def[portal-exit]>]>
- queue clear
}
- if <server.has_flag[<def[portal-unsafe-exit]>]>
{
- teleport <server.flag[<def[portal-unsafe-exit]>]>
- announce to_console "teleport <server.flag[<def[portal-unsafe-exit]>]>"
- flag player player-gliding-chestplate:<player.equipment.chestplate>
- announce to_console "Giving player temporary elytra, player chestplate was <player.equipment.chestplate>"
- wait 10t
- equip <player> chest:elytra
- adjust <player> gliding:true
- queue clear
}
- if <def[target-material]> == m@air && <def[target-location].add[0,-1,0].material> != m@air && <def[target-location].add[0,1,0].material> == m@air
{
- announce to_console "Initial block is safe"
- define teleport-location l@<context.from.x.div[2]>,<context.from.y>,<context.from.z.div[2]>,heavens
- teleport <def[teleport-location]>
- announce to_console "teleport <def[teleport-location]>"
- flag server <def[portal-exit]>:<def[teleport-location]>
- queue clear
}
- define size 20
- if <def[target-location].find.surface_blocks.within[<def[size]>].size> >= 1
{
- announce to-console "Finding safe spot"
- define safe-spot <def[target-location].find.surface_blocks.within[<def[size]>].random>
- announce to_console "Safe spot: <def[safe-spot]>"
- teleport <def[safe-spot]>
- announce to_console "teleport <def[safe-spot]>"
- flag server <def[portal-exit]>:<def[safe-spot]>
- queue clear
}
else
{
- announce to_console "No safe spot, let's glide!"
- flag server <def[portal-unsafe-exit]>:l@<context.from.x.div[2]>,90,<context.from.z.div[2]>,heavens
- teleport l@<context.from.x.div[2]>,90,<context.from.z.div[2]>,heavens
- announce to_console "teleport l@<context.from.x.div[2]>,90,<context.from.z.div[2]>,heavens"
- flag player player-gliding-chestplate:<player.equipment.chestplate>
- announce to_console "Giving player temporary elytra, player chestplate was <player.equipment.chestplate>"
- equip <player> chest:elytra
- adjust <player> gliding:true
}
- determine cancelled
}
on player stops gliding in heavens:
- if <player.has_flag[player-gliding-chestplate]>
{
- equip <player> chest:<flag.player[player-gliding-chestplate]>
- flag player player-gliding-chestplate:!
}
on player clicks in inventory:
- if <player.has_flag[player-gliding-chestplate]> && <context.slot> == 39
{
- narrate "<&c>You can change your chestplate after landing!"
- determine cancelled
}
#"Portal Gliding Handler":
# type: world
# debug: false
# events:
# on player stops gliding in heavens:
# - if <player.has_flag[portal-exiter]>
# {
## - flag player portal-exiter:!
# - determine cancelled
# }
## - determine cancelled
# on player starts gliding in heavens:
# - if <player.has_flag[portal-exiter]>
# {
## - flag player portal-exiter:!
# - determine cancelled:false
# }