summaryrefslogtreecommitdiff
path: root/data/onechunk/function/initialize.mcfunction
diff options
context:
space:
mode:
Diffstat (limited to 'data/onechunk/function/initialize.mcfunction')
-rw-r--r--data/onechunk/function/initialize.mcfunction40
1 files changed, 40 insertions, 0 deletions
diff --git a/data/onechunk/function/initialize.mcfunction b/data/onechunk/function/initialize.mcfunction
new file mode 100644
index 0000000..4d545a0
--- /dev/null
+++ b/data/onechunk/function/initialize.mcfunction
@@ -0,0 +1,40 @@
+scoreboard players set $chunkSize onechunk_data 16
+
+execute store result score $posX onechunk_data run data get entity @p Pos[0]
+execute store result score $posZ onechunk_data run data get entity @p Pos[2]
+
+# posX - ( posX % 16 )
+# posZ - ( posZ % 16 )
+# = chunk start corner
+# + 15 = chunk end corner
+
+execute store result score $chunkStartX onechunk_data run scoreboard players get $posX onechunk_data
+execute store result score $tmp onechunk_data run scoreboard players get $posX onechunk_data
+scoreboard players operation $tmp onechunk_data %= $chunkSize onechunk_data
+scoreboard players operation $chunkStartX onechunk_data -= $tmp onechunk_data
+
+execute store result score $chunkStartZ onechunk_data run scoreboard players get $posZ onechunk_data
+execute store result score $tmp onechunk_data run scoreboard players get $posZ onechunk_data
+scoreboard players operation $tmp onechunk_data %= $chunkSize onechunk_data
+scoreboard players operation $chunkStartZ onechunk_data -= $tmp onechunk_data
+
+execute store result score $chunkCenterX onechunk_data run scoreboard players get $chunkStartX onechunk_data
+scoreboard players set $tmp onechunk_data 8
+scoreboard players operation $chunkCenterX onechunk_data += $tmp onechunk_data
+
+execute store result score $chunkCenterZ onechunk_data run scoreboard players get $chunkStartZ onechunk_data
+scoreboard players set $tmp onechunk_data 8
+scoreboard players operation $chunkCenterZ onechunk_data += $tmp onechunk_data
+
+summon armor_stand ~ ~ ~ {NoGravity:1,Invulnerable:1,Invisible:1,Tags:["onechunk_chunk_center"]}
+execute store result entity @e[tag=onechunk_chunk_center,limit=1] Pos[0] double 1 run scoreboard players get $chunkCenterX onechunk_data
+execute store result entity @e[tag=onechunk_chunk_center,limit=1] Pos[2] double 1 run scoreboard players get $chunkCenterZ onechunk_data
+execute store result entity @e[tag=onechunk_chunk_center,limit=1] Pos[1] double 1 run data get entity @p Pos[1]
+
+execute at @e[tag=onechunk_chunk_center,limit=1] run worldborder center ~ ~
+kill @e[tag=onechunk_chunk_center]
+
+# TODO: how to set to score?
+worldborder set 16
+
+scoreboard players set $initialized onechunk_data 1