53 lines
3.7 KiB
MCFunction
53 lines
3.7 KiB
MCFunction
# Minecraft time:
|
|
# 06:00 = 0
|
|
# 06:30 = 500
|
|
# 07:00 = 1000
|
|
# 08:00 = 2000
|
|
|
|
execute store result score #time daytime run time query daytime
|
|
|
|
# Sistem visual wave: title, countdown, dan bossbar.
|
|
function protect_villagers:wave/tick
|
|
|
|
# Hitung villager dan guard villager.
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] run function protect_villagers:entities/count
|
|
|
|
# Kurangi cooldown spawn villager untuk player.
|
|
scoreboard players remove @a[scores={pv_spawn_cd=1..}] pv_spawn_cd 1
|
|
|
|
# Button spawn villager di -10 68 0.
|
|
# Hanya 1 player terdekat dari button yang diproses per sekali tekan.
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] if block -10 68 0 minecraft:stone_button[powered=true] if score #button pv_button_lock matches 0 positioned -10 68 0 as @p[distance=..8] run function protect_villagers:entities/spawn/request
|
|
|
|
# Buka lock button lagi setelah tombol tidak powered.
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] unless block -10 68 0 minecraft:stone_button[powered=true] run scoreboard players set #button pv_button_lock 0
|
|
|
|
# Deteksi jika ada villager/guard yang mati.
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] if score #alive pv_alive < #prev_alive pv_prev_alive run function protect_villagers:game/villager_lost
|
|
|
|
# Simpan jumlah hidup terbaru.
|
|
scoreboard players operation #prev_alive pv_prev_alive = #alive pv_alive
|
|
|
|
# Hitung emerald player setiap tick
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] store result score @s pv_emeralds run clear @s minecraft:emerald 0
|
|
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] run scoreboard players operation @s pv_sidebar_villagers = #villager pv_villagers
|
|
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] run scoreboard players operation @s pv_sidebar_guards = #guard pv_guards
|
|
|
|
# Tampilkan actionbar hanya untuk player di arena.
|
|
# execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] run title @s actionbar [{"text":"Villager: ","color":"yellow"},{"score":{"name":"#villager","objective":"pv_villagers"},"color":"white"},{"text":" | ","color":"gray"},{"text":"Guard Villagers: ","color":"green"},{"score":{"name":"#guard","objective":"pv_guards"},"color":"white"}]
|
|
|
|
# Cek hasil game jam 06:30.
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] if score #time daytime matches 500..510 if score #result pv_result_lock matches 0 run function protect_villagers:game/check_result
|
|
|
|
# Reset arena jam 07:00.
|
|
execute as @a at @s if predicate protect_villagers:allowed_dimension if entity @s[x=-39,y=57,z=-27,dx=108,dy=42,dz=54] if score #time daytime matches 1000..1010 if score #arena arena_reset_lock matches 0 run function protect_villagers:arena/reset
|
|
|
|
# Buka lock hasil game setelah lewat jendela 06:30.
|
|
execute if score #time daytime matches 511..23999 run scoreboard players set #result pv_result_lock 0
|
|
execute if score #time daytime matches 0..499 run scoreboard players set #result pv_result_lock 0
|
|
|
|
# Buka lock reset arena setelah lewat jendela 07:00.
|
|
execute if score #time daytime matches 1011..23999 run scoreboard players set #arena arena_reset_lock 0
|
|
execute if score #time daytime matches 0..999 run scoreboard players set #arena arena_reset_lock 0 |