Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added gm4_timelines/README.md
Empty file.
25 changes: 25 additions & 0 deletions gm4_timelines/beet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
id: gm4_timelines
name: Timelines
version: 1.0.X

data_pack:
load: .

require:
- gm4_timelines.plugins.generate

pipeline:
- gm4.plugins.extend.module

meta:
gm4:
versioning:
schedule_loops: [main]
website:
description: Timelines!
video: null
wiki: https://wiki.gm4.co/wiki/Timelines
credits:
Creator:
- Djones
- Kyrius
21 changes: 21 additions & 0 deletions gm4_timelines/data/gm4_timelines/function/init.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
execute unless score timelines gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Timelines"}
execute unless score timelines gm4_earliest_version < timelines gm4_modules run scoreboard players operation timelines gm4_earliest_version = timelines gm4_modules
scoreboard players set timelines gm4_modules 1

scoreboard objectives add gm4_timelines.data dummy

scoreboard players set #8 gm4_timelines.data 8
scoreboard players set #24000 gm4_timelines.data 24000

gamerule advance_weather false

function gm4_timelines:register/days
execute store result score #day.offset gm4_timelines.data run data get storage gm4_timelines:data day_data.offset
execute store result score #day.duration gm4_timelines.data run data get storage gm4_timelines:data day_data.duration

# TODO: only run this when needed, it resets everything to day 0
function gm4_timelines:reset

schedule function gm4_timelines:main 1t

#$moduleUpdateList
14 changes: 14 additions & 0 deletions gm4_timelines/data/gm4_timelines/function/main.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
schedule function gm4_timelines:main 1t

execute store result score $day.real gm4_timelines.data run time query day
execute store result score $daytime.real gm4_timelines.data run time query daytime

scoreboard players operation $day.current gm4_timelines.data = $day.real gm4_timelines.data
scoreboard players operation $day.current gm4_timelines.data *= #24000 gm4_timelines.data
scoreboard players operation $day.current gm4_timelines.data += $daytime.real gm4_timelines.data
scoreboard players operation $day.current gm4_timelines.data -= #day.offset gm4_timelines.data
scoreboard players operation $daytime.current gm4_timelines.data = $day.current gm4_timelines.data
scoreboard players operation $day.current gm4_timelines.data /= #day.duration gm4_timelines.data
scoreboard players operation $daytime.current gm4_timelines.data %= #day.duration gm4_timelines.data

execute unless score $day.active gm4_timelines.data = $day.current gm4_timelines.data run function gm4_timelines:pick_day/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

$execute store result score $picked_weight gm4_timelines.data run random value 0..$(max) gm4_timelines:pick_day
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

$data modify storage gm4_timelines:temp possible_days set from storage gm4_timelines:data day_data.registry.$(moon_phase).$(in_type)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

execute store result score $this_weight gm4_timelines.data run data get storage gm4_timelines:temp count_weight[0].weight
scoreboard players operation $total_weight gm4_timelines.data += $this_weight gm4_timelines.data

data remove storage gm4_timelines:temp count_weight[0]
execute if data storage gm4_timelines:temp count_weight[0] run function gm4_timelines:pick_day/build_dayline/loop_count_weights
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

