Skip to content

Commit

Permalink
port source code to main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
katelyynn committed Mar 28, 2022
1 parent 38d7061 commit fef0a02
Show file tree
Hide file tree
Showing 27 changed files with 362 additions and 0 deletions.
11 changes: 11 additions & 0 deletions data/lavarising/functions/2teams.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# If 3v3v3 is set to 0 (2 teams)

# Red
execute if score blue alive_players matches ..0 unless score period time matches 3 run function lavarising:red_victory

# Blue
execute if score red alive_players matches ..0 unless score period time matches 3 run function lavarising:blue_victory

# Prevent players from joining Green team
execute if entity @a[team=green] run tellraw @a {"text":"The amount of teams is set to 2, the Green team is reserved for 3 teams only.","color":"red"}
team leave @a[team=green]
10 changes: 10 additions & 0 deletions data/lavarising/functions/3teams.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# If 3v3v3 is set to 1 (3 teams)

# Red
execute if score red alive_players matches 1.. unless score blue alive_players matches 1.. unless score green alive_players matches 1.. unless score period time matches 3 unless score period time matches -1 run function lavarising:red_victory

# Blue
execute if score blue alive_players matches 1.. unless score red alive_players matches 1.. unless score green alive_players matches 1.. unless score period time matches 3 unless score period time matches -1 run function lavarising:blue_victory

# Green
execute if score green alive_players matches 1.. unless score red alive_players matches 1.. unless score blue alive_players matches 1.. unless score period time matches 3 unless score period time matches -1 run function lavarising:green_victory
12 changes: 12 additions & 0 deletions data/lavarising/functions/blue_victory.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
scoreboard players set period time 3

title @a title {"text":"GAME OVER!","color":"aqua","bold":true}
title @a subtitle [{"text":"Blue Team has won the game."}]
execute as @a at @s run playsound minecraft:ui.toast.challenge_complete player @s ~ ~ ~
effect give @a resistance 9999 255 true
execute as @a at @s run summon firework_rocket ~ ~1 ~ {FireworksItem:{id:firework_rocket,Count:1,tag:{Fireworks:{Flight:1,Explosions:[{Type:1,Flicker:0,Trail:0,Colors:[I;2437522],FadeColors:[I;6719955]}]}}}}
gamemode spectator @a

scoreboard players reset red alive_players
scoreboard players reset blue alive_players
scoreboard players reset green alive_players
4 changes: 4 additions & 0 deletions data/lavarising/functions/bossbar.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
execute if score enabled global matches 0 run bossbar set lavarising:status name {"text":"The void is not currently rising!","color":"green"}
bossbar set lavarising:status name [{"score":{"name":"@e[tag=riser,limit=1]","objective":"y"},"bold":true,"color":"red"},{"text":"/","color":"dark_red","bold":false},{"text":"310","color":"red","bold":false}]

bossbar set lavarising:status color red
1 change: 1 addition & 0 deletions data/lavarising/functions/close_border.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worldborder set 80 2350
5 changes: 5 additions & 0 deletions data/lavarising/functions/death.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gamemode spectator @a[scores={death=1..}]
execute as @a[scores={death=1..}] run scoreboard players remove alive alive_players 1
tellraw @a [{"selector":"@a[scores={death=1..}]","color":"red","bold":true},{"text":" has been eliminated!","color":"dark_red","bold":false}]
execute as @a at @s run playsound minecraft:entity.lightning_bolt.thunder player @s
scoreboard players reset @a[scores={death=1..}] death
63 changes: 63 additions & 0 deletions data/lavarising/functions/defaults.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Resets all settings and creates scoreboards

scoreboard players set period time -1
scoreboard players set @a lastlogin -1
scoreboard objectives add lastlogin dummy

# Defines scores in the global scoreboard
scoreboard players set warning_time time 40
scoreboard players set rising_time time 100
scoreboard players set starter_period time 300
scoreboard players set grace_period time 2500
scoreboard players set height_limit global 1
scoreboard players set sound_effects global 1

# Teams
scoreboard players set enable_teams global 0
scoreboard players set 3v3v3 global 0

scoreboard players set timer_enabled global 0
scoreboard objectives add alive_players dummy
scoreboard objectives modify alive_players displayname {"text":"Lava Rising","color":"red","bold":true}
bossbar add lavarising:period {"text":""}
bossbar set lavarising:period players @a

