Skip to content

Commit

Permalink
⚡️Optimize dropper minigame
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiome committed May 4, 2024
1 parent 0d4177a commit 12f20ba
Show file tree
Hide file tree
Showing 58 changed files with 254 additions and 214 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
5 changes: 0 additions & 5 deletions minigames/data/dropper/functions/__load__.mcfunction
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@

function dropper:stop/stop
scoreboard objectives add dropper.fall_damage minecraft.custom:minecraft.damage_resisted

team add dropper
team modify dropper color green
team modify dropper friendlyFire false
team modify dropper seeFriendlyInvisibles true
team modify dropper collisionRule never

4 changes: 1 addition & 3 deletions minigames/data/dropper/functions/__tick__.mcfunction
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@


execute if score #dropper.game_started data matches 1 run function dropper:game_tick
execute if score #dropper.game_started data matches 1 run function #dropper:game
10 changes: 5 additions & 5 deletions minigames/data/dropper/functions/game_tick.mcfunction
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

effect give @a[predicate=dropper:in_dropzone] invisibility 1 1 true
execute at @a[team=dropper] run effect give @a[distance=0.001..3] invisibility 1 1 true

function #dropper:jump
function #dropper:end_game
function #dropper:music
# Display timer ---------------------------------------------------------------

effect give @a[x=118,y=75,z=-10,dx=10,dy=10,dz=10] invisibility 1 1 true
execute store result score #dropper.timer.seconds data store result score #dropper.timer.modulo data run scoreboard players remove #dropper.timer data 1
scoreboard players operation #dropper.timer.modulo data %= 20 const
execute if score #dropper.timer.modulo data matches 0 run function dropper:timer/display
3 changes: 3 additions & 0 deletions minigames/data/dropper/functions/jump/begin.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tellraw @a[team=dropper] [{"text":"DROPPER > ","color":"green","bold":true,"italic":true},{"selector":"@s","color":"gray","bold":false,"italic":false},{"text":" has jumped!","color":"gray","bold":false,"italic":false}]
execute as @a[team=dropper] at @s run playsound block.stone_button.click_on master @s ~ ~ ~ 1 2 0
tag @s add dropper.has_jumped
6 changes: 6 additions & 0 deletions minigames/data/dropper/functions/jump/complete.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# If the player fall in water inside of the zone -> success
execute at @s[predicate=dropper:in_dropzone] if block ~ ~ ~ #dropper:water run return run function dropper:jump/success
# If the player fall in water outside of the zone -> fail
execute at @s if block ~ ~ ~ #dropper:water run return run function dropper:jump/failure/missed_zone
# If the player fall on a block -> fail
function dropper:jump/failure/fell_on_block
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

tellraw @a[team=dropper] [{"text":"DROPPER > ","color":"green","bold":true,"italic":true},{"selector":"@s","color":"red","bold":false,"italic":false},{"text":" didn't jump","color":"red","bold":false,"italic":false}]

function dropper:jump/fail
function dropper:jump/failure/eliminate_player
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

execute as @a[team=dropper] at @s run playsound block.stone_button.click_off master @s ~ ~ ~ 1 2 0

function #global:animated_title {type:"defeat"}

tag @s add dropper.jump_complete

function dropper:stop/reset_player
team leave @s
stopsound @s record
tag @s remove dropper.jump_complete
tag @s remove dropper.has_jumped
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

tellraw @a[team=dropper] [{"text":"DROPPER > ","color":"green","bold":true,"italic":true},{"selector":"@s","color":"red","bold":false,"italic":false},{"text":" fell on a block","color":"red","bold":false,"italic":false}]

function dropper:jump/fail
function dropper:jump/failure/eliminate_player
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

tellraw @a[team=dropper] [{"text":"DROPPER > ","color":"green","bold":true,"italic":true},{"selector":"@s","color":"red","bold":false,"italic":false},{"text":" missed the zone","color":"red","bold":false,"italic":false}]

function dropper:jump/fail
function dropper:jump/failure/eliminate_player
11 changes: 11 additions & 0 deletions minigames/data/dropper/functions/jump/reset/process.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
scoreboard players add #dropper.timer_before_jump_reset data 1