# check moon cycle
scoreboard players operation $moon_cycle gm4_timelines.data = $last_build_day gm4_timelines.data
scoreboard players operation $moon_cycle gm4_timelines.data %= #8 gm4_timelines.data
execute if score $moon_cycle gm4_timelines.data matches 0 run data modify storage gm4_timelines:temp looking_for set value {moon_phase:"full_moon",in_type:"clear"}
execute if score $moon_cycle gm4_timelines.data matches 1 run data modify storage gm4_timelines:temp looking_for set value {moon_phase:"waning_gibbous",in_type:"clear"}
execute if score $moon_cycle gm4_timelines.data matches 2 run data modify storage gm4_timelines:temp looking_for set value {moon_phase:"third_quarter",in_type:"clear"}
execute if score $moon_cycle gm4_timelines.data matches 3 run data modify storage gm4_timelines:temp looking_for set value {moon_phase:"waning_crescent",in_type:"clear"}
execute if score $moon_cycle gm4_timelines.data matches 4 run data modify storage gm4_timelines:temp looking_for set value {moon_phase:"new_moon",in_type:"clear"}
execute if score $moon_cycle gm4_timelines.data matches 5 run data modify storage gm4_timelines:temp looking_for set value {moon_phase:"waxing_crescent",in_type:"clear"}
execute if score $moon_cycle gm4_timelines.data matches 6 run data modify storage gm4_timelines:temp looking_for set value {moon_phase:"first_quarter",in_type:"clear"}
execute if score $moon_cycle gm4_timelines.data matches 7 run data modify storage gm4_timelines:temp looking_for set value {moon_phase:"waxing_gibbous",in_type:"clear"}
# check required in_type
data modify storage gm4_timelines:temp looking_for.in_type set from storage gm4_timelines:data active_day.out_type
# get possible days
function gm4_timelines:pick_day/build_dayline/eval_possible_days with storage gm4_timelines:temp looking_for
data remove storage gm4_timelines:temp looking_for

# get the total weight of all entries
scoreboard players set $total_weight gm4_timelines.data 0
data modify storage gm4_timelines:temp count_weight set from storage gm4_timelines:temp possible_days
function gm4_timelines:pick_day/build_dayline/loop_count_weights
data remove storage gm4_timelines:temp count_weight

# get a random weight between 0 and total weight
execute store result storage gm4_timelines:temp rng.max int 1 run scoreboard players get $total_weight gm4_timelines.data
function gm4_timelines:pick_day/build_dayline/eval_pick_weight with storage gm4_timelines:temp rng
data remove storage gm4_timelines:temp rng

# loop to get the picked day and add it to they dayline
execute if score $picked_weight gm4_timelines.data matches 1.. run function gm4_timelines:pick_day/build_dayline/loop_to_picked_day
data modify storage gm4_timelines:data dayline append from storage gm4_timelines:temp possible_days[0]
data remove storage gm4_timelines:temp possible_days

# continue doing this until we get to the desired day
scoreboard players add $last_build_day gm4_timelines.data 1
scoreboard players remove $days_forward gm4_timelines.data 1
execute if score $days_forward gm4_timelines.data matches 1.. run function gm4_timelines:pick_day/build_dayline/loop_run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

execute store result score $this_weight gm4_timelines.data run data get storage gm4_timelines:temp possible_days[0].weight
scoreboard players operation $picked_weight gm4_timelines.data -= $this_weight gm4_timelines.data

execute if score $picked_weight gm4_timelines.data matches ..0 run return 1