# Create Admin + Spectator team
team add admin
team add spectator

worldborder set 10
gamemode adventure @a
effect give @a weakness 9999 255 true
effect give @a resistance 9999 255 true
effect give @a regeneration 9999 255 true

# Teams
scoreboard players reset alive alive_players
scoreboard players reset red alive_players
scoreboard players reset blue alive_players
scoreboard players reset green alive_players
# Create Teams
# Team 1
team add red
team modify red color red
team modify red friendlyFire false
# Team 2
team add blue
team modify blue color aqua
team modify blue friendlyFire false
# Team 3 (only when 3v3v3 is set to 1)
team add green
team modify green color green
team modify green friendlyFire false
# Add scoreboards for teams
scoreboard objectives add red_team dummy
scoreboard objectives add blue_team dummy
scoreboard objectives add green_team dummy
scoreboard objectives modify red_team displayname [{"text":"Lava Rising","color":"gold","bold":true},{"text":" (red)","color":"red","bold":true}]
scoreboard objectives modify blue_team displayname [{"text":"Lava Rising","color":"gold","bold":true},{"text":" (blue)","color":"aqua","bold":true}]
scoreboard objectives modify green_team displayname [{"text":"Lava Rising","color":"gold","bold":true},{"text":" (green)","color":"green","bold":true}]

difficulty peaceful

scoreboard players set defaults global 1
9 changes: 9 additions & 0 deletions data/lavarising/functions/grace_period.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
effect clear @a resistance
scoreboard players set period time 1

execute as @a at @s run playsound minecraft:entity.generic.explode player @s ~ ~ ~ 100 0.5
execute as @a at @s run playsound minecraft:ambient.cave player @s ~ ~ ~ 100 0.5
title @a title {"text":"GRACE PERIOD","color":"green","bold":true}
title @a subtitle {"text":"PvP has been enabled, however players may still respawn.","color":"white"}

gamerule naturalRegeneration true
12 changes: 12 additions & 0 deletions data/lavarising/functions/green_victory.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
scoreboard players set period time 3

title @a title {"text":"GAME OVER!","color":"green","bold":true}
title @a subtitle [{"text":"Green Team has won the game."}]
execute as @a at @s run playsound minecraft:ui.toast.challenge_complete player @s ~ ~ ~
effect give @a resistance 9999 255 true
execute as @a at @s run summon firework_rocket ~ ~1 ~ {FireworksItem:{id:firework_rocket,Count:1,tag:{Fireworks:{Flight:1,Explosions:[{Type:1,Flicker:0,Trail:0,Colors:[I;3887386],FadeColors:[I;4312372]}]}}}}
gamemode spectator @a

scoreboard players reset red alive_players
scoreboard players reset blue alive_players
scoreboard players reset green alive_players
63 changes: 63 additions & 0 deletions data/lavarising/functions/main.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Try to find a player and load setup-flow
execute as @a unless score setup_flow internal matches 1 run function lavarising:setup_flow

# Move up player if they spawn underground
execute if score period time matches -1 as @a at @s unless block ~ ~1 ~ #lavarising:safe run tp @s ~ ~5 ~

# Runs the necessary functions & stores variables
execute if score timer_enabled global matches 1 run function lavarising:time
execute as @a if score @s death matches 1.. if score period time matches 2 run function lavarising:death
execute unless score period time matches 2 run scoreboard players reset @a[scores={death=1..}] death
execute as @e[tag=riser] at @s store result score @s y run data get entity @s Pos[1]
bossbar set lavarising:period players @a

# Sets scores for all teams
scoreboard players set @a[team=red] red_team 1
scoreboard players reset @a[team=blue] red_team
scoreboard players reset @a[team=green] red_team
scoreboard players set @a[team=blue] blue_team 1
scoreboard players reset @a[team=red] blue_team
scoreboard players reset @a[team=green] blue_team
scoreboard players set @a[team=green] green_team 1
scoreboard players reset @a[team=red] green_team
scoreboard players reset @a[team=blue] green_team
scoreboard objectives setdisplay sidebar.team.red red_team
scoreboard objectives setdisplay sidebar.team.aqua blue_team
scoreboard objectives setdisplay sidebar.team.green green_team

