Date: 2024/08/24 15:02:36 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# switch BLOCK state:on to Toggle CommandBlocks
# modifyblock BLOCK MATERIAL to Change Blocks
# execute as_server COMMAND
# Command Modify Limit -> 65792
# Run update_chunk def.ChunkX:31 def.ChunkZ:3 def.ChunkWorld:world_sky
update_chunk:
debug: false
type: task
script:
# Run update_chunk def.ChunkX:31 def.ChunkZ:3 def.ChunkWorld:world_sky
- if <[ChunkX].exists> = false:
- define ChunkX:0
- if <[ChunkZ].exists> = false:
- define ChunkZ:0
- if <[ChunkWorld].exists> = false:
- define ChunkWorld:world_sky
- define ProcessChunk <chunk[<[ChunkX]>,<[ChunkZ]>,<[ChunkWorld]>]>
- define MinX <[ChunkX]>
- define MinX:*:16
- define MinZ <[ChunkZ]>
- define MinZ:*:16
- define MaxX <[MinX]>
- define MaxX:+:15
- define MaxZ <[MinZ]>
- define MaxZ:+:15
- if <chunk[<[ProcessChunk]>].is_loaded> = false:
- define time_start <util.current_time_millis>
- chunkload <[ProcessChunk]> duration:10s
- define elapsed <util.current_time_millis>
- define elapsed:-:<[time_start]>
- narrate "Loaded Chunk in <[elapsed]>ms"
- narrate "Updating Chunk: <[ProcessChunk]> Loaded: <chunk[<[ProcessChunk]>].is_loaded>"
- if !<[ProcessChunk].has_flag[worked]>:
- narrate "Updating in Progress, ..."
# Move Main Chunk Down
- define time_start <util.current_time_millis>
- if !<[ProcessChunk].has_flag[moved]>:
- flag <[ProcessChunk]> moved
- ~schematic create name:move_chunk area:<cuboid[<[ChunkWorld]>,<[MinX]>,0,<[MinZ]>,<[MaxX]>,256,<[MaxZ]>]> <location[<[MinX]>,0,<[MinZ]>,<[ChunkWorld]>]> entities delayed
- ~schematic paste name:move_chunk <location[<[MinX]>,-64,<[MinZ]>,<[ChunkWorld]>]> delayed
- ~schematic unload name:move_chunk delayed
# Move neighbor Chunks
- definemap Chunklist
1:<chunk[<[ChunkX].add[1]>,<[ChunkZ]>,<[ChunkWorld]>]>
2:<chunk[<[ChunkX].add[1]>,<[ChunkZ].add[1]>,<[ChunkWorld]>]>
3:<chunk[<[ChunkX].add[1]>,<[ChunkZ].sub[1]>,<[ChunkWorld]>]>
4:<chunk[<[ChunkX]>,<[ChunkZ].add[1]>,<[ChunkWorld]>]>
5:<chunk[<[ChunkX]>,<[ChunkZ].sub[1]>,<[ChunkWorld]>]>
6:<chunk[<[ChunkX].sub[1]>,<[ChunkZ]>,<[ChunkWorld]>]>
7:<chunk[<[ChunkX].sub[1]>,<[ChunkZ].add[1]>,<[ChunkWorld]>]>
8:<chunk[<[ChunkX].sub[1]>,<[ChunkZ].sub[1]>,<[ChunkWorld]>]>
- foreach <[Chunklist]> as:chunk:
- if <chunk[<[chunk]>].is_loaded> = false:
- chunkload <[chunk]> duration:10s
- if !<[chunk].has_flag[moved]>:
- flag <[chunk]> moved
- ~schematic create name:move_chunk area:<[chunk].cuboid> <location[<[MinX]>,0,<[MinZ]>,<[ChunkWorld]>]> entities delayed
- ~schematic paste name:move_chunk <location[<[MinX]>,-64,<[MinZ]>,<[ChunkWorld]>]> delayed
- ~schematic unload name:move_chunk delayed
- define elapsed <util.current_time_millis>
- define elapsed:-:<[time_start]>
- narrate "Loaded and Moved all Chunks in <[elapsed]>ms"
# Replace Blocks
- definemap block_replacements
black_concrete:deepslate
gray_concrete:tuff
white_concrete:calcite
magenta_stained_glass:amethyst_block
pink_stained_glass:budding_amethyst
orange_concrete:copper_ore
blue_terracotta:sculk
pink_terracotta:sculk_catalyst
purple_terracotta:dripstone_block
green_terracotta:moss_block
light_blue_terracotta:water
magenta_terracotta:water
coarse_dirt:mud
green_carpet:moss_carpet
- definemap block_overlays
green_terracotta:dirt
light_blue_terracotta:clay
magenta_terracotta:calcite
blue_terracotta:deepslate
pink_terracotta:sculk
- definemap block_underlays
green_terracotta:true
light_blue_terracotta:false
magenta_terracotta:false
blue_terracotta:true
pink_terracotta:false
- definemap block_surround
magenta_terracotta:true
light_blue_terracotta:true
- definemap ore_replace
coal_ore:deepslate_coal_ore
copper_ore:deepslate_copper_ore
lapis_ore:deepslate_lapis_ore
iron_ore:deepslate_iron_ore
gold_ore:deepslate_gold_ore
redstone_ore:deepslate_redstone_ore
diamond_ore:deepslate_diamond_ore
emerald_ore:deepslate_emerald_ore
- definemap saplings
cherry_sapling:cherry
mangrove_propagule:mangrove
- definemap makeunfloat
cherry_log:cherry_log
- definemap waterplants
water:True
small_dripleaf:True
big_dripleaf:True
big_dripleaf_stem:True
- definemap fluidreplacer
blue_wool:water
red_wool:lava
- define time_start <util.current_time_millis>
- define blocks <[ProcessChunk].cuboid.blocks>
- foreach <[blocks]> as:block:
- define replace_y <[block].y>
- if <[block].y> == -64:
- modifyblock <[block]> bedrock delayed
- else:
- define block_above <[block].relative[0,1,0]>
- define block_below <[block].relative[0,-1,0]>
- define block_north <[block].relative[0,0,-1]>
- define block_south <[block].relative[0,0,1]>
- define block_east <[block].relative[1,0,0]>
- define block_west <[block].relative[-1,0,0]>
- define change_block false
- if <[block].material.name> = command_block:
- define command <[block].command_block>
- define parts <[command].split[ ]>
- if <[parts].get[1]> = "blockreplacer":
- define block_type <[parts].get[2]>
- if <[block_type]> in <[saplings].keys>:
- modifyblock <[block]> air delayed
- execute as_server "/world <[ChunkWorld]>" silent
- execute as_server "/pos1 <[block].x>,<[block].y>,<[block].z>" silent
- execute as_server "/pos2 <[block].x>,<[block].y.sub[1]>,<[block].z>" silent
- execute as_server "/forest <[saplings.<[block_type]>]> 100" delayed
- else:
- if <[parts].get[3].exists>:
- execute as_server "/world <[ChunkWorld]>" silent
- execute as_server "/pos1 <[block].x>,<[block].y>,<[block].z>" silent
- execute as_server "/pos2 <[block].x>,<[block].y>,<[block].z>" silent
- execute as_server "/set <[block_type]>" delayed
- else:
- modifyblock <[block]> <[block_type]> delayed
- if <[parts].get[1]> = "schematic":
# Make sure the Schematic is saved in WorldEdit as Sponge.2 otherwise Denizen cannot load it.
- define PlaceY:<[replace_y]>
- define PlaceX:<[block].x>
- define PlaceZ:<[block].z>
- if <[parts].get[3].exists>:
- define PlaceY:+:<[parts].get[3]>
- if <[parts].get[4].exists>:
- define PlaceX:+:<[parts].get[4]>
- if <[parts].get[5].exists>:
- define PlaceZ:+:<[parts].get[5]>
- if <[parts].get[2]> not in <schematic.list>:
- ~schematic load name:<[parts].get[2]>
- define mask_area:<schematic[<[parts].get[2]>].cuboid[<location[<[PlaceX]>,<[PlaceY]>,<[PlaceZ]>,<[ChunkWorld]>]>]>
- define mask_list <[mask_area].blocks.parse[material]>
## - Basic Mask - ##
- define mask <material[air].name>|<material[grass_block].name>|<material[cherry_leaves].name>|<material[oak_leaves].name>|<material[spruce_leaves].name>|<material[birch_leaves].name>|<material[jungle_leaves].name>|<material[acacia_leaves].name>|<material[dark_oak_leaves].name>|<material[mangrove_leaves].name>|<material[azalea_leaves].name>|<material[flowering_azalea_leaves].name>
- ~schematic paste name:<[parts].get[2]> mask:<[mask]> noair <location[<[PlaceX]>,<[PlaceY]>,<[PlaceZ]>,<[ChunkWorld]>]>
# Replace blocks based on the replacement dictionary
- if <[block].material.name> in <[block_overlays].keys>:
- if not <[block_above].material.is_solid>:
- define change_block true
- if not <[block_below].material.is_solid>:
- if <[block_underlays.<[block].material.name>]> = true:
- define change_block true
- if <[block].material.name> in <[block_surround].keys>:
- if not <[block_north].material.is_solid>:
- if <[block_north].material.name> not in <[waterplants].keys>:
- define change_block false
- if not <[block_east].material.is_solid>:
- if <[block_east].material.name> not in <[waterplants].keys>:
- define change_block false
- if not <[block_west].material.is_solid>:
- if <[block_west].material.name> not in <[waterplants].keys>:
- define change_block false
- if not <[block_south].material.is_solid>:
- if <[block_south].material.name> not in <[waterplants].keys>:
- define change_block false
- if <[change_block]> = true:
- if <[block].material.name> in <[block_replacements].keys>:
- modifyblock <[block]> <[block_replacements.<[block].material.name>]> delayed
- else:
- modifyblock <[block]> <[block_overlays.<[block].material.name>]> delayed
- else:
- if <[block].material.name> in <[block_replacements].keys>:
- modifyblock <[block]> <[block_replacements.<[block].material.name>]> delayed
- if <[block].material.name> = dirt or <[block].material.name> = coarse_dirt:
- define random_index <util.random.int[1].to[15]>
- if <[random_index]> = 1:
- if <[block_below].material.name> = air or <[block_below].material.name> = cave_air:
- modifyblock <[block_below]> hanging_roots delayed
- if <[block].material.name> in <[makeunfloat].keys>:
- if not <[block_below].material.is_solid>:
- modifyblock <[block_below]> <[block_above].material.name> delayed
- execute as_server "/world <[ChunkWorld]>" silent
- execute as_server "/pos1 <[block].x>,<[block].y>,<[block].z>" silent
- execute as_server "/pos2 <[block].x>,<[block].y.sub[1]>,<[block].z>" silent
- execute as_server "/set <[block_above].material.name>"
- if <[replace_y]> <= -1:
- if <[block].material.name> in <[ore_replace].keys>:
- modifyblock <[block]> <[ore_replace.<[block].material.name>]> delayed
- if <[block].material.name> in <[fluidreplacer].keys>:
- define change_block true
- if not <[block_north].material.is_solid> or <[block_north].material.name> != <[fluidreplacer.<[block].material.name>]>:
- define change_block false
- if not <[block_east].material.is_solid> or <[block_east].material.name> != <[fluidreplacer.<[block].material.name>]>:
- define change_block false
- if not <[block_west].material.is_solid> or <[block_west].material.name> != <[fluidreplacer.<[block].material.name>]>:
- define change_block false
- if not <[block_south].material.is_solid> or <[block_south].material.name> != <[fluidreplacer.<[block].material.name>]>:
- define change_block false
- if not <[block_below].material.is_solid> or <[block_below].material.name> != <[fluidreplacer.<[block].material.name>]>:
- define change_block false
- if <[change_block]> = true:
- modifyblock <[block]> <[fluidreplacer.<[block].material.name>]> delayed
- else:
- if <[block].y> <= 0:
- modifyblock <[block]> deepslate delayed
- else:
- if <[block].y> <= 64 and not <[block_above].material.is_solid>:
- modifyblock <[block]> grass_block delayed
- else:
- modifyblock <[block]> stone delayed
- define elapsed <util.current_time_millis>
- define elapsed:-:<[time_start]>
- narrate "Scanned and Adjusted Blocks in <[elapsed]>ms"
- flag <[ProcessChunk]> worked
- else:
- narrate "Already Updated, ..."
- narrate "Updating Done: <[ProcessChunk]>"