data remove storage gm4_timelines:temp possible_days[0]
execute if data storage gm4_timelines:temp possible_days[0] run function gm4_timelines:pick_day/build_dayline/loop_to_picked_day
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# data modify storage gm4_timelines:data active_day set from storage gm4_timelines:data day_registry[0]
tellraw @a [{text:"[GM4 Timelines] ",color:"#4AA0C7"},{text:"No valid day found!",color:"red"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# first get the last day in the build timeline
execute store result score $last_build_day gm4_timelines.data run data get storage gm4_timelines:data dayline

# check how many days should be build
scoreboard players operation $days_forward gm4_timelines.data = $index_change gm4_timelines.data

# build at most 32 days
execute if score $days_forward gm4_timelines.data matches 32.. run tellraw @a [{text:"[GM4 Timelines] ",color:"#4AA0C7"},{text:"Could only move 32 days into the future",color:"red"}]
execute if score $days_forward gm4_timelines.data matches 32.. run scoreboard players set $index_change gm4_timelines.data 32
execute if score $days_forward gm4_timelines.data matches 32.. run scoreboard players set $days_forward gm4_timelines.data 32

# get data from last build day
data modify storage gm4_timelines:data active_day set from storage gm4_timelines:data dayline[-1]

# build the amount of needed days
function gm4_timelines:pick_day/build_dayline/loop_run

# get the last day
data modify storage gm4_timelines:data active_day set from storage gm4_timelines:data dayline[-1]
scoreboard players operation $day.current gm4_timelines.data = $last_build_day gm4_timelines.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

$data modify storage gm4_timelines:data active_day set from storage gm4_timelines:data dayline[$(index)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

$time set $(time)
33 changes: 33 additions & 0 deletions gm4_timelines/data/gm4_timelines/function/pick_day/run.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@


# check how the days have changed
scoreboard players operation $index_change gm4_timelines.data = $day.current gm4_timelines.data
scoreboard players operation $index_change gm4_timelines.data -= $day.active gm4_timelines.data

scoreboard players operation $day_index gm4_timelines.data = $day.game gm4_timelines.data
scoreboard players operation $day_index gm4_timelines.data += $index_change gm4_timelines.data

# check what day index should be used
execute store result storage gm4_timelines:temp day.index int 1 run scoreboard players get $day_index gm4_timelines.data
data remove storage gm4_timelines:data active_day
function gm4_timelines:pick_day/eval_day_from_dayline with storage gm4_timelines:temp day

# if that index does not yet exist try to extend the dayline to it
execute unless data storage gm4_timelines:data active_day run function gm4_timelines:pick_day/build_dayline/run

# move time as needed
execute store result score $set_time gm4_timelines.data run data get storage gm4_timelines:data active_day.start_time
scoreboard players operation $add_time gm4_timelines.data = $daytime.real gm4_timelines.data
scoreboard players operation $add_time gm4_timelines.data -= #day.offset gm4_timelines.data
scoreboard players operation $add_time gm4_timelines.data %= #day.duration gm4_timelines.data
scoreboard players operation $set_time gm4_timelines.data += $add_time gm4_timelines.data
execute store result storage gm4_timelines:temp change.time int 1 run scoreboard players get $set_time gm4_timelines.data
function gm4_timelines:pick_day/eval_time with storage gm4_timelines:temp change
data remove storage gm4_timelines:temp change

# mark this as the active day
execute store result score $day.active gm4_timelines.data run data get storage gm4_timelines:data active_day.start_time
scoreboard players operation $day.active gm4_timelines.data -= #day.offset gm4_timelines.data
scoreboard players operation $day.active gm4_timelines.data /= #day.duration gm4_timelines.data
# move the game day so we remember what day we're actually at
scoreboard players operation $day.game gm4_timelines.data += $index_change gm4_timelines.data
6 changes: 6 additions & 0 deletions gm4_timelines/data/gm4_timelines/function/reset.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# TODO: how does this impact local difficulty?
time set 1
data modify storage gm4_timelines:data dayline set value []
random reset gm4_timelines:pick_day 0 true true
scoreboard players set $day.active gm4_timelines.data -1
65 changes: 65 additions & 0 deletions gm4_timelines/data/minecraft/timeline/early_game.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"tracks": {
"minecraft:gameplay/can_pillager_patrol_spawn": {
"keyframes": [
{
"ticks": 0,
"value": false
},
{
"ticks": 120000,
"value": true
}
],
"modifier": "and"
},
"minecraft:gameplay/bed_rule": {
"modifier": "override",
"keyframes": [
{
"ticks": 0,
"value": {
"can_sleep": "always",
"can_set_spawn": "always"
}
}
]
},
"minecraft:visual/cloud_fog_end_distance": {
"ease": "linear",
"keyframes": [
{
"ticks": 0,
"value": 2048
}
]
},
"minecraft:visual/fog_end_distance": {
"ease": "in_out_sine",
"keyframes": [
{
"ticks": 0,
"value": 1024
}
]
},
"minecraft:visual/fog_start_distance": {
"ease": "in_out_sine",
"keyframes": [
{
"ticks": 0,
"value": 0
}
]
},
"minecraft:visual/sky_fog_end_distance": {
"ease": "in_out_sine",
"keyframes": [
{
"ticks": 0,
"value": 512
}
]
}
}
}
3 changes: 3 additions & 0 deletions gm4_timelines/data/minecraft/timeline/moon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tracks": {}
}
3 changes: 3 additions & 0 deletions gm4_timelines/data/minecraft/timeline/villager_schedule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tracks": {}
}
Loading
Loading