# Teams
execute if score enable_teams global matches 1 run function waterrising:teams_mode
execute if score enable_teams global matches 0 run function waterrising:solos_mode

kill @e[type=falling_block]

execute as @e[tag=riser] at @s run fill ~-40 ~-1 ~-40 ~40 ~ ~40 lava
execute as @e[tag=riser] at @s run fill ~-40 ~ ~-40 ~40 ~2 ~40 air replace #lavarising:illegal

# PERIOD -1 (pre-game)
execute if score period time matches -1 run gamemode adventure @a[gamemode=!adventure,team=!admin]
execute if score period time matches -1 run effect give @a weakness 9999 255 true
execute if score period time matches -1 run effect give @a resistance 9999 255 true
execute if score period time matches -1 run effect give @a regeneration 9999 255 true
execute if score period time matches -1 run scoreboard players set @a lastlogin -1

# PERIOD 0 (starter period)
execute as @a at @s if score period time matches 0 unless score @s lastlogin matches 0 run effect clear @s weakness
execute as @a at @s if score period time matches 0 unless score @s lastlogin matches 0 run effect clear @s regeneration
execute as @a at @s if score period time matches 0 unless score @s lastlogin matches 0 run effect give @s resistance 120 255 true
execute as @a at @s if score period time matches 0 unless score @s lastlogin matches 0 run gamemode survival @s
execute as @a at @s if score period time matches 0 unless score @s lastlogin matches 0 run scoreboard players set @s lastlogin 0

# PERIOD 1 (grace period)
execute as @a at @s if score period time matches 1 unless score @s lastlogin matches 1 run effect clear @s weakness
execute as @a at @s if score period time matches 1 unless score @s lastlogin matches 1 run effect clear @s regeneration
execute as @a at @s if score period time matches 1 unless score @s lastlogin matches 1 run effect clear @s resistance
execute as @a at @s if score period time matches 1 unless score @s lastlogin matches 1 run gamemode survival @s
execute as @a at @s if score period time matches 1 unless score @s lastlogin matches 1 run scoreboard players set @s lastlogin 1

# PERIOD 2 (main period)
execute as @a at @s if score period time matches 2 unless score @s lastlogin matches 2 run effect clear @s weakness
execute as @a at @s if score period time matches 2 unless score @s lastlogin matches 2 run effect clear @s regeneration
execute as @a at @s if score period time matches 2 unless score @s lastlogin matches 2 run effect clear @s resistance
execute as @a at @s if score period time matches 2 unless score @s lastlogin matches 2 run gamemode survival @s
execute as @a at @s if score period time matches 2 unless score @s lastlogin matches 2 run scoreboard players set @s lastlogin 2
13 changes: 13 additions & 0 deletions data/lavarising/functions/main_game.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
team modify players friendlyFire true
scoreboard players set period time 2

execute as @a at @s run playsound minecraft:entity.generic.explode player @s ~ ~ ~ 100 0.5
execute as @a at @s run playsound minecraft:ambient.cave player @s ~ ~ ~ 100 0.5
title @a title {"text":"LAVA RISING","color":"red","bold":true}
title @a subtitle {"text":"The lava has begun to rise, this is your only life.","color":"white"}

worldborder set 10 10000
gamerule naturalRegeneration true

scoreboard players set rise_time time 0
scoreboard players set enabled global 1
13 changes: 13 additions & 0 deletions data/lavarising/functions/prepare.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Runs on reload

# Creates the required scoreboards
scoreboard objectives add time dummy
scoreboard objectives add global dummy
scoreboard objectives add death deathCount
scoreboard objectives add y dummy

# Defines scores in the global scoreboard
execute unless score defaults global matches 1 run function lavarising:defaults

# Changes necessary gamerules & parameters
gamerule doImmediateRespawn true
12 changes: 12 additions & 0 deletions data/lavarising/functions/red_victory.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
scoreboard players set period time 3