execute if score #dropper.timer_before_jump_reset data matches 1 as @a[team=dropper] at @s run playsound block.stone_button.click_on master @s ~ ~ ~ 1 2 0
execute if score #dropper.timer_before_jump_reset data matches 1 run tellraw @a[team=dropper] [{"text":"\nDROPPER > ","color":"green","bold":true,"italic":true},{"text":" Round complete!\n","color":"gray","bold":false,"italic":false}]

execute if score #dropper.timer_before_jump_reset data matches 33 run function dropper:map/dropzone/refill

execute if score #dropper.timer_before_jump_reset data matches 66 run scoreboard players add #dropper.round data 1
execute if score #dropper.timer_before_jump_reset data matches 66 run function dropper:map/obstacles/generate

execute if score #dropper.timer_before_jump_reset data matches 100.. run function dropper:jump/reset/round
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

tp @a[team=dropper] 123.5 186 5.5 180 45
tag @a remove dropper.jump_complete
tag @a remove dropper.has_jumped

scoreboard players set #dropper.timer data 300
scoreboard players set #dropper.timer_before_jump_reset data 0
scoreboard players set #dropper.timer_before_jump_reset data 0
10 changes: 0 additions & 10 deletions minigames/data/dropper/functions/jump/set_wool.mcfunction

This file was deleted.

14 changes: 11 additions & 3 deletions minigames/data/dropper/functions/jump/success.mcfunction
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
tag @s add dropper.jump_complete
tp @s ~ ~2 ~
execute as @a[team=dropper] at @s run playsound block.stone_button.click_on master @s ~ ~ ~ 1 2 0
tag @s add dropper.jump_complete

tellraw @a[team=dropper] [{"text":"DROPPER > ","color":"green","bold":true,"italic":true},{"selector":"@s","bold":false,"italic":false},{"text":" succeeded in his jump","color":"green","bold":false,"italic":false}]
execute as @a[team=dropper] at @s run playsound block.stone_button.click_on master @s ~ ~ ~ 1 2 0

function dropper:jump/set_wool
execute store result score #dropper.jump.wool data run random value 0..6
execute if score #dropper.jump.wool data matches 0 run setblock ~ 80 ~ black_wool
execute if score #dropper.jump.wool data matches 1 run setblock ~ 80 ~ white_wool
execute if score #dropper.jump.wool data matches 2 run setblock ~ 80 ~ red_wool
execute if score #dropper.jump.wool data matches 3 run setblock ~ 80 ~ lime_wool
execute if score #dropper.jump.wool data matches 4 run setblock ~ 80 ~ light_blue_wool
execute if score #dropper.jump.wool data matches 5 run setblock ~ 80 ~ magenta_wool
execute if score #dropper.jump.wool data matches 6 run setblock ~ 80 ~ yellow_wool
52 changes: 6 additions & 46 deletions minigames/data/dropper/functions/jump/trigger.mcfunction
Original file line number Diff line number Diff line change
@@ -1,53 +1,13 @@

scoreboard players remove #dropper.timer data 1


execute as @a[team=dropper,tag=!dropper.has_jumped,scores={pos.y=..195000}] run tellraw @a[team=dropper] [{"text":"DROPPER > ","color":"green","bold":true,"italic":true},{"selector":"@s","color":"gray","bold":false,"italic":false},{"text":" has jumped!","color":"gray","bold":false,"italic":false}]
execute as @a[team=dropper,tag=!dropper.has_jumped,scores={pos.y=..195000}] as @a[team=dropper] at @s run playsound block.stone_button.click_on master @s ~ ~ ~ 1 2 0
execute as @a[team=dropper,tag=!dropper.has_jumped,scores={pos.y=..195000}] run tag @s add dropper.has_jumped

# Display timer ---------------------------------------------------------------

execute store result score #dropper.timer.seconds data store result score #dropper.timer.modulo data run scoreboard players get #dropper.timer data
scoreboard players operation #dropper.timer.seconds data /= 20 const
scoreboard players operation #dropper.timer.modulo data %= 20 const
scoreboard players add #dropper.timer.seconds data 1

execute if score #dropper.timer data matches 101.. run title @a[team=dropper,scores={pos.y=185000..}] actionbar [{"text":"You have ","color":"white"},{"score":{"name":"#dropper.timer.seconds","objective":"data"},"color":"green"},{"text":"s to jump","color":"white"}]

