├── README.md ├── data ├── distancing │ ├── functions │ │ ├── assign.mcfunction │ │ ├── check_and_move_dimensions.mcfunction │ │ ├── check_dimensions.mcfunction │ │ ├── check_end_exits.mcfunction │ │ ├── check_x.mcfunction │ │ ├── find_fortress_1.mcfunction │ │ ├── find_fortress_128.mcfunction │ │ ├── find_fortress_16.mcfunction │ │ ├── find_fortress_2.mcfunction │ │ ├── find_fortress_256.mcfunction │ │ ├── find_fortress_32.mcfunction │ │ ├── find_fortress_4.mcfunction │ │ ├── find_fortress_512.mcfunction │ │ ├── find_fortress_64.mcfunction │ │ ├── find_fortress_8.mcfunction │ │ ├── find_fortress_negative.mcfunction │ │ ├── load.mcfunction │ │ ├── make_platform.mcfunction │ │ ├── move_dimensions.mcfunction │ │ ├── move_project.mcfunction │ │ ├── move_project_r.mcfunction │ │ ├── move_r.mcfunction │ │ ├── move_to_line.mcfunction │ │ ├── place_fortress.mcfunction │ │ ├── platform_r.mcfunction │ │ ├── portal.mcfunction │ │ ├── portal_r.mcfunction │ │ ├── pre_tick.mcfunction │ │ ├── randomize_bit.mcfunction │ │ ├── randomize_fortress.mcfunction │ │ ├── read_portal.mcfunction │ │ ├── read_portal_frame.mcfunction │ │ ├── set_eye.mcfunction │ │ ├── set_portal_frame.mcfunction │ │ ├── spawn_random_fortress_mob.mcfunction │ │ ├── sync_portal.mcfunction │ │ ├── tick.mcfunction │ │ ├── try_make_portal.mcfunction │ │ └── try_place_fortress.mcfunction │ └── tags │ │ └── blocks │ │ ├── air.json │ │ └── nonbase.json └── minecraft │ └── tags │ └── functions │ ├── load.json │ └── tick.json └── pack.mcmeta /README.md: -------------------------------------------------------------------------------- 1 | # Distancing 2 | Social Distancing in Minecraft - Stay in Line! 3 | 4 | Every player gets their own x coordinate, 8 blocks apart. How far can you get without leaving your line? 5 | Can you learn to collaborate even when far apart? 6 | 7 | Note that this is a very early alpha version. Expect glitches, especially with Nether and End. 8 | -------------------------------------------------------------------------------- /data/distancing/functions/assign.mcfunction: -------------------------------------------------------------------------------- 1 | # Assign a new player an X value 2 | 3 | tag @s add dist_set 4 | scoreboard players operation @s dist_x = $Next dist_x 5 | scoreboard players operation $Next dist_x *= $-1 dist_x 6 | execute if score $Next dist_x matches 0.. run scoreboard players add $Next dist_x 8 7 | function distancing:move_to_line 8 | -------------------------------------------------------------------------------- /data/distancing/functions/check_and_move_dimensions.mcfunction: -------------------------------------------------------------------------------- 1 | # Check the starting end position and then move after switching dimensions 2 | tag @s add dist_current 3 | execute in the_end as @p[tag=dist_current,distance=0..] run tp @s ~ ~ -100 4 | tag @s remove dist_current 5 | 6 | execute at @s run function distancing:move_dimensions 7 | -------------------------------------------------------------------------------- /data/distancing/functions/check_dimensions.mcfunction: -------------------------------------------------------------------------------- 1 | # Check all players' dimensions 2 | 3 | execute in overworld as @a[distance=0..] unless score @s dist_dimension matches 0 at @s run function distancing:check_and_move_dimensions 4 | execute in the_nether as @a[distance=0..] unless score @s dist_dimension matches -1 at @s run function distancing:check_and_move_dimensions 5 | execute in the_end as @a[distance=0..] unless score @s dist_dimension matches 1 at @s run function distancing:check_and_move_dimensions 6 | 7 | execute in overworld run scoreboard players set @a[distance=0..] dist_dimension 0 8 | execute in the_nether run scoreboard players set @a[distance=0..] dist_dimension -1 9 | execute in the_end run scoreboard players set @a[distance=0..] dist_dimension 1 10 | -------------------------------------------------------------------------------- /data/distancing/functions/check_end_exits.mcfunction: -------------------------------------------------------------------------------- 1 | # Check for and replace end exit portals 2 | 3 | execute if entity @s[tag=!dist_set_end_exit] run fill ~-2 63 -2 ~2 68 2 air 4 | tag @s add dist_set_end_exit 5 | 6 | setblock ~ 63 0 bedrock 7 | setblock ~1 64 0 bedrock 8 | setblock ~-1 64 0 bedrock 9 | setblock ~ 64 1 bedrock 10 | setblock ~ 64 -1 bedrock 11 | 12 | execute store success score $success dist_mem run clone -3 0 -3 3 255 3 -3 0 -3 filtered minecraft:end_portal move 13 | 14 | execute if score $success dist_mem matches 0 run setblock ~ 64 0 air 15 | execute unless score $success dist_mem matches 0 run setblock ~ 64 0 end_portal 16 | -------------------------------------------------------------------------------- /data/distancing/functions/check_x.mcfunction: -------------------------------------------------------------------------------- 1 | # Check a player's x value 2 | 3 | execute store result score $x dist_mem run data get entity @s Pos[0] 10 4 | scoreboard players operation $linex dist_mem = @s dist_x 5 | scoreboard players operation $linex dist_mem *= $10 dist_x 6 | scoreboard players operation $linex dist_mem += $5 dist_x 7 | scoreboard players operation $x dist_mem -= $linex dist_mem 8 | 9 | execute if score $x dist_mem matches 40.. run function distancing:move_to_line 10 | execute if score $x dist_mem matches ..-40 run function distancing:move_to_line 11 | 12 | # Re-run the entire thing to see if player is still far away 13 | execute store result score $x dist_mem run data get entity @s Pos[0] 100 14 | scoreboard players operation $linex dist_mem = @s dist_x 15 | scoreboard players operation $linex dist_mem *= $100 dist_x 16 | scoreboard players operation $linex dist_mem += $75 dist_x 17 | scoreboard players operation $x dist_mem -= $linex dist_mem 18 | 19 | execute if score $x dist_mem matches 800..1599 at @s run tp @s ~-8 ~ ~ 20 | execute if score $x dist_mem matches 800..1599 run scoreboard players remove $x dist_mem 800 21 | execute if score $x dist_mem matches 400..799 at @s run tp @s ~-4 ~ ~ 22 | execute if score $x dist_mem matches 400..799 run scoreboard players remove $x dist_mem 400 23 | execute if score $x dist_mem matches 200..399 at @s run tp @s ~-2 ~ ~ 24 | execute if score $x dist_mem matches 200..399 run scoreboard players remove $x dist_mem 200 25 | execute if score $x dist_mem matches 100..199 at @s run tp @s ~-1 ~ ~ 26 | execute if score $x dist_mem matches 100..199 run scoreboard players remove $x dist_mem 100 27 | execute if score $x dist_mem matches 50..99 at @s run tp @s ~-0.5 ~ ~ 28 | execute if score $x dist_mem matches 50..99 run scoreboard players remove $x dist_mem 50 29 | execute if score $x dist_mem matches 25..49 at @s run tp @s ~-0.25 ~ ~ 30 | execute if score $x dist_mem matches 25..49 run scoreboard players remove $x dist_mem 25 31 | execute if score $x dist_mem matches 12..24 at @s run tp @s ~-0.12 ~ ~ 32 | execute if score $x dist_mem matches 12..24 run scoreboard players remove $x dist_mem 12 33 | execute if score $x dist_mem matches 6..11 at @s run tp @s ~-0.06 ~ ~ 34 | execute if score $x dist_mem matches 6..11 run scoreboard players remove $x dist_mem 6 35 | execute if score $x dist_mem matches 3..5 at @s run tp @s ~-0.03 ~ ~ 36 | execute if score $x dist_mem matches 3..5 run scoreboard players remove $x dist_mem 3 37 | execute if score $x dist_mem matches 1..2 at @s run tp @s ~-0.01 ~ ~ 38 | execute if score $x dist_mem matches 1..2 run scoreboard players remove $x dist_mem 1 39 | 40 | execute store result score $x dist_mem run data get entity @s Pos[0] 100 41 | scoreboard players operation $linex dist_mem = @s dist_x 42 | scoreboard players operation $linex dist_mem *= $100 dist_x 43 | scoreboard players operation $linex dist_mem += $25 dist_x 44 | scoreboard players operation $x dist_mem -= $linex dist_mem 45 | 46 | execute if score $x dist_mem matches -1599..-800 at @s run tp @s ~8 ~ ~ 47 | execute if score $x dist_mem matches -1599..-800 run scoreboard players add $x dist_mem 800 48 | execute if score $x dist_mem matches -799..-400 at @s run tp @s ~4 ~ ~ 49 | execute if score $x dist_mem matches -799..-400 run scoreboard players add $x dist_mem 400 50 | execute if score $x dist_mem matches -399..-200 at @s run tp @s ~2 ~ ~ 51 | execute if score $x dist_mem matches -399..-200 run scoreboard players add $x dist_mem 200 52 | execute if score $x dist_mem matches -199..-100 at @s run tp @s ~1 ~ ~ 53 | execute if score $x dist_mem matches -199..-100 run scoreboard players add $x dist_mem 100 54 | execute if score $x dist_mem matches -99..-50 at @s run tp @s ~0.5 ~ ~ 55 | execute if score $x dist_mem matches -99..-50 run scoreboard players add $x dist_mem 50 56 | execute if score $x dist_mem matches -49..-25 at @s run tp @s ~0.25 ~ ~ 57 | execute if score $x dist_mem matches -49..-25 run scoreboard players add $x dist_mem 25 58 | execute if score $x dist_mem matches -24..-12 at @s run tp @s ~0.12 ~ ~ 59 | execute if score $x dist_mem matches -24..-12 run scoreboard players add $x dist_mem 12 60 | execute if score $x dist_mem matches -11..-6 at @s run tp @s ~0.06 ~ ~ 61 | execute if score $x dist_mem matches -11..-6 run scoreboard players add $x dist_mem 6 62 | execute if score $x dist_mem matches -5..-3 at @s run tp @s ~0.03 ~ ~ 63 | execute if score $x dist_mem matches -5..-3 run scoreboard players add $x dist_mem 3 64 | execute if score $x dist_mem matches -2..-1 at @s run tp @s ~0.01 ~ ~ 65 | execute if score $x dist_mem matches -2..-1 run scoreboard players add $x dist_mem 1 66 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_1.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 2.. run scoreboard players remove $fortress_copy dist_mem 2 2 | 3 | execute if score $fortress_copy dist_mem matches 1.. positioned ~ ~ ~1 if block ~ 0 ~ bedrock run function distancing:place_fortress 4 | execute unless score $fortress_copy dist_mem matches 1.. if block ~ 0 ~ bedrock run function distancing:place_fortress 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_128.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 256.. run scoreboard players remove $fortress_copy dist_mem 256 2 | 3 | execute unless score $fortress_copy dist_mem matches 128.. run function distancing:find_fortress_64 4 | execute if score $fortress_copy dist_mem matches 128.. positioned ~ ~ ~128 run function distancing:find_fortress_64 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_16.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 32.. run scoreboard players remove $fortress_copy dist_mem 32 2 | 3 | execute unless score $fortress_copy dist_mem matches 16.. run function distancing:find_fortress_8 4 | execute if score $fortress_copy dist_mem matches 16.. positioned ~ ~ ~16 run function distancing:find_fortress_8 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_2.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 4.. run scoreboard players remove $fortress_copy dist_mem 4 2 | 3 | execute unless score $fortress_copy dist_mem matches 2.. run function distancing:find_fortress_1 4 | execute if score $fortress_copy dist_mem matches 2.. positioned ~ ~ ~2 run function distancing:find_fortress_1 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_256.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 512.. run scoreboard players remove $fortress_copy dist_mem 512 2 | 3 | execute unless score $fortress_copy dist_mem matches 256.. run function distancing:find_fortress_128 4 | execute if score $fortress_copy dist_mem matches 256.. positioned ~ ~ ~256 run function distancing:find_fortress_128 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_32.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 64.. run scoreboard players remove $fortress_copy dist_mem 64 2 | 3 | execute unless score $fortress_copy dist_mem matches 32.. run function distancing:find_fortress_16 4 | execute if score $fortress_copy dist_mem matches 32.. positioned ~ ~ ~32 run function distancing:find_fortress_16 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_4.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 8.. run scoreboard players remove $fortress_copy dist_mem 8 2 | 3 | execute unless score $fortress_copy dist_mem matches 4.. run function distancing:find_fortress_2 4 | execute if score $fortress_copy dist_mem matches 4.. positioned ~ ~ ~4 run function distancing:find_fortress_2 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_512.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 1024.. run scoreboard players remove $fortress_copy dist_mem 1024 2 | 3 | execute unless score $fortress_copy dist_mem matches 512.. run function distancing:find_fortress_256 4 | execute if score $fortress_copy dist_mem matches 512.. positioned ~ ~ ~512 run function distancing:find_fortress_256 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_64.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 128.. run scoreboard players remove $fortress_copy dist_mem 128 2 | 3 | execute unless score $fortress_copy dist_mem matches 64.. run function distancing:find_fortress_32 4 | execute if score $fortress_copy dist_mem matches 64.. positioned ~ ~ ~64 run function distancing:find_fortress_32 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_8.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $fortress_copy dist_mem matches 16.. run scoreboard players remove $fortress_copy dist_mem 16 2 | 3 | execute unless score $fortress_copy dist_mem matches 8.. run function distancing:find_fortress_4 4 | execute if score $fortress_copy dist_mem matches 8.. positioned ~ ~ ~8 run function distancing:find_fortress_4 5 | -------------------------------------------------------------------------------- /data/distancing/functions/find_fortress_negative.mcfunction: -------------------------------------------------------------------------------- 1 | # If position is < 0, move start to lowest possible (-2047) and "bitwise invert" score 2 | 3 | scoreboard players add $fortress_copy dist_mem 2047 4 | 5 | execute unless score $fortress_copy dist_mem matches 1024.. positioned ~ ~ -2047 run function distancing:find_fortress_512 6 | execute if score $fortress_copy dist_mem matches 1024.. positioned ~ ~ -1023 run function distancing:find_fortress_512 7 | -------------------------------------------------------------------------------- /data/distancing/functions/load.mcfunction: -------------------------------------------------------------------------------- 1 | # Set up scoreboard 2 | 3 | scoreboard objectives add dist_x dummy "Player X" 4 | scoreboard objectives add dist_mem dummy "Memory" 5 | scoreboard objectives add dist_eyes dummy "Eyes in Portal" 6 | scoreboard objectives add dist_used_eye minecraft.used:minecraft.ender_eye "Eye Used" 7 | scoreboard objectives add dist_dimension dummy "Dimension" 8 | 9 | scoreboard players set $-1 dist_x -1 10 | scoreboard players set $2 dist_x 2 11 | scoreboard players set $5 dist_x 5 12 | scoreboard players set $10 dist_x 10 13 | scoreboard players set $25 dist_x 25 14 | scoreboard players set $50 dist_x 50 15 | scoreboard players set $75 dist_x 75 16 | scoreboard players set $100 dist_x 100 17 | scoreboard players add $Next dist_x 0 18 | execute if score $Next dist_x matches 0 run scoreboard players set $Next dist_x 4 19 | scoreboard players set $start dist_eyes 1 20 | scoreboard players set $initialized dist_mem 1 21 | 22 | scoreboard players add $fortress dist_mem 0 23 | execute if score $fortress dist_mem matches 0 run function distancing:randomize_fortress 24 | 25 | scoreboard objectives add dist_list dummy "Player Lines" 26 | scoreboard objectives setdisplay list dist_list 27 | -------------------------------------------------------------------------------- /data/distancing/functions/make_platform.mcfunction: -------------------------------------------------------------------------------- 1 | # Make a small platform 2 | fill ~-1 ~-1 ~-1 ~1 ~-1 ~1 obsidian 3 | fill ~-1 ~ ~-1 ~1 ~1 ~1 air 4 | -------------------------------------------------------------------------------- /data/distancing/functions/move_dimensions.mcfunction: -------------------------------------------------------------------------------- 1 | # Move to line after switching dimensions 2 | 3 | function distancing:move_to_line 4 | scoreboard players operation $x dist_mem = @s dist_x 5 | execute if score $y dist_mem matches 0 positioned 0.5 ~ ~ run function distancing:platform_r 6 | execute if score $y dist_mem matches 0 positioned 0.5 ~ ~ run function distancing:move_to_line 7 | -------------------------------------------------------------------------------- /data/distancing/functions/move_project.mcfunction: -------------------------------------------------------------------------------- 1 | # Load the current area, then run move_project_r 2 | forceload add ~ ~ 3 | function distancing:move_project_r 4 | -------------------------------------------------------------------------------- /data/distancing/functions/move_project_r.mcfunction: -------------------------------------------------------------------------------- 1 | # Project downwards until we find a non-air and an air block, then tp 2 | # Very inaccurate, maybe good enough. This is a kind-of spreadplayers that is guaranteed to not move in x or z 3 | 4 | scoreboard players remove $y dist_mem 1 5 | execute store success score $found dist_mem if block ~ ~ ~ #distancing:air if block ~ ~1 ~ #distancing:air unless block ~ ~-1 ~ #distancing:nonbase 6 | execute if score $found dist_mem matches 1 run tp @s ~ ~ ~ 7 | execute if score $y dist_mem matches 1.. unless score $found dist_mem matches 1 positioned ~ ~-1 ~ run function distancing:move_project 8 | -------------------------------------------------------------------------------- /data/distancing/functions/move_r.mcfunction: -------------------------------------------------------------------------------- 1 | # Find an x value and tp 2 | 3 | scoreboard players set $step dist_mem 0 4 | execute if score $x dist_mem matches 16.. run scoreboard players set $step dist_mem 16 5 | execute if score $x dist_mem matches 1..15 run scoreboard players set $step dist_mem 1 6 | execute if score $x dist_mem matches 0 positioned ~ 255 ~ run function distancing:move_project 7 | execute if score $x dist_mem matches -15..-1 run scoreboard players set $step dist_mem -1 8 | execute if score $x dist_mem matches ..-16 run scoreboard players set $step dist_mem -16 9 | 10 | scoreboard players operation $x dist_mem -= $step dist_mem 11 | execute if score $step dist_mem matches 16 positioned ~16 ~ ~ run function distancing:move_r 12 | execute if score $step dist_mem matches 1 positioned ~1 ~ ~ run function distancing:move_r 13 | execute if score $step dist_mem matches -1 positioned ~-1 ~ ~ run function distancing:move_r 14 | execute if score $step dist_mem matches -16 positioned ~-16 ~ ~ run function distancing:move_r 15 | -------------------------------------------------------------------------------- /data/distancing/functions/move_to_line.mcfunction: -------------------------------------------------------------------------------- 1 | # Run a tp command onto a player's x line, after finding a suitable space 2 | 3 | scoreboard players operation $x dist_mem = @s dist_x 4 | scoreboard players set $y dist_mem 255 5 | execute positioned 0.5 ~ ~ run function distancing:move_r 6 | scoreboard players reset $x dist_mem 7 | scoreboard players reset $step dist_mem 8 | scoreboard players reset $found dist_mem 9 | -------------------------------------------------------------------------------- /data/distancing/functions/place_fortress.mcfunction: -------------------------------------------------------------------------------- 1 | # Place a fortress segment 2 | 3 | tag @s add dist_has_fortress 4 | summon area_effect_cloud ~ 60 ~ {Tags:["dist_fortress"], Age:-2147483648, Duration:-1, WaitTime:-2147483648} 5 | 6 | fill ~-5 10 ~-2 ~5 59 ~2 nether_bricks 7 | fill ~-5 60 ~-2 ~5 60 ~-2 nether_bricks 8 | fill ~-5 60 ~2 ~5 60 ~2 nether_bricks 9 | -------------------------------------------------------------------------------- /data/distancing/functions/platform_r.mcfunction: -------------------------------------------------------------------------------- 1 | # Find an x value and create platform 2 | 3 | scoreboard players set $step dist_mem 0 4 | execute if score $x dist_mem matches 16.. run scoreboard players set $step dist_mem 16 5 | execute if score $x dist_mem matches 1..15 run scoreboard players set $step dist_mem 1 6 | execute if score $x dist_mem matches 0 run function distancing:make_platform 7 | execute if score $x dist_mem matches -15..-1 run scoreboard players set $step dist_mem -1 8 | execute if score $x dist_mem matches ..-16 run scoreboard players set $step dist_mem -16 9 | 10 | scoreboard players operation $x dist_mem -= $step dist_mem 11 | execute if score $step dist_mem matches 16 positioned ~16 ~ ~ run function distancing:platform_r 12 | execute if score $step dist_mem matches 1 positioned ~1 ~ ~ run function distancing:platform_r 13 | execute if score $step dist_mem matches -1 positioned ~-1 ~ ~ run function distancing:platform_r 14 | execute if score $step dist_mem matches -16 positioned ~-16 ~ ~ run function distancing:platform_r 15 | -------------------------------------------------------------------------------- /data/distancing/functions/portal.mcfunction: -------------------------------------------------------------------------------- 1 | # Make and sync portals 2 | 3 | scoreboard players add @s dist_eyes 0 4 | execute if score @s dist_eyes matches 0 store success score $loaded dist_mem if block ~ -64 ~ bedrock 5 | 6 | execute if score @s dist_eyes matches 0 if score $loaded dist_mem matches 1 run fill ~-3 ~-1 ~-3 ~3 ~3 ~3 air 7 | execute if score @s dist_eyes matches 0 if score $loaded dist_mem matches 1 run function distancing:sync_portal 8 | 9 | execute if score @s dist_used_eye matches 1.. if score $loaded dist_mem matches 1 run function distancing:read_portal 10 | 11 | scoreboard players operation $max dist_eyes > * dist_eyes 12 | execute if score $loaded dist_mem matches 1 if score @s dist_eyes < $max dist_eyes run function distancing:sync_portal 13 | -------------------------------------------------------------------------------- /data/distancing/functions/portal_r.mcfunction: -------------------------------------------------------------------------------- 1 | # Find an x value and run portal function 2 | 3 | scoreboard players set $step dist_mem 0 4 | execute if score $x dist_mem matches 16.. run scoreboard players set $step dist_mem 16 5 | execute if score $x dist_mem matches 1..15 run scoreboard players set $step dist_mem 1 6 | execute if score $x dist_mem matches 0 positioned ~ 25 ~ run function distancing:portal 7 | execute if score $x dist_mem matches -15..-1 run scoreboard players set $step dist_mem -1 8 | execute if score $x dist_mem matches ..-16 run scoreboard players set $step dist_mem -16 9 | 10 | scoreboard players operation $x dist_mem -= $step dist_mem 11 | execute if score $step dist_mem matches 16 positioned ~16 ~ ~ run function distancing:portal_r 12 | execute if score $step dist_mem matches 1 positioned ~1 ~ ~ run function distancing:portal_r 13 | execute if score $step dist_mem matches -1 positioned ~-1 ~ ~ run function distancing:portal_r 14 | execute if score $step dist_mem matches -16 positioned ~-16 ~ ~ run function distancing:portal_r 15 | -------------------------------------------------------------------------------- /data/distancing/functions/pre_tick.mcfunction: -------------------------------------------------------------------------------- 1 | execute if score $initialized dist_mem matches 1 run function distancing:tick 2 | -------------------------------------------------------------------------------- /data/distancing/functions/randomize_bit.mcfunction: -------------------------------------------------------------------------------- 1 | scoreboard players operation $fortress dist_mem *= $2 dist_x 2 | execute as @e[tag=dist_rand,limit=1,sort=random] run scoreboard players operation $fortress dist_mem += @s dist_mem 3 | -------------------------------------------------------------------------------- /data/distancing/functions/randomize_fortress.mcfunction: -------------------------------------------------------------------------------- 1 | # Randomize a position of the fortress between -2048 and 2048 2 | 3 | summon armor_stand ~ ~ ~ {Tags:["dist_rand"]} 4 | scoreboard players add @e[tag=dist_rand] dist_mem 1 5 | summon armor_stand ~ ~ ~ {Tags:["dist_rand"]} 6 | scoreboard players add @e[tag=dist_rand] dist_mem 0 7 | 8 | scoreboard players set $fortress dist_mem 0 9 | 10 | execute as @e[tag=dist_rand,limit=1,sort=random] run scoreboard players operation $fortress dist_mem += @s dist_mem 11 | function distancing:randomize_bit 12 | function distancing:randomize_bit 13 | function distancing:randomize_bit 14 | function distancing:randomize_bit 15 | function distancing:randomize_bit 16 | function distancing:randomize_bit 17 | function distancing:randomize_bit 18 | function distancing:randomize_bit 19 | function distancing:randomize_bit 20 | function distancing:randomize_bit 21 | execute as @e[tag=dist_rand,limit=1,sort=random] if score @s dist_mem matches 1 run scoreboard players operation $fortress dist_mem *= $-1 dist_x 22 | 23 | kill @e[tag=dist_rand] 24 | 25 | execute if score $fortress dist_mem matches -512..512 run function distancing:randomize_fortress 26 | -------------------------------------------------------------------------------- /data/distancing/functions/read_portal.mcfunction: -------------------------------------------------------------------------------- 1 | # Read a portal's eyes for a player 2 | 3 | scoreboard players set $eyes dist_mem 0 4 | 5 | execute positioned ~2 ~ ~1 run function distancing:read_portal_frame 6 | execute positioned ~2 ~ ~ run function distancing:read_portal_frame 7 | execute positioned ~2 ~ ~-1 run function distancing:read_portal_frame 8 | execute positioned ~1 ~ ~2 run function distancing:read_portal_frame 9 | execute positioned ~ ~ ~2 run function distancing:read_portal_frame 10 | execute positioned ~-1 ~ ~2 run function distancing:read_portal_frame 11 | execute positioned ~-2 ~ ~1 run function distancing:read_portal_frame 12 | execute positioned ~-2 ~ ~ run function distancing:read_portal_frame 13 | execute positioned ~-2 ~ ~-1 run function distancing:read_portal_frame 14 | execute positioned ~1 ~ ~-2 run function distancing:read_portal_frame 15 | execute positioned ~ ~ ~-2 run function distancing:read_portal_frame 16 | execute positioned ~-1 ~ ~-2 run function distancing:read_portal_frame 17 | 18 | scoreboard players operation @s dist_eyes = $eyes dist_mem 19 | scoreboard players reset @s dist_used_eye 20 | -------------------------------------------------------------------------------- /data/distancing/functions/read_portal_frame.mcfunction: -------------------------------------------------------------------------------- 1 | execute store result score $eye dist_mem if block ~ ~ ~ end_portal_frame[eye=true] 2 | scoreboard players operation $eyes dist_mem *= $2 dist_x 3 | scoreboard players operation $eyes dist_mem += $eye dist_mem 4 | -------------------------------------------------------------------------------- /data/distancing/functions/set_eye.mcfunction: -------------------------------------------------------------------------------- 1 | # Set an eye of ender to always go towards 0 on the current line 2 | 3 | # Read current data 4 | execute store result score $z dist_mem run data get entity @s Pos[2] 1000 5 | execute store result score $dy dist_mem run data get entity @s Motion[1] 1000 6 | 7 | # Clear X motion 8 | data modify entity @s Motion[0] set value 0.0d 9 | 10 | # Figure out sign of new Z motion 11 | execute if score $z dist_mem matches 0.. run scoreboard players operation $dy dist_mem *= $-1 dist_x 12 | 13 | # 0 out motion if near 0 14 | execute if score $z dist_mem matches -8000..24000 run scoreboard players set $dy dist_mem 0 15 | 16 | # Set new motion 17 | execute store result entity @s Motion[2] double 0.001 run scoreboard players get $dy dist_mem 18 | -------------------------------------------------------------------------------- /data/distancing/functions/set_portal_frame.mcfunction: -------------------------------------------------------------------------------- 1 | # Place one portal frame facing south 2 | 3 | scoreboard players operation $eye dist_mem = $eyes dist_mem 4 | scoreboard players operation $eye dist_mem %= $2 dist_x 5 | scoreboard players operation $eyes dist_mem /= $2 dist_x 6 | 7 | execute if score $dir dist_mem matches 0 if score $eye dist_mem matches 0 run setblock ~ ~ ~ end_portal_frame[eye=false,facing=south] 8 | execute if score $dir dist_mem matches 0 if score $eye dist_mem matches 1 run setblock ~ ~ ~ end_portal_frame[eye=true,facing=south] 9 | 10 | execute if score $dir dist_mem matches 1 if score $eye dist_mem matches 0 run setblock ~ ~ ~ end_portal_frame[eye=false,facing=east] 11 | execute if score $dir dist_mem matches 1 if score $eye dist_mem matches 1 run setblock ~ ~ ~ end_portal_frame[eye=true,facing=east] 12 | 13 | execute if score $dir dist_mem matches 2 if score $eye dist_mem matches 0 run setblock ~ ~ ~ end_portal_frame[eye=false,facing=north] 14 | execute if score $dir dist_mem matches 2 if score $eye dist_mem matches 1 run setblock ~ ~ ~ end_portal_frame[eye=true,facing=north] 15 | 16 | execute if score $dir dist_mem matches 3 if score $eye dist_mem matches 0 run setblock ~ ~ ~ end_portal_frame[eye=false,facing=west] 17 | execute if score $dir dist_mem matches 3 if score $eye dist_mem matches 1 run setblock ~ ~ ~ end_portal_frame[eye=true,facing=west] 18 | -------------------------------------------------------------------------------- /data/distancing/functions/spawn_random_fortress_mob.mcfunction: -------------------------------------------------------------------------------- 1 | # Spawn a random fortress mob at ~ ~ ~ (kind of) 2 | 3 | summon area_effect_cloud ~ ~ ~ {Tags:["dist_blaze","dist_random_mob"]} 4 | summon area_effect_cloud ~ ~ ~ {Tags:["dist_skeleton","dist_random_mob"]} 5 | summon area_effect_cloud ~ ~ ~ {Tags:["dist_wither_skeleton","dist_random_mob"]} 6 | 7 | tag @e[tag=dist_random_mob,sort=random,limit=1] add dist_chosen 8 | 9 | execute if entity @e[tag=dist_blaze,tag=dist_chosen] run summon blaze ~ ~ ~ {Tags:["dist_new_spawn"]} 10 | execute if entity @e[tag=dist_skeleton,tag=dist_chosen] run summon skeleton ~ ~ ~ {Tags:["dist_new_spawn"],HandItems:[{id:"bow",Count:1b}]} 11 | execute if entity @e[tag=dist_wither_skeleton,tag=dist_chosen] run summon wither_skeleton ~ ~ ~ {Tags:["dist_new_spawn"],HandItems:[{id:"stone_sword",Count:1b}]} 12 | 13 | spreadplayers ~ ~ 2 2 under 63 false @e[tag=dist_new_spawn] 14 | tag @e[tag=dist_new_spawn] remove dist_new_spawn 15 | 16 | kill @e[tag=dist_random_mob] 17 | scoreboard players set $spawn_tick dist_mem 0 18 | -------------------------------------------------------------------------------- /data/distancing/functions/sync_portal.mcfunction: -------------------------------------------------------------------------------- 1 | # Create a portal for a player 2 | 3 | scoreboard players operation @s dist_eyes > * dist_eyes 4 | scoreboard players operation $eyes dist_mem = @s dist_eyes 5 | 6 | scoreboard players set $dir dist_mem 0 7 | execute positioned ~-1 ~ ~-2 run function distancing:set_portal_frame 8 | execute positioned ~ ~ ~-2 run function distancing:set_portal_frame 9 | execute positioned ~1 ~ ~-2 run function distancing:set_portal_frame 10 | 11 | scoreboard players set $dir dist_mem 1 12 | execute positioned ~-2 ~ ~-1 run function distancing:set_portal_frame 13 | execute positioned ~-2 ~ ~ run function distancing:set_portal_frame 14 | execute positioned ~-2 ~ ~1 run function distancing:set_portal_frame 15 | 16 | scoreboard players set $dir dist_mem 2 17 | execute positioned ~-1 ~ ~2 run function distancing:set_portal_frame 18 | execute positioned ~ ~ ~2 run function distancing:set_portal_frame 19 | execute positioned ~1 ~ ~2 run function distancing:set_portal_frame 20 | 21 | scoreboard players set $dir dist_mem 3 22 | execute positioned ~2 ~ ~-1 run function distancing:set_portal_frame 23 | execute positioned ~2 ~ ~ run function distancing:set_portal_frame 24 | execute positioned ~2 ~ ~1 run function distancing:set_portal_frame 25 | 26 | execute if score @s dist_eyes matches 4095 run fill ~-1 ~ ~-1 ~1 ~ ~1 end_portal 27 | -------------------------------------------------------------------------------- /data/distancing/functions/tick.mcfunction: -------------------------------------------------------------------------------- 1 | # Every tick 2 | 3 | execute as @a[gamemode=!spectator,tag=!dist_set] run function distancing:assign 4 | function distancing:check_dimensions 5 | execute as @a[gamemode=!spectator] at @s run function distancing:check_x 6 | execute as @e[type=ender_pearl] run data modify entity @s Motion[0] set value 0.0d 7 | 8 | execute as @a run function distancing:try_make_portal 9 | execute as @a[gamemode=!spectator,scores={dist_dimension=1}] at @s run function distancing:check_end_exits 10 | forceload remove all 11 | 12 | execute as @a run scoreboard players operation @s dist_list = @s dist_x 13 | 14 | execute as @e[type=eye_of_ender] run function distancing:set_eye 15 | 16 | execute as @a[gamemode=!spectator,scores={dist_dimension=-1},tag=!dist_has_fortress] at @s run function distancing:try_place_fortress 17 | 18 | scoreboard players add $spawn_tick dist_mem 1 19 | execute if score $spawn_tick dist_mem matches 1200.. at @e[type=area_effect_cloud,tag=dist_fortress,sort=random,limit=1] if entity @a[gamemode=!spectator,distance=..120,limit=1] unless entity @a[gamemode=!spectator,distance=..20,limit=1] run function distancing:spawn_random_fortress_mob 20 | -------------------------------------------------------------------------------- /data/distancing/functions/try_make_portal.mcfunction: -------------------------------------------------------------------------------- 1 | # Try to make a portal at x, 0 for a given player 2 | 3 | scoreboard players operation $x dist_mem = @s dist_x 4 | execute positioned 0.5 ~ 8 run function distancing:portal_r 5 | -------------------------------------------------------------------------------- /data/distancing/functions/try_place_fortress.mcfunction: -------------------------------------------------------------------------------- 1 | # Find the fortress location and try to place a portal there 2 | 3 | scoreboard players operation $fortress_copy dist_mem = $fortress dist_mem 4 | 5 | execute if score $fortress_copy dist_mem matches 0..1023 positioned ~ ~ 0 run function distancing:find_fortress_512 6 | execute if score $fortress_copy dist_mem matches 1024.. positioned ~ ~ 1024 run function distancing:find_fortress_512 7 | execute if score $fortress_copy dist_mem matches ..-1 run function distancing:find_fortress_negative 8 | -------------------------------------------------------------------------------- /data/distancing/tags/blocks/air.json: -------------------------------------------------------------------------------- 1 | { 2 | "replace": false, 3 | "values": [ 4 | "minecraft:air", 5 | "minecraft:cave_air", 6 | "minecraft:void_air" 7 | ] 8 | } -------------------------------------------------------------------------------- /data/distancing/tags/blocks/nonbase.json: -------------------------------------------------------------------------------- 1 | { 2 | "replace": false, 3 | "values": [ 4 | "minecraft:air", 5 | "minecraft:cave_air", 6 | "minecraft:void_air", 7 | "minecraft:bedrock", 8 | "minecraft:lava", 9 | "#minecraft:fire", 10 | "#minecraft:campfires", 11 | "minecraft:magma_block" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /data/minecraft/tags/functions/load.json: -------------------------------------------------------------------------------- 1 | { 2 | "replace": false, 3 | "values": [ 4 | "distancing:load" 5 | ] 6 | } -------------------------------------------------------------------------------- /data/minecraft/tags/functions/tick.json: -------------------------------------------------------------------------------- 1 | { 2 | "replace": false, 3 | "values": [ 4 | "distancing:pre_tick" 5 | ] 6 | } -------------------------------------------------------------------------------- /pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 9, 4 | "description": "Social Distancing" 5 | } 6 | } 7 | --------------------------------------------------------------------------------