title @a title {"text":"GAME OVER!","color":"red","bold":true}
title @a subtitle [{"text":"Red Team has won the game."}]
execute as @a at @s run playsound minecraft:ui.toast.challenge_complete player @s ~ ~ ~
effect give @a resistance 9999 255 true
execute as @a at @s run summon firework_rocket ~ ~1 ~ {FireworksItem:{id:firework_rocket,Count:1,tag:{Fireworks:{Flight:1,Explosions:[{Type:1,Flicker:0,Trail:0,Colors:[I;11743532],FadeColors:[I;14188952]}]}}}}
gamemode spectator @a

scoreboard players reset red alive_players
scoreboard players reset blue alive_players
scoreboard players reset green alive_players
14 changes: 14 additions & 0 deletions data/lavarising/functions/rise.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Resets the timer score
scoreboard players set rise_time time 0

# Fills away all blocks on the riser y level and rises up a block unless y is 310
gamerule doTileDrops false
execute as @e[tag=riser] at @s run fill ~-41 ~-1 ~-41 ~41 ~1 ~41 barrier
execute as @e[tag=riser] at @s run fill ~-40 ~-1 ~-40 ~40 ~ ~40 lava
execute as @e[tag=riser] at @s run fill ~-40 ~-1 ~-40 ~40 ~-3 ~40 lava replace #lavarising:illegal
execute as @e[tag=riser] at @s run tp @s ~ ~1 ~
gamerule doTileDrops true

# Sends chat messages & alert sounds
execute if score sound_effects global matches 1 as @a at @s run playsound minecraft:block.lava.pop ambient @s
3 changes: 3 additions & 0 deletions data/lavarising/functions/setup_flow.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Guided Setup flow

tellraw @a [{"text":"\nLava Rising for 1.17\n\n","color":"gold","bold":true},{"text":"This is the first-time setup flow to get you up and running. This can be run again with function lavarising:setup_flow\n\n","color":"gray","bold":false},{"text":"Configure the datapack:\n","color":"white","bold":false},{"text":"Teams: ","color":"light_purple"},{"text":"ENABLE","color":"green","clickEvent":{"action":"run_command","value":"/scoreboard players set enable_teams global 1"}},{"text":" DISABLE","color":"red","italic":true,"clickEvent":{"action":"run_command","value":"/scoreboard players set enable_teams global 0"}},{"text":"\nTeam count: ","color":"dark_purple"},{"text":"3 Teams","color":"gold","clickEvent":{"action":"run_command","value":"/scoreboard players set 3v3v3 global 1"}},{"text":" 2 Teams","italic":true,"clickEvent":{"action":"run_command","value":"/scoreboard players set 3v3v3 global 0"}},{"text":"\n\nWhen you're ready, ","color":"gray","bold":false},{"text":"Start Game\n","color":"green","clickEvent":{"action":"run_command","value":"/function lavarising:start"}}]
1 change: 1 addition & 0 deletions data/lavarising/functions/solos_mode.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
execute if score alive alive_players matches ..1 if score period time matches 2 run function lavarising:victory
22 changes: 22 additions & 0 deletions data/lavarising/functions/start.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kill @e[tag=riser]
execute unless entity @e[tag=riser] run summon armor_stand 0 0 0 {NoGravity:1b,Silent:1b,Invulnerable:1b,Invisible:1b,Tags:["riser"]}

scoreboard players set time time 0
scoreboard players set time_seconds time 0
scoreboard players set timer_enabled global 1
execute as @a[gamemode=!spectator] run scoreboard players add alive alive_players 1

execute as @a at @s run playsound minecraft:entity.generic.explode player @s ~ ~ ~ 100 1.5
title @a title {"text":"Let the games begin!","color":"green","bold":true}
title @a subtitle {"text":"PvP will be enabled in 4 minutes, make sure you're ready!","color":"white"}

function lavarising:starter_period

worldborder set 1000 10
gamemode survival @a
effect clear @a weakness
effect clear @a regeneration

difficulty easy

scoreboard players set enabled global 0
4 changes: 4 additions & 0 deletions data/lavarising/functions/starter_period.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
effect give @a resistance 120 255 true
scoreboard players set period time 0
gamerule naturalRegeneration true
schedule function lavarising:close_border 10s
6 changes: 6 additions & 0 deletions data/lavarising/functions/teams_mode.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Teams manager