execute if score #dropper.timer data matches ..100 run title @a[team=dropper,scores={pos.y=185000..}] actionbar [{"text":"You have ","color":"red","bold":true,"italic":true},{"score":{"name":"#dropper.timer.seconds","objective":"data"},"color":"yellow","bold":true,"italic":true},{"text":"s to jump","color":"red","bold":true,"italic":true}]

execute if score #dropper.timer data matches 1..100 if score #dropper.timer.modulo data matches 0 as @a[team=dropper,scores={pos.y=185000..}] at @s run playsound minecraft:entity.experience_orb.pickup master @s ~ ~ ~ 1 1 0
execute as @a[team=dropper,tag=!dropper.has_jumped,predicate=dropper:is_jumping] run function dropper:jump/begin

# Jump complete ---------------------------------------------------------------

# If the player fall in water inside of the zone -> success
execute as @a[team=dropper,scores={pos.x=118500..128500,pos.y=70000..120000,pos.z=-9500..500},tag=!dropper.jump_complete] at @s if block ~ ~ ~ #dropper:water run function dropper:jump/success

# If the player fall in water outside of the zone -> fail
execute as @a[team=dropper,scores={pos.y=70000..120000},tag=!dropper.jump_complete] at @s if block ~ ~ ~ #dropper:water run function dropper:jump/missed_zone

# If the player fall on a block -> fail
execute as @a[team=dropper,scores={pos.y=70000..180000,dropper.fall_damage=1..},tag=!dropper.jump_complete] at @s run function dropper:jump/fell_on_block
execute as @a[team=dropper,scores={pos.y=70000..180000},gamemode=creative,nbt={OnGround:1b},tag=!dropper.jump_complete] at @s run function dropper:jump/fell_on_block
execute as @e[team=dropper] run scoreboard players set @s dropper.fall_damage 0


# If the player has jumped and is not currently jumping -> jump is complete
execute as @a[team=dropper,tag=dropper.has_jumped,tag=!dropper.jump_complete,predicate=!dropper:is_jumping] run function dropper:jump/complete
# If the player didn't jumped after 10s -> fail
execute if score #dropper.timer data matches ..0 as @a[team=dropper,scores={pos.y=185000..}] at @s run function dropper:jump/didnt_jump
execute if score #dropper.timer data matches ..0 as @a[team=dropper,predicate=dropper:on_diving_board,predicate=!dropper:is_jumping] at @s run function dropper:jump/failure/didnt_jump

# Reset jump if all player jumped ---------------------------------------------

scoreboard players set #dropper.didnt_jump_players data 0
execute as @a[team=dropper,tag=!dropper.jump_complete] run scoreboard players add #dropper.didnt_jump_players data 1
execute if score #dropper.timer_before_jump_reset data matches 1.. run scoreboard players add #dropper.timer_before_jump_reset data 1
execute if score #dropper.timer_before_jump_reset data matches 0 if score #dropper.didnt_jump_players data matches 0 if entity @a[team=dropper] run scoreboard players add #dropper.timer_before_jump_reset data 1

execute if score #dropper.timer_before_jump_reset data matches 1 run execute as @a[team=dropper] at @s run playsound block.stone_button.click_on master @s ~ ~ ~ 1 2 0
execute if score #dropper.timer_before_jump_reset data matches 1 run tellraw @a[team=dropper] [{"text":"\nDROPPER > ","color":"green","bold":true,"italic":true},{"text":" Round complete!\n","color":"gray","bold":false,"italic":false}]

execute if score #dropper.timer_before_jump_reset data matches 66 run scoreboard players add #dropper.round data 1
execute if score #dropper.timer_before_jump_reset data matches 66 run function dropper:obstacles/generate

execute if score #dropper.timer_before_jump_reset data matches 33 run function dropper:zone/refill
execute if score #dropper.timer_before_jump_reset data matches 100.. run function dropper:jump/reset
execute store result score #dropper.didnt_jump_players data if entity @a[team=dropper,tag=!dropper.jump_complete]
execute if score #dropper.didnt_jump_players data matches 0 run function dropper:jump/reset/process
5 changes: 3 additions & 2 deletions minigames/data/dropper/functions/map/build.mcfunction
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

