Skip to content

Commit 44ac972

Browse files
committed
update build script
1 parent ac4b972 commit 44ac972

File tree

16 files changed

+738
-230
lines changed

16 files changed

+738
-230
lines changed

gm4_timelines/data/gm4_timelines/function/init.mcfunction

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ execute unless score timelines gm4_modules matches 1 run data modify storage gm4
22
execute unless score timelines gm4_earliest_version < timelines gm4_modules run scoreboard players operation timelines gm4_earliest_version = timelines gm4_modules
33
scoreboard players set timelines gm4_modules 1
44

5-
schedule function gm4_timelines:main 1t
5+
scoreboard objectives add gm4_timelines.data dummy
6+
7+
scoreboard players set #24000 gm4_timelines.data 24000
68

9+
gamerule advance_weather false
710

11+
function gm4_timelines:register/days
12+
13+
schedule function gm4_timelines:main 1t
814

915
#$moduleUpdateList
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
11
schedule function gm4_timelines:main 16t
2+
3+
execute store result score $daytime gm4_timelines.data run time query daytime
4+
execute store result score $day gm4_timelines.data run time query day
5+
scoreboard players operation $current_time gm4_timelines.data = $day gm4_timelines.data
6+
scoreboard players operation $current_time gm4_timelines.data *= #24000 gm4_timelines.data
7+
scoreboard players operation $current_time gm4_timelines.data += $daytime gm4_timelines.data
8+
9+
scoreboard players operation $time_passed gm4_timelines.data = $current_time gm4_timelines.data
10+
scoreboard players operation $time_passed gm4_timelines.data -= $previous_time gm4_timelines.data
11+
12+
scoreboard players operation $previous_time gm4_timelines.data = $current_time gm4_timelines.data
13+
14+
scoreboard players operation $daytime_left gm4_timelines.data -= $time_passed gm4_timelines.data
15+
16+
execute unless score $daytime_left gm4_timelines.data matches 1.. run function gm4_timelines:pick_day/run
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
$time set $(start_time)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
data modify storage gm4_timelines:temp day set from storage gm4_timelines:temp all_days[0]
3+
data remove storage gm4_timelines:temp all_days[0]
4+
5+
# check if this day is possible
6+
execute store result score $allow_day gm4_timelines.data run function gm4_timelines:pick_day/verify with storage gm4_timelines:data last_day
7+
8+
# not possible
9+
execute if score $allow_day gm4_timelines.data matches 0 if data storage gm4_timelines:temp all_days[0] run return run function gm4_timelines:pick_day/loop
10+
execute if score $allow_day gm4_timelines.data matches 0 run return fail
11+
12+
# possible
13+
data modify storage gm4_timelines:temp possible_days append from storage gm4_timelines:temp day
14+
execute store result score $this_weight gm4_timelines.data run data get storage gm4_timelines:temp day.weight
15+
scoreboard players operation $total_weight gm4_timelines.data += $this_weight gm4_timelines.data
16+
execute if data storage gm4_timelines:temp all_days[0] run function gm4_timelines:pick_day/loop
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
data modify storage gm4_timelines:temp picked_day set from storage gm4_timelines:data day_registry[0]
3+
tellraw @a [{text:"[GM4 Timelines] ",color:"#4AA0C7"},{text:"No valid day found, using day 0 as fallback",color:"red"}]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
scoreboard players set $previous_time gm4_timelines.data 0
3+
4+
scoreboard players set $total_weight gm4_timelines.data 0
5+
6+
data modify storage gm4_timelines:temp possible_days set value []
7+
data modify storage gm4_timelines:temp all_days set from storage gm4_timelines:data day_registry
8+
9+
function gm4_timelines:pick_day/loop
10+
11+
# TODO: pick properly
12+
data modify storage gm4_timelines:temp picked_day set from storage gm4_timelines:temp possible_days[0]
13+
execute unless data storage gm4_timelines:temp possible_days[0] run function gm4_timelines:pick_day/no_valid_day
14+
15+
# TODO: do this better
16+
execute if data storage gm4_timelines:temp picked_day{moon_phase:"full_moon"} run data modify storage gm4_timelines:data last_day.next_moon_phase set value "waning_gibbous"
17+
execute if data storage gm4_timelines:temp picked_day{moon_phase:"waning_gibbous"} run data modify storage gm4_timelines:data last_day.next_moon_phase set value "third_quarter"
18+
execute if data storage gm4_timelines:temp picked_day{moon_phase:"third_quarter"} run data modify storage gm4_timelines:data last_day.next_moon_phase set value "waning_crescent"
19+
execute if data storage gm4_timelines:temp picked_day{moon_phase:"waning_crescent"} run data modify storage gm4_timelines:data last_day.next_moon_phase set value "new_moon"
20+
execute if data storage gm4_timelines:temp picked_day{moon_phase:"new_moon"} run data modify storage gm4_timelines:data last_day.next_moon_phase set value "waxing_crescent"
21+
execute if data storage gm4_timelines:temp picked_day{moon_phase:"waxing_crescent"} run data modify storage gm4_timelines:data last_day.next_moon_phase set value "first_quarter"
22+
execute if data storage gm4_timelines:temp picked_day{moon_phase:"first_quarter"} run data modify storage gm4_timelines:data last_day.next_moon_phase set value "waxing_gibbous"
23+
execute if data storage gm4_timelines:temp picked_day{moon_phase:"waxing_gibbous"} run data modify storage gm4_timelines:data last_day.next_moon_phase set value "full_moon"
24+
data modify storage gm4_timelines:data last_day.out_type set from storage gm4_timelines:temp picked_day.out_type
25+
26+
function gm4_timelines:pick_day/eval_day with storage gm4_timelines:temp picked_day
27+
scoreboard players set $daytime_left gm4_timelines.data 72000
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
execute if data storage gm4_timelines:temp day{dev:true} run return 1
3+
4+
$execute unless data storage gm4_timelines:temp day{in_type:$(out_type)} run return 0
5+
6+
$execute unless data storage gm4_timelines:temp day{moon_phase:$(next_moon_phase)} run return 0
7+
8+
return 1

gm4_timelines/data/gm4_timelines/function/test.mcfunction

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"period_ticks": 192000,
3+
"tracks": {}
4+
}

0 commit comments

Comments
 (0)