# 3 Teams
execute if score 3v3v3 global matches 1 run function lavarising:3teams
# 2 Teams
execute if score 3v3v3 global matches 0 run function lavarising:2teams
35 changes: 35 additions & 0 deletions data/lavarising/functions/time.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
scoreboard players add time time 1
execute if score enabled global matches 1 run scoreboard players add rise_time time 1

execute if score time time matches 20.. run scoreboard players add time_seconds time 1
execute if score time time matches 20.. run scoreboard players set time time 0

execute as @e[tag=riser] at @s if score rise_time time = rising_time time unless score @s y matches 310.. if score height_limit global matches 1 run function lavarising:rise

execute as @e[tag=riser] at @s if score time time = rising_time time unless score @s y matches 310.. if score height_limit global matches 1 run function lavarising:rise

execute if score time_seconds time = starter_period time if score period time matches 0 run function lavarising:grace_period
execute if score time_seconds time = grace_period time if score period time matches 1 run function lavarising:main_game

# Stores current timer & max y level in the bossbar
execute unless score period time matches 2 store result bossbar lavarising:period value run scoreboard players get time_seconds time

# Progress bossbar
execute if score period time matches -1 run bossbar set lavarising:period color white
execute if score period time matches -1 run bossbar set lavarising:period name ""

execute if score period time matches 0 store result bossbar lavarising:period max run scoreboard players get starter_period time
execute if score period time matches 0 run bossbar set lavarising:period color yellow
execute if score period time matches 0 run bossbar set lavarising:period name [{"text":"It is now the ","color":"white","bold":false},{"text":"starter period","color":"yellow","bold":true},{"text":" [","color":"white","bold":false},{"score":{"name":"time_seconds","objective":"time"},"color":"yellow","bold":true},{"text":"/","color":"gold","bold":false},{"score":{"name":"starter_period","objective":"global"},"color":"yellow","bold":false},{"text":"]","color":"white","bold":false}]

execute if score period time matches 1 store result bossbar lavarising:period max run scoreboard players get grace_period time
execute if score period time matches 1 run bossbar set lavarising:period color green
execute if score period time matches 1 run bossbar set lavarising:period name [{"text":"It is now the ","color":"white","bold":false},{"text":"grace period","color":"green","bold":true},{"text":" [","color":"white","bold":false},{"score":{"name":"time_seconds","objective":"time"},"color":"green","bold":true},{"text":"/","color":"dark_green","bold":false},{"score":{"name":"grace_period","objective":"global"},"color":"green","bold":false},{"text":"]","color":"white","bold":false}]

execute if score period time matches 2 run bossbar set lavarising:period color red
execute if score period time matches 2 run bossbar set lavarising:period name [{"text":"The lava is currently at Y: ","color":"red"},{"score":{"name":"@e[tag=riser,limit=1]","objective":"y"},"color":"yellow","bold":true},{"text":"/310","color":"gold"}]
execute if score period time matches 2 store result bossbar lavarising:period value run scoreboard players get rise_time time
execute if score period time matches 2 store result bossbar lavarising:period max run scoreboard players get rising_time time

execute if score period time matches 3 run bossbar set lavarising:period color blue
execute if score period time matches 3 run bossbar set lavarising:period name [{"text":"The game has ended!","color":"aqua","bold":false}]
12 changes: 12 additions & 0 deletions data/lavarising/functions/victory.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
scoreboard players reset alive alive_players
scoreboard players set period time 3

title @a[gamemode=!survival] title {"text":"GAME OVER!","color":"gold","bold":true}
title @a[gamemode=!survival] subtitle [{"selector":"@a[gamemode=survival]"},{"text":" has won the game."}]

title @a[gamemode=survival] title {"text":"YOU WON!","color":"gold","bold":true}
title @a[gamemode=survival] subtitle [{"text":"Congratulations."}]

execute as @a at @s run playsound minecraft:ui.toast.challenge_complete player @s ~ ~ ~
effect give @a resistance 9999 255 true
execute as @a at @s run summon firework_rocket ~ ~1 ~ {FireworksItem:{id:firework_rocket,Count:1,tag:{Fireworks:{Flight:1,Explosions:[{Type:1,Flicker:0,Trail:0,Colors:[I;15435844],FadeColors:[I;14602026]}]}}}}
Loading

0 comments on commit fef0a02

Please sign in to comment.