fill 119 80 0 127 80 0 minecraft:spruce_log[axis=x]
fill 119 80 -10 127 80 -10 minecraft:spruce_log[axis=x]
fill 118 80 -9 118 80 -1 minecraft:spruce_log[axis=z]
fill 128 80 -9 128 80 -1 minecraft:spruce_log[axis=z]

setblock 128 80 0 minecraft:cobblestone
setblock 128 80 -10 minecraft:cobblestone
setblock 118 80 -10 minecraft:cobblestone
setblock 118 80 0 minecraft:cobblestone
place template dropper:dropper_platform 120 185 1

place template dropper:dropper_platform 120 185 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
execute store result score #dropper.zone.refill data if entity @a[team=dropper]
scoreboard players remove #dropper.zone.refill data 1

execute if score #dropper.zone.refill data matches 1.. positioned 119 80 -9 summon minecraft:marker run function dropper:map/dropzone/refill_loop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Random pos
execute store result entity @s Pos[0] double 1 run random value 119..127
execute store result entity @s Pos[2] double 1 run random value -9..-1

execute at @s run setblock ~ ~ ~ water destroy

scoreboard players remove #dropper.zone.refill data 1

execute if score #dropper.zone.refill data matches 0 run kill @s
execute if score #dropper.zone.refill data matches 1.. run function dropper:map/dropzone/refill_loop
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
function dropper:map/obstacles/remove_all

function dropper:obstacles/remove_all

execute if score #dropper.timer_before_jump_reset data matches 66 run execute as @a[team=dropper] at @s run playsound block.stone_button.click_on master @s ~ ~ ~ 1 2 0
execute as @a[team=dropper] at @s run playsound block.stone_button.click_on master @s ~ ~ ~ 1 2 0

# During the two first rounds, there is no bottom obstacle
execute if score #dropper.round data matches 1..2 run scoreboard players set #dropper.obstacle data 0
Expand Down Expand Up @@ -57,4 +56,4 @@ execute if score #dropper.obstacle data matches 4 run tellraw @a[team=dropper] [
execute if score #dropper.obstacle data matches 1 run place template dropper:obstacle_1 113 105 -15
execute if score #dropper.obstacle data matches 2 run place template dropper:obstacle_2 113 105 -15
execute if score #dropper.obstacle data matches 3 run place template dropper:obstacle_3 113 105 -15
execute if score #dropper.obstacle data matches 4 run place template dropper:obstacle_4 113 105 -15
execute if score #dropper.obstacle data matches 4 run place template dropper:obstacle_4 113 105 -15
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

fill 113 105 -15 134 108 6 air
fill 113 135 -15 134 138 6 air
fill 113 165 -15 134 168 6 air
fill 113 165 -15 134 168 6 air
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
setblock 135 85 -4 minecraft:quartz_pillar destroy
setblock 135 85 -3 minecraft:air destroy
setblock 135 85 -3 minecraft:oak_wall_sign[facing=south,waterlogged=false]{back_text:{color:"black",has_glowing_text:0b,messages:['{"text":""}','{"text":""}','{"text":""}','{"text":""}']},front_text:{has_glowing_text:0b,messages:['{"clickEvent":{"action":"run_command","value":"function #dropper:start"},"color":"green","text":" "}','{"color":"green","text":"Start"}','{"color":"green","text":"DROPPER"}','{"text":""}']},is_waxed:0b}
setblock 135 85 -3 minecraft:oak_wall_sign[facing=south,waterlogged=false]{back_text:{color:"black",has_glowing_text:0b,messages:['{"text":""}','{"text":""}','{"text":""}','{"text":""}']},front_text:{has_glowing_text:0b,messages:['{"clickEvent":{"action":"run_command","value":"function #dropper:events/launch"},"color":"green","text":" "}','{"color":"green","text":"Start"}','{"color":"green","text":"DROPPER"}','{"text":""}']},is_waxed:0b}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
setblock 135 85 -4 minecraft:air destroy
setblock 135 85 -3 minecraft:air destroy
setblock 135 85 -3 minecraft:air destroy
4 changes: 2 additions & 2 deletions minigames/data/dropper/functions/map/reset.mcfunction
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

