diff --git a/data/minecraft/tags/functions/load.json b/data/minecraft/tags/functions/load.json new file mode 100644 index 0000000..c9644f3 --- /dev/null +++ b/data/minecraft/tags/functions/load.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "spacefont:load" + ] +} \ No newline at end of file diff --git a/data/spacefont/functions/load.mcfunction b/data/spacefont/functions/load.mcfunction new file mode 100644 index 0000000..30bf08e --- /dev/null +++ b/data/spacefont/functions/load.mcfunction @@ -0,0 +1,3 @@ +# Create scoreboard and intiialize values: +scoreboard objectives add spacefont dummy +scoreboard players set #-1 spacefont -1 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits.mcfunction b/data/spacefont/functions/magic_digits.mcfunction new file mode 100644 index 0000000..26f081d --- /dev/null +++ b/data/spacefont/functions/magic_digits.mcfunction @@ -0,0 +1,38 @@ +# ----------------------- +# Magic Digits Calculator +# ----------------------- +# +# This function will convert a width in the range -6764 .. 6764 to a set of digits. +# When displayed in the extended negative space font, these digits will form a space with the input width. +# +# Input score: width spacefont +# Output score: spacer spacefont +# +# Example usage: +# /scoreboard players set width spacefont -42 +# /function spacefont:magic_digits +# /tellraw @a ["Hello ", {"font": "space:default", "score": {"name": "spacer","objective": "spacefont"}}, " There"] +# +# Example result: "Hello -1123466899 There" but with the score turning into a space of width -42. +# +# Digit sizes (just for reference): +# 9 = 1 +# 8 = 3 +# 7 = 8 +# 6 = 21 +# 5 = 55 +# 4 = 144 +# 3 = 377 +# 2 = 987 +# 1 = 2584 +# - = -6765 +# +# What is this sequence? It is every other Fibonacci number. +# If F(n) is the nth term, all terms before it add up to F(n+1). +# With 9 digits and 10 places to put them we can duplicate one digit. +# This extra capacity means we can skip every other term. +# Does it produce the largest range? No, but it eases scoreboard calculations. + +execute if score width spacefont matches 6765.. run scoreboard players set spacer spacefont 1123456789 +execute if score width spacefont matches ..-6765 run scoreboard players set spacer spacefont -9 +execute if score width spacefont matches -6764..6764 run function spacefont:magic_digits/in_range \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/1_10.mcfunction b/data/spacefont/functions/magic_digits/1_10.mcfunction new file mode 100644 index 0000000..c056434 --- /dev/null +++ b/data/spacefont/functions/magic_digits/1_10.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 1000000000 +scoreboard players remove width spacefont 2584 +execute if score width spacefont matches 2584.. run function spacefont:magic_digits/1_9 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/1_9.mcfunction b/data/spacefont/functions/magic_digits/1_9.mcfunction new file mode 100644 index 0000000..2910057 --- /dev/null +++ b/data/spacefont/functions/magic_digits/1_9.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 100000000 +scoreboard players remove width spacefont 2584 +execute if score width spacefont matches 987.. run function spacefont:magic_digits/2_8 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/2_8.mcfunction b/data/spacefont/functions/magic_digits/2_8.mcfunction new file mode 100644 index 0000000..ccfbd7f --- /dev/null +++ b/data/spacefont/functions/magic_digits/2_8.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 20000000 +scoreboard players remove width spacefont 987 +execute if score width spacefont matches 377.. run function spacefont:magic_digits/3_7 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/2_9.mcfunction b/data/spacefont/functions/magic_digits/2_9.mcfunction new file mode 100644 index 0000000..408d02c --- /dev/null +++ b/data/spacefont/functions/magic_digits/2_9.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 200000000 +scoreboard players remove width spacefont 987 +execute if score width spacefont matches 987.. run function spacefont:magic_digits/2_8 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/3_7.mcfunction b/data/spacefont/functions/magic_digits/3_7.mcfunction new file mode 100644 index 0000000..b1ab030 --- /dev/null +++ b/data/spacefont/functions/magic_digits/3_7.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 3000000 +scoreboard players remove width spacefont 377 +execute if score width spacefont matches 144.. run function spacefont:magic_digits/4_6 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/3_8.mcfunction b/data/spacefont/functions/magic_digits/3_8.mcfunction new file mode 100644 index 0000000..4b70eb6 --- /dev/null +++ b/data/spacefont/functions/magic_digits/3_8.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 30000000 +scoreboard players remove width spacefont 377 +execute if score width spacefont matches 377.. run function spacefont:magic_digits/3_7 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/4_6.mcfunction b/data/spacefont/functions/magic_digits/4_6.mcfunction new file mode 100644 index 0000000..4d38348 --- /dev/null +++ b/data/spacefont/functions/magic_digits/4_6.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 400000 +scoreboard players remove width spacefont 144 +execute if score width spacefont matches 55.. run function spacefont:magic_digits/5_5 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/4_7.mcfunction b/data/spacefont/functions/magic_digits/4_7.mcfunction new file mode 100644 index 0000000..d054971 --- /dev/null +++ b/data/spacefont/functions/magic_digits/4_7.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 4000000 +scoreboard players remove width spacefont 144 +execute if score width spacefont matches 144.. run function spacefont:magic_digits/4_6 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/5_5.mcfunction b/data/spacefont/functions/magic_digits/5_5.mcfunction new file mode 100644 index 0000000..f99321b --- /dev/null +++ b/data/spacefont/functions/magic_digits/5_5.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 50000 +scoreboard players remove width spacefont 55 +execute if score width spacefont matches 21.. run function spacefont:magic_digits/6_4 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/5_6.mcfunction b/data/spacefont/functions/magic_digits/5_6.mcfunction new file mode 100644 index 0000000..927b862 --- /dev/null +++ b/data/spacefont/functions/magic_digits/5_6.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 500000 +scoreboard players remove width spacefont 55 +execute if score width spacefont matches 55.. run function spacefont:magic_digits/5_5 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/6_4.mcfunction b/data/spacefont/functions/magic_digits/6_4.mcfunction new file mode 100644 index 0000000..8113703 --- /dev/null +++ b/data/spacefont/functions/magic_digits/6_4.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 6000 +scoreboard players remove width spacefont 21 +execute if score width spacefont matches 8.. run function spacefont:magic_digits/7_3 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/6_5.mcfunction b/data/spacefont/functions/magic_digits/6_5.mcfunction new file mode 100644 index 0000000..060355b --- /dev/null +++ b/data/spacefont/functions/magic_digits/6_5.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 60000 +scoreboard players remove width spacefont 21 +execute if score width spacefont matches 21.. run function spacefont:magic_digits/6_4 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/7_3.mcfunction b/data/spacefont/functions/magic_digits/7_3.mcfunction new file mode 100644 index 0000000..68a7d9c --- /dev/null +++ b/data/spacefont/functions/magic_digits/7_3.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 700 +scoreboard players remove width spacefont 8 +execute if score width spacefont matches 3.. run function spacefont:magic_digits/8_2 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/7_4.mcfunction b/data/spacefont/functions/magic_digits/7_4.mcfunction new file mode 100644 index 0000000..3d7df87 --- /dev/null +++ b/data/spacefont/functions/magic_digits/7_4.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 7000 +scoreboard players remove width spacefont 8 +execute if score width spacefont matches 8.. run function spacefont:magic_digits/7_3 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/8_2.mcfunction b/data/spacefont/functions/magic_digits/8_2.mcfunction new file mode 100644 index 0000000..550e1f6 --- /dev/null +++ b/data/spacefont/functions/magic_digits/8_2.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 80 +scoreboard players remove width spacefont 3 +execute if score width spacefont matches 1 run function spacefont:magic_digits/9_1 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/8_3.mcfunction b/data/spacefont/functions/magic_digits/8_3.mcfunction new file mode 100644 index 0000000..0d8970d --- /dev/null +++ b/data/spacefont/functions/magic_digits/8_3.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 800 +scoreboard players remove width spacefont 3 +execute if score width spacefont matches 3.. run function spacefont:magic_digits/8_2 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/9_1.mcfunction b/data/spacefont/functions/magic_digits/9_1.mcfunction new file mode 100644 index 0000000..dba3e19 --- /dev/null +++ b/data/spacefont/functions/magic_digits/9_1.mcfunction @@ -0,0 +1,2 @@ +scoreboard players add spacer spacefont 9 +scoreboard players remove width spacefont 1 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/9_2.mcfunction b/data/spacefont/functions/magic_digits/9_2.mcfunction new file mode 100644 index 0000000..7cadde9 --- /dev/null +++ b/data/spacefont/functions/magic_digits/9_2.mcfunction @@ -0,0 +1,3 @@ +scoreboard players add spacer spacefont 90 +scoreboard players remove width spacefont 1 +execute if score width spacefont matches 1 run function spacefont:magic_digits/9_1 \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/debug_list_scores.mcfunction b/data/spacefont/functions/magic_digits/debug_list_scores.mcfunction new file mode 100644 index 0000000..4abb3ef --- /dev/null +++ b/data/spacefont/functions/magic_digits/debug_list_scores.mcfunction @@ -0,0 +1 @@ +tellraw @s [[{"text":"width: ","color":"gold"},{"score":{"name":"width","objective":"spacefont"}}], [{"text":"\nspacer: ","color":"dark_green"}, {"score":{"name":"spacer","objective":"spacefont"}}], [{"text":"\n#is_neg: ","color":"gray"}, {"score":{"name":"#is_neg","objective":"spacefont"}}], [{"text":"\n#-1: ","color":"gray"}, {"score":{"name":"#-1","objective":"spacefont"}}]] \ No newline at end of file diff --git a/data/spacefont/functions/magic_digits/in_range.mcfunction b/data/spacefont/functions/magic_digits/in_range.mcfunction new file mode 100644 index 0000000..0bc04fa --- /dev/null +++ b/data/spacefont/functions/magic_digits/in_range.mcfunction @@ -0,0 +1,16 @@ +scoreboard players set spacer spacefont 0 + +execute store result score #is_neg spacefont if score width spacefont matches ..-1 +execute if score width spacefont matches ..-1 run scoreboard players add width spacefont 6765 + +execute if score width spacefont matches 2584..6764 run function spacefont:magic_digits/1_10 +execute if score width spacefont matches 987..2583 run function spacefont:magic_digits/2_9 +execute if score width spacefont matches 377..986 run function spacefont:magic_digits/3_8 +execute if score width spacefont matches 144..376 run function spacefont:magic_digits/4_7 +execute if score width spacefont matches 55..143 run function spacefont:magic_digits/5_6 +execute if score width spacefont matches 21..54 run function spacefont:magic_digits/6_5 +execute if score width spacefont matches 8..20 run function spacefont:magic_digits/7_4 +execute if score width spacefont matches 3..7 run function spacefont:magic_digits/8_3 +execute if score width spacefont matches 1..2 run function spacefont:magic_digits/9_2 + +execute if score #is_neg spacefont matches 1.. run scoreboard players operation spacer spacefont *= #-1 spacefont \ No newline at end of file