fill 120 185 1 126 188 7 air destroy
fill 118 80 -10 128 80 0 minecraft:water destroy
function dropper:obstacles/remove_all

function dropper:map/obstacles/remove_all
16 changes: 0 additions & 16 deletions minigames/data/dropper/functions/music/main.mcfunction

This file was deleted.

4 changes: 4 additions & 0 deletions minigames/data/dropper/functions/music/play.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tellraw @a[team=dropper] {"text":"Musics by Yrii Semchyshyn, Oleksandr Stepanov and QubeSounds","hoverEvent":{"action":"show_text","value":[{"text":"Played on the \"record\" audio source"}]}}

function dropper:music/stop
function dropper:music/theme_1
5 changes: 5 additions & 0 deletions minigames/data/dropper/functions/music/stop.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
stopsound @a[team=dropper] record

schedule clear dropper:music/theme_1
schedule clear dropper:music/theme_2
schedule clear dropper:music/theme_3
4 changes: 4 additions & 0 deletions minigames/data/dropper/functions/music/theme_1.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# First theme (1m 28s)
stopsound @a[team=dropper] record
playsound dropper:theme-1 record @a[team=dropper] ~ ~ ~ .5 .5 .5
schedule function dropper:music/theme_2 1780t
4 changes: 4 additions & 0 deletions minigames/data/dropper/functions/music/theme_2.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Second theme (1m 6s)
stopsound @a[team=dropper] record
playsound dropper:theme-2 record @a[team=dropper] ~ ~ ~ .5 .5 .5
schedule function dropper:music/theme_3 1340t
4 changes: 4 additions & 0 deletions minigames/data/dropper/functions/music/theme_3.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Third theme (1m 6s)
stopsound @a[team=dropper] record
playsound dropper:theme-3 record @a[team=dropper] ~ ~ ~ .5 .5 .5
schedule function dropper:music/theme_1 1860t
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
function dropper:map/remove_starting_sign

function #lib:start_animation {\
id: "dropper",\
minigame: "DROPPER",\
Expand All @@ -8,6 +6,6 @@ function #lib:start_animation {\
y: 85.5,\
z: -3.5,\
size: 5,\
start_callback: "dropper:start/start",\
cancel_callback: "dropper:map/place_starting_sign"\
start_callback: "#dropper:events/start",\
cancel_callback: "#dropper:events/cancel"\
}
11 changes: 2 additions & 9 deletions minigames/data/dropper/functions/start/start.mcfunction
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@

execute at @e[tag=lib.start_animation.dropper] run team join dropper @a[distance=..5]
function dropper:map/build

execute as @a[team=dropper] run function #global:animated_title {type:"start"}
clear @a[team=dropper]

scoreboard players set #dropper.game_started data 1
function dropper:jump/reset

scoreboard players set #dropper.music_timer data 0
scoreboard players set #dropper.round data 0

execute as @a[team=dropper] run function #global:animated_title {type:"start"}

tellraw @a[team=dropper] {"text":"Musics by Yrii Semchyshyn, Oleksandr Stepanov and QubeSounds","hoverEvent":{"action":"show_text","value":[{"text":"Played on the \"record\" audio source"}]}}
function dropper:jump/reset/round
4 changes: 0 additions & 4 deletions minigames/data/dropper/functions/stop/end_game.mcfunction

This file was deleted.

6 changes: 0 additions & 6 deletions minigames/data/dropper/functions/stop/reset_player.mcfunction

This file was deleted.

14 changes: 11 additions & 3 deletions minigames/data/dropper/functions/stop/stop.mcfunction
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
execute as @a[team=dropper] at @s run function #global:animated_title {type:"victory"}

scoreboard players set #dropper.game_started data 0

stopsound @a[team=dropper] record
tag @a[team=dropper] remove dropper.jump_complete
tag @a[team=dropper] remove dropper.has_jumped
team leave @a[team=dropper]

execute as @a[team=dropper] at @s run function dropper:stop/reset_player
function dropper:map/place_starting_sign
function dropper:map/reset


scoreboard players set #dropper.game_started data 0
schedule clear dropper:music/theme_1
schedule clear dropper:music/theme_2
schedule clear dropper:music/theme_3
Loading

0 comments on commit 12f20ba

Please sign in to comment.