AirDef: drones and air defence for a Horizon fork
build / mod (push) Failing after 5m36s
build / game-linux (push) Has been skipped
build / game-macos (push) Has been cancelled
build / game-windows (push) Has been cancelled
build / release (push) Has been cancelled

The mod (airdef-mod/), its generated models and sounds, the fork's patches
over upstream Horizon (horizon-patches/, HORIZON_COMMIT), a cross-platform
build/install/run script (tools/airdef.py), CI that builds and releases on
every push (.gitea/workflows/build.yml) and a setup guide (docs/INSTALL.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 19:16:52 +03:00
commit a6a13003c2
543 changed files with 31555 additions and 0 deletions
@@ -0,0 +1,2 @@
$bossbar set airdef:alert name [{"text":"ВОЗДУШНАЯ ТРЕВОГА","color":"red","bold":true},{"text":" — целей в воздухе: $(n)","color":"white","bold":false}]
bossbar set airdef:alert players @a
@@ -0,0 +1,5 @@
execute store result score $air airdef.tmp if entity @e[type=marker,tag=airdef.drone,tag=!airdef.falling]
execute store result storage airdef:alert n int 1 run scoreboard players get $air airdef.tmp
execute store result bossbar airdef:alert value run scoreboard players get $air airdef.tmp
execute if score $air airdef.tmp matches 1.. run function airdef:alert/show with storage airdef:alert
execute if score $air airdef.tmp matches 0 run bossbar set airdef:alert players
@@ -0,0 +1,3 @@
execute as @e[type=marker,tag=airdef.drone] run function airdef:drone/remove
execute as @e[type=marker,tag=airdef.missile] run function airdef:drone/remove
tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"Небо очищено","color":"gray"}]
@@ -0,0 +1,9 @@
# вызывается как новый дрон: id, координаты ближайшей цели
function airdef:new_id
execute as @e[type=marker,tag=airdef.target,sort=nearest,limit=1] run tag @s add airdef.tsel
execute store result score @s airdef.tx run data get entity @e[tag=airdef.tsel,limit=1] Pos[0]
execute store result score @s airdef.ty run data get entity @e[tag=airdef.tsel,limit=1] Pos[1]
execute store result score @s airdef.tz run data get entity @e[tag=airdef.tsel,limit=1] Pos[2]
tag @e[tag=airdef.tsel] remove airdef.tsel
scoreboard players operation @s airdef.cy = @s airdef.ty
tp @s ~ ~ ~ ~ ~
@@ -0,0 +1,7 @@
# обломки на земле: в 30 % случаев детонирует БЧ
execute store result score $r airdef.tmp run random value 1..100
execute if score $r airdef.tmp matches ..30 run summon tnt ~ ~ ~ {fuse:0}
particle minecraft:explosion ~ ~ ~ 1 0.5 1 0 6 force
particle minecraft:campfire_cosy_smoke ~ ~ ~ 1 0.3 1 0.01 20 force
playsound minecraft:entity.generic.explode master @a ~ ~ ~ 4 1.3
function airdef:drone/remove
@@ -0,0 +1,8 @@
# сбитый дрон: штопор вниз, горит, на земле — взрыв
execute if score @s airdef.life matches ..0 run return run function airdef:drone/remove
execute rotated ~18 ~ run tp @s ^ ^ ^0.35 ~ ~5
tp @s ~ ~-0.45 ~
execute at @s run function airdef:visual/update
execute at @s run particle minecraft:large_smoke ~ ~ ~ 0.2 0.2 0.2 0.02 2 force
execute at @s run particle minecraft:flame ~ ~ ~ 0.15 0.15 0.15 0.02 2 force
execute at @s unless block ~ ~-0.6 ~ #minecraft:air run function airdef:drone/crash
@@ -0,0 +1,10 @@
# попадание в цель / землю
summon tnt ~ ~ ~ {fuse:0}
execute if entity @s[tag=airdef.heavy] run summon tnt ~ ~1 ~ {fuse:0}
execute if entity @s[tag=airdef.heavy] run summon tnt ~ ~-1 ~ {fuse:0}
particle minecraft:explosion_emitter ~ ~ ~ 1 1 1 0 3 force
particle minecraft:lava ~ ~ ~ 2 2 2 0 40 force
particle minecraft:campfire_signal_smoke ~ ~ ~ 1.5 0.5 1.5 0.02 40 force
particle minecraft:flame ~ ~ ~ 2 1 2 0.15 60 force
tellraw @a [{"text":"[AirDef] ","color":"gold"},{"nbt":"data.name","entity":"@s","color":"red"},{"text":" поразил цель","color":"red"}]
function airdef:drone/remove
@@ -0,0 +1,5 @@
# запуск дрона с позиции игрока на ближайшую цель. Аргумент: type
execute unless entity @e[type=marker,tag=airdef.target] run return run tellraw @s [{"text":"[AirDef] ","color":"gold"},{"text":"Сначала отметьте цель (Целеуказатель или /function airdef:target/here)","color":"red"}]
$execute positioned ~ ~3 ~ rotated ~ -30 run function airdef:drone/spawn_$(type)
playsound minecraft:entity.firework_rocket.launch master @a ~ ~ ~ 3 0.5
particle minecraft:large_smoke ~ ~1 ~ 0.5 0.5 0.5 0.05 30 force
@@ -0,0 +1,3 @@
$execute positioned $(x) ~ $(z) if entity @s[distance=..$(dr)] run tag @s add airdef.dive
$execute facing $(x) $(y) $(z) run tp @s ^ ^ ^$(s) ~ ~
$execute if entity @s[tag=airdef.dive] positioned $(x) $(y) $(z) if entity @s[distance=..2] run tag @s add airdef.boom
@@ -0,0 +1 @@
kill @s
@@ -0,0 +1,10 @@
# поражён ПВО в воздухе: вспышка, дальше падает горящим
particle minecraft:explosion_emitter ~ ~ ~ 0 0 0 0 1 force
particle minecraft:flash{color:[1.0,0.85,0.5,1.0]} ~ ~ ~ 0 0 0 0 1 force
particle minecraft:large_smoke ~ ~ ~ 1 1 1 0.05 30 force
particle minecraft:flame ~ ~ ~ 1 1 1 0.15 30 force
playsound minecraft:entity.generic.explode master @a ~ ~ ~ 10 0.8
scoreboard players add $kills airdef.kills 1
tag @s add airdef.falling
tag @s remove airdef.engaged
scoreboard players set @s airdef.life 300
@@ -0,0 +1,8 @@
# Герань-3: реактивный, быстрый, лёгкая БЧ
summon marker ~ ~ ~ {Tags:["airdef.drone","airdef.geran3","airdef.new"],data:{prefix:"geran3",dy:-0.5d,top:200,step:200,np:6,name:"Герань-3"}}
execute as @e[type=marker,tag=airdef.new] run function airdef:drone/common
scoreboard players add @e[type=marker,tag=airdef.new] airdef.cy 60
scoreboard players set @e[type=marker,tag=airdef.new] airdef.spd 160
scoreboard players set @e[type=marker,tag=airdef.new] airdef.dr 45
scoreboard players set @e[type=marker,tag=airdef.new] airdef.life 1200
tag @e[type=marker,tag=airdef.new] remove airdef.new
@@ -0,0 +1,8 @@
# Шахед-136 / Герань-2: медленный, тяжёлая БЧ, пикирует на цель
summon marker ~ ~ ~ {Tags:["airdef.drone","airdef.shahed","airdef.heavy","airdef.new"],data:{prefix:"shahed",dy:-0.5d,top:200,step:200,np:6,name:"Шахед-136"}}
execute as @e[type=marker,tag=airdef.new] run function airdef:drone/common
scoreboard players add @e[type=marker,tag=airdef.new] airdef.cy 45
scoreboard players set @e[type=marker,tag=airdef.new] airdef.spd 60
scoreboard players set @e[type=marker,tag=airdef.new] airdef.dr 28
scoreboard players set @e[type=marker,tag=airdef.new] airdef.life 2400
tag @e[type=marker,tag=airdef.new] remove airdef.new
@@ -0,0 +1,21 @@
scoreboard players remove @s airdef.life 1
execute if entity @s[tag=airdef.falling] run return run function airdef:drone/fall
execute if score @s airdef.life matches ..0 run return run function airdef:drone/impact
execute store result storage airdef:args x double 1 run scoreboard players get @s airdef.tx
execute store result storage airdef:args z double 1 run scoreboard players get @s airdef.tz
execute store result storage airdef:args y double 1 run scoreboard players get @s airdef.cy
execute if entity @s[tag=airdef.dive] store result storage airdef:args y double 1 run scoreboard players get @s airdef.ty
execute store result storage airdef:args s double 0.01 run scoreboard players get @s airdef.spd
execute store result storage airdef:args dr int 1 run scoreboard players get @s airdef.dr
function airdef:drone/move with storage airdef:args
execute at @s unless block ~ ~ ~ #minecraft:air run tag @s add airdef.boom
execute if entity @s[tag=airdef.boom] at @s run return run function airdef:drone/impact
execute at @s run function airdef:visual/update
# выхлоп и звук двигателя
execute at @s if entity @s[tag=airdef.shahed] run particle minecraft:smoke ^ ^ ^-1.6 0.03 0.03 0.03 0 1 force
execute at @s if entity @s[tag=airdef.geran3] run particle minecraft:small_flame ^ ^0.3 ^-1.4 0.02 0.02 0.02 0 1 force
execute at @s if entity @s[tag=airdef.geran3] run particle minecraft:smoke ^ ^0.3 ^-1.8 0.05 0.05 0.05 0 2 force
scoreboard players operation $m airdef.tmp = @s airdef.life
scoreboard players operation $m airdef.tmp %= $20 airdef.tmp
execute if score $m airdef.tmp matches 0 if entity @s[tag=airdef.shahed] at @s run playsound minecraft:entity.bee.loop hostile @a ~ ~ ~ 6 0.5
execute if score $m airdef.tmp matches 0 if entity @s[tag=airdef.geran3] at @s run playsound minecraft:entity.elytra.flying hostile @a ~ ~ ~ 4 1.6
@@ -0,0 +1,5 @@
give @s carrot_on_a_stick[custom_name={"text":"Целеуказатель","color":"red","italic":false},lore=[{"text":"Q (бросить): отметить цель для дронов","color":"gray"}],custom_data={airdef:"target"}]
give @s carrot_on_a_stick[custom_name={"text":"Пуск: Шахед-136","color":"yellow","italic":false},lore=[{"text":"Q (бросить): запустить дрон на ближайшую цель","color":"gray"}],custom_data={airdef:"shahed"}]
give @s carrot_on_a_stick[custom_name={"text":"Пуск: Герань-3 (реактивный)","color":"yellow","italic":false},lore=[{"text":"Q (бросить): быстрый реактивный дрон","color":"gray"}],custom_data={airdef:"geran3"}]
give @s carrot_on_a_stick[custom_name={"text":"Развернуть: Patriot","color":"aqua","italic":false},lore=[{"text":"Q (бросить): ЗРК большой дальности перед вами","color":"gray"}],custom_data={airdef:"patriot"}]
give @s carrot_on_a_stick[custom_name={"text":"Развернуть: Гепард","color":"aqua","italic":false},lore=[{"text":"Q (бросить): ЗСУ ближнего рубежа перед вами","color":"gray"}],custom_data={airdef:"gepard"}]
@@ -0,0 +1,31 @@
# AirDef: дальнобойные дроны и ПВО
scoreboard objectives add airdef.t dummy
scoreboard objectives add airdef.tmp dummy
scoreboard objectives add airdef.id dummy
scoreboard objectives add airdef.tid dummy
scoreboard objectives add airdef.life dummy
scoreboard objectives add airdef.spd dummy
scoreboard objectives add airdef.tx dummy
scoreboard objectives add airdef.ty dummy
scoreboard objectives add airdef.tz dummy
scoreboard objectives add airdef.cy dummy
scoreboard objectives add airdef.dr dummy
scoreboard objectives add airdef.cd dummy
scoreboard objectives add airdef.ammo dummy
scoreboard objectives add airdef.pk dummy
scoreboard objectives add airdef.px dummy
scoreboard objectives add airdef.py dummy
scoreboard objectives add airdef.pz dummy
scoreboard objectives add airdef.kills dummy
scoreboard players set $2 airdef.tmp 2
scoreboard players set $4 airdef.tmp 4
scoreboard players set $10 airdef.tmp 10
scoreboard players set $20 airdef.tmp 20
scoreboard players set $225 airdef.tmp 225
scoreboard players set $3600 airdef.tmp 3600
execute unless score $next airdef.id matches 1.. run scoreboard players set $next airdef.id 1
bossbar add airdef:alert "Воздушная тревога"
bossbar set airdef:alert color red
bossbar set airdef:alert style notched_10
bossbar set airdef:alert max 10
tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"загружен. Меню: ","color":"gray"},{"text":"/function airdef:menu","color":"yellow","click_event":{"action":"run_command","command":"/function airdef:menu"}}]
@@ -0,0 +1,5 @@
tellraw @s {"text":"===== AirDef =====","color":"gold"}
tellraw @s [{"text":"[Выдать пульты] ","color":"green","click_event":{"action":"run_command","command":"/function airdef:give"}},{"text":"[Цель здесь] ","color":"red","click_event":{"action":"run_command","command":"/function airdef:target/here"}},{"text":"[Убрать цели]","color":"gray","click_event":{"action":"run_command","command":"/function airdef:target/clear"}}]
tellraw @s [{"text":"Налёт: ","color":"gray"},{"text":"[3 Шахеда] ","color":"yellow","click_event":{"action":"run_command","command":"/function airdef:wave/start {type:\"shahed\",count:3,dist:150}"}},{"text":"[8 Шахедов] ","color":"yellow","click_event":{"action":"run_command","command":"/function airdef:wave/start {type:\"shahed\",count:8,dist:160}"}},{"text":"[4 Герань-3] ","color":"yellow","click_event":{"action":"run_command","command":"/function airdef:wave/start {type:\"geran3\",count:4,dist:180}"}}]
tellraw @s [{"text":"ПВО (перед вами): ","color":"gray"},{"text":"[Patriot] ","color":"aqua","click_event":{"action":"run_command","command":"/function airdef:sam/place {type:\"patriot\"}"}},{"text":"[Гепард] ","color":"aqua","click_event":{"action":"run_command","command":"/function airdef:sam/place {type:\"gepard\"}"}},{"text":"[Свернуть ближайший]","color":"gray","click_event":{"action":"run_command","command":"/function airdef:sam/remove_nearest"}}]
tellraw @s [{"text":"[Очистить небо] ","color":"dark_red","click_event":{"action":"run_command","command":"/function airdef:clear_all"}},{"text":"[Статистика]","color":"gray","click_event":{"action":"run_command","command":"/function airdef:stats"}}]
@@ -0,0 +1,5 @@
tag @e[tag=airdef.cur] remove airdef.engaged
tag @e[tag=airdef.cur] remove airdef.cur
particle minecraft:explosion ~ ~ ~ 0.5 0.5 0.5 0 3 force
playsound minecraft:entity.firework_rocket.blast master @a ~ ~ ~ 6 0.6
kill @s
@@ -0,0 +1,4 @@
execute store result score $r airdef.tmp run random value 1..100
execute if score $r airdef.tmp <= @s airdef.pk as @e[tag=airdef.cur,limit=1] at @s run function airdef:drone/shot
execute if score $r airdef.tmp > @s airdef.pk run tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"Промах перехватчика","color":"gray"}]
function airdef:missile/fizzle
@@ -0,0 +1 @@
$execute facing entity @e[tag=airdef.cur,limit=1] feet run tp @s ^ ^ ^$(s) ~ ~
@@ -0,0 +1,16 @@
scoreboard players remove @s airdef.life 1
execute if score @s airdef.life matches ..0 run return run function airdef:missile/fizzle
# своя цель по id
tag @e[tag=airdef.cur] remove airdef.cur
scoreboard players operation $t airdef.tmp = @s airdef.tid
execute as @e[type=marker,tag=airdef.drone,tag=!airdef.falling] if score @s airdef.id = $t airdef.tmp run tag @s add airdef.cur
execute unless entity @e[tag=airdef.cur] run return run function airdef:missile/fizzle
execute if entity @e[tag=airdef.cur,distance=..3] run return run function airdef:missile/hit
# 8 тиков вертикальный старт, потом наведение
execute if score @s airdef.life matches 193.. run tp @s ~ ~1.5 ~ ~ -90
execute store result storage airdef:args s double 0.01 run scoreboard players get @s airdef.spd
execute if score @s airdef.life matches ..192 run function airdef:missile/move with storage airdef:args
execute at @s run function airdef:visual/update
execute at @s run particle minecraft:flame ^ ^ ^-1.2 0.05 0.05 0.05 0.01 2 force
execute at @s run particle minecraft:cloud ^ ^ ^-1.6 0.1 0.1 0.1 0.01 3 force
execute at @s if entity @e[tag=airdef.cur,distance=..3] run function airdef:missile/hit
@@ -0,0 +1,3 @@
scoreboard players operation @s airdef.id = $next airdef.id
scoreboard players add $next airdef.id 1
tag @s add airdef.logic
@@ -0,0 +1 @@
$execute on origin at @s run function airdef:player/use_$(airdef)
@@ -0,0 +1,6 @@
# Пульт срабатывает, если его бросить (Q), и сразу возвращается бросившему:
# ПКМ и Shift в тиковых функциях Horizon пока не видны.
tag @s add airdef.used
function airdef:player/act with entity @s Item.components."minecraft:custom_data"
data modify entity @s PickupDelay set value 0s
execute on origin at @s run tp @e[type=item,tag=airdef.used,sort=nearest,limit=1] ~ ~ ~
@@ -0,0 +1 @@
function airdef:sam/place {type:"gepard"}
@@ -0,0 +1 @@
function airdef:drone/launch {type:"geran3"}
@@ -0,0 +1 @@
function airdef:sam/place {type:"patriot"}
@@ -0,0 +1 @@
function airdef:drone/launch {type:"shahed"}
@@ -0,0 +1 @@
function airdef:target/look
@@ -0,0 +1,10 @@
# ЗСУ Gepard: корпус из двух блоков, башня с пушками — поворотная модель
$summon marker ~ ~ ~ {Tags:["airdef.sam","airdef.gepard","airdef.new"],Rotation:[$(yaw)f,0f],data:{prefix:"gepard_turret",dy:1.0d,top:750,step:250,np:4,byaw:$(yaw),kind:"gepard"}}
$execute rotated $(yaw) 0 run setblock ^ ^ ^1 airdef:gepard_front[facing=$(f)]
$execute rotated $(yaw) 0 run setblock ^ ^ ^-2 airdef:gepard_rear[facing=$(f)]
execute as @e[type=marker,tag=airdef.new] run function airdef:new_id
scoreboard players set @e[tag=airdef.new] airdef.ammo 60
scoreboard players set @e[tag=airdef.new] airdef.cd 20
tag @e[tag=airdef.new] remove airdef.new
playsound minecraft:block.anvil.place master @a ~ ~ ~ 2 0.8
tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"Гепард развёрнут: дальность 40, 2×35 мм","color":"aqua"}]
@@ -0,0 +1,10 @@
# ПУ M903: тягач + полуприцеп (блоки), пакет ТПК — поворотная модель
$summon marker ~ ~ ~ {Tags:["airdef.sam","airdef.patriot","airdef.new"],Rotation:[$(yaw)f,0f],data:{prefix:"patriot_box",dy:1.0d,top:0,step:100,np:1,byaw:$(yaw),kind:"patriot"}}
$execute rotated $(yaw) 0 run setblock ^ ^ ^ airdef:patriot_trailer[facing=$(f)]
$execute rotated $(yaw) 0 run setblock ^ ^ ^3 airdef:patriot_truck[facing=$(f)]
execute as @e[type=marker,tag=airdef.new] run function airdef:new_id
scoreboard players set @e[tag=airdef.new] airdef.ammo 4
scoreboard players set @e[tag=airdef.new] airdef.cd 40
tag @e[tag=airdef.new] remove airdef.new
playsound minecraft:block.anvil.place master @a ~ ~ ~ 2 0.6
tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"Patriot развёрнут: дальность 160, 4 ракеты PAC-3","color":"aqua"}]
@@ -0,0 +1,6 @@
# сопровождение ближайшей цели башней, огонь на дальности 40
execute as @e[type=marker,tag=airdef.drone,tag=!airdef.falling,distance=..48,sort=nearest,limit=1] run tag @s add airdef.pick
execute if entity @e[tag=airdef.pick] positioned ~ ~1.6 ~ facing entity @e[tag=airdef.pick,limit=1] feet positioned ~ ~-1.6 ~ run tp @s ~ ~ ~ ~ ~
execute if score @s airdef.cd matches ..0 if score @s airdef.ammo matches ..0 run function airdef:sam/reload {ammo:60,time:240,name:"Гепард"}
execute if score @s airdef.cd matches ..0 if entity @e[tag=airdef.pick,distance=..40] run function airdef:sam/gepard_fire
tag @e[tag=airdef.pick] remove airdef.pick
@@ -0,0 +1,14 @@
# очередь из двух стволов: трассеры, шанс поражения 10 % за очередь
scoreboard players set $d airdef.tmp 22
execute positioned ~ ~1.6 ~ positioned ^0.9 ^ ^1.4 facing entity @e[tag=airdef.pick,limit=1] feet run function airdef:sam/tracer
scoreboard players set $d airdef.tmp 22
execute positioned ~ ~1.6 ~ positioned ^-0.9 ^ ^1.4 facing entity @e[tag=airdef.pick,limit=1] feet run function airdef:sam/tracer
execute positioned ~ ~1.6 ~ positioned ^0.9 ^ ^1.6 run particle minecraft:flash{color:[1.0,0.85,0.4,1.0]} ~ ~ ~ 0 0 0 0 1 force
execute positioned ~ ~1.6 ~ positioned ^-0.9 ^ ^1.6 run particle minecraft:flash{color:[1.0,0.85,0.4,1.0]} ~ ~ ~ 0 0 0 0 1 force
execute positioned ~ ~1.6 ~ run particle minecraft:smoke ^ ^ ^1.6 0.4 0.2 0.4 0.02 6 force
playsound minecraft:entity.generic.explode master @a ~ ~ ~ 3 2
playsound minecraft:block.note_block.snare master @a ~ ~ ~ 6 0.5
execute store result score $r airdef.tmp run random value 1..100
execute if score $r airdef.tmp matches ..10 as @e[tag=airdef.pick,limit=1] at @s run function airdef:drone/shot
scoreboard players remove @s airdef.ammo 1
scoreboard players set @s airdef.cd 3
@@ -0,0 +1,5 @@
execute if score @s airdef.cd matches 1.. run return 0
execute if score @s airdef.ammo matches ..0 run return run function airdef:sam/reload {ammo:4,time:300,name:"Patriot"}
execute as @e[type=marker,tag=airdef.drone,tag=!airdef.falling,tag=!airdef.engaged,distance=8..160,sort=nearest,limit=1] run tag @s add airdef.pick
execute if entity @e[tag=airdef.pick] run function airdef:sam/patriot_fire
tag @e[tag=airdef.pick] remove airdef.pick
@@ -0,0 +1,18 @@
# развернуть ПУ на цель и пустить ракету из пакета
execute facing entity @e[tag=airdef.pick,limit=1] feet run tp @s ~ ~ ~ ~ 0
scoreboard players operation $t airdef.tmp = @e[tag=airdef.pick,limit=1] airdef.id
tag @e[tag=airdef.pick] add airdef.engaged
execute rotated ~ 0 positioned ^ ^2.4 ^-0.6 run summon marker ~ ~ ~ {Tags:["airdef.missile","airdef.new"],Rotation:[0f,-90f],data:{prefix:"pac3",dy:-0.5d,top:900,step:225,np:9}}
execute as @e[type=marker,tag=airdef.new] run function airdef:new_id
scoreboard players operation @e[tag=airdef.new] airdef.tid = $t airdef.tmp
scoreboard players set @e[tag=airdef.new] airdef.life 200
scoreboard players set @e[tag=airdef.new] airdef.pk 90
scoreboard players set @e[tag=airdef.new] airdef.spd 300
tag @e[tag=airdef.new] remove airdef.new
scoreboard players remove @s airdef.ammo 1
scoreboard players set @s airdef.cd 30
playsound minecraft:entity.firework_rocket.launch master @a ~ ~ ~ 10 0.5
playsound minecraft:entity.generic.explode master @a ~ ~ ~ 6 1.6
execute rotated ~ 0 positioned ^ ^2.4 ^-0.6 run particle minecraft:flash{color:[1.0,0.9,0.6,1.0]} ~ ~ ~ 0 0 0 0 1 force
execute rotated ~ 0 positioned ^ ^1.5 ^1 run particle minecraft:cloud ~ ~ ~ 1.2 0.6 1.2 0.08 80 force
execute rotated ~ 0 positioned ^ ^1 ^2 run particle minecraft:campfire_cosy_smoke ~ ~ ~ 1 0.3 1 0.02 25 force
@@ -0,0 +1,11 @@
# развернуть комплекс в 7 блоках перед игроком, носом по взгляду (4 стороны). Аргумент: type
execute store result score $yaw airdef.tmp run data get entity @s Rotation[0] 10
scoreboard players add $yaw airdef.tmp 5850
scoreboard players operation $yaw airdef.tmp %= $3600 airdef.tmp
scoreboard players set $900 airdef.tmp 900
scoreboard players operation $yaw airdef.tmp /= $900 airdef.tmp
execute if score $yaw airdef.tmp matches 0 run data modify storage airdef:b f set value {f:"north",yaw:180}
execute if score $yaw airdef.tmp matches 1 run data modify storage airdef:b f set value {f:"east",yaw:-90}
execute if score $yaw airdef.tmp matches 2 run data modify storage airdef:b f set value {f:"south",yaw:0}
execute if score $yaw airdef.tmp matches 3 run data modify storage airdef:b f set value {f:"west",yaw:90}
$execute rotated ~ 0 positioned ^ ^ ^7 align xyz positioned ~0.5 ~ ~0.5 run function airdef:sam/build_$(type) with storage airdef:b f
@@ -0,0 +1,3 @@
$scoreboard players set @s airdef.ammo $(ammo)
$scoreboard players set @s airdef.cd $(time)
$tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"$(name): перезарядка","color":"gray"}]
@@ -0,0 +1,3 @@
function airdef:sam/remove_blocks with entity @s data
kill @s
tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"Комплекс ПВО свёрнут","color":"gray"}]
@@ -0,0 +1,4 @@
$execute if data entity @s {data:{kind:"patriot"}} rotated $(byaw) 0 run setblock ^ ^ ^ air
$execute if data entity @s {data:{kind:"patriot"}} rotated $(byaw) 0 run setblock ^ ^ ^3 air
$execute if data entity @s {data:{kind:"gepard"}} rotated $(byaw) 0 run setblock ^ ^ ^1 air
$execute if data entity @s {data:{kind:"gepard"}} rotated $(byaw) 0 run setblock ^ ^ ^-2 air
@@ -0,0 +1 @@
execute as @e[type=marker,tag=airdef.sam,sort=nearest,limit=1] at @s run function airdef:sam/remove
@@ -0,0 +1,4 @@
scoreboard players remove @s[scores={airdef.cd=1..}] airdef.cd 1
execute if entity @s[tag=airdef.patriot] run function airdef:sam/patriot
execute if entity @s[tag=airdef.gepard] run function airdef:sam/gepard
function airdef:visual/update
@@ -0,0 +1,4 @@
particle minecraft:dust{color:[1.0,0.75,0.3],scale:0.7} ~ ~ ~ 0 0 0 0 1 force
scoreboard players remove $d airdef.tmp 1
execute if entity @e[tag=airdef.pick,distance=..2] run return run particle minecraft:crit ~ ~ ~ 0.5 0.5 0.5 0.3 8 force
execute if score $d airdef.tmp matches 1.. positioned ^ ^ ^2 run function airdef:sam/tracer
@@ -0,0 +1,2 @@
execute store result score $air airdef.tmp if entity @e[type=marker,tag=airdef.drone,tag=!airdef.falling]
tellraw @s [{"text":"[AirDef] ","color":"gold"},{"text":"Сбито: ","color":"gray"},{"score":{"name":"$kills","objective":"airdef.kills"},"color":"green"},{"text":" | в воздухе: ","color":"gray"},{"score":{"name":"$air","objective":"airdef.tmp"},"color":"red"}]
@@ -0,0 +1,2 @@
kill @e[type=marker,tag=airdef.target]
tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"Цели убраны","color":"gray"}]
@@ -0,0 +1 @@
execute align xyz positioned ~0.5 ~ ~0.5 run function airdef:target/make
@@ -0,0 +1,3 @@
# луч из глаз до первого твёрдого блока, максимум 256 блоков
scoreboard players set $ray airdef.tmp 256
execute anchored eyes positioned ^ ^ ^ run function airdef:target/ray
@@ -0,0 +1,4 @@
summon marker ~ ~ ~ {Tags:["airdef.target"]}
playsound minecraft:block.note_block.bit master @a ~ ~ ~ 2 0.6
particle minecraft:dust{color:[1.0,0.1,0.1],scale:3.0} ~ ~1 ~ 0.2 2 0.2 0 60 force
tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"Цель отмечена","color":"red"}]
@@ -0,0 +1,3 @@
scoreboard players remove $ray airdef.tmp 1
execute unless block ~ ~ ~ #minecraft:air align xyz positioned ~0.5 ~1 ~0.5 run return run function airdef:target/make
execute if score $ray airdef.tmp matches 1.. positioned ^ ^ ^1 run function airdef:target/ray
@@ -0,0 +1 @@
particle minecraft:dust{color:[1.0,0.1,0.1],scale:2.0} ~ ~0.5 ~ 0.3 0.6 0.3 0 6 force
@@ -0,0 +1,9 @@
scoreboard players add $tick airdef.t 1
scoreboard players operation $m10 airdef.tmp = $tick airdef.t
scoreboard players operation $m10 airdef.tmp %= $10 airdef.tmp
execute as @e[type=item,tag=!airdef.used] if data entity @s Item.components."minecraft:custom_data".airdef run function airdef:player/dropped
execute if score $m10 airdef.tmp matches 0 as @e[type=marker,tag=airdef.target] at @s run function airdef:target/tick
execute as @e[type=marker,tag=airdef.drone] at @s run function airdef:drone/tick
execute as @e[type=marker,tag=airdef.sam] at @s run function airdef:sam/tick
execute as @e[type=marker,tag=airdef.missile] at @s run function airdef:missile/tick
execute if score $m10 airdef.tmp matches 0 run function airdef:alert/update
@@ -0,0 +1,3 @@
scoreboard players set $mx airdef.tmp 0
scoreboard players set $my airdef.tmp 0
scoreboard players set $mz airdef.tmp 0
@@ -0,0 +1 @@
$summon falling_block ~ ~$(dy) ~ {NoGravity:1b,Time:599,DropItem:0b,Motion:[$(mx)d,$(my)d,$(mz)d],BlockState:{Name:"airdef:$(prefix)_p$(i)_y$(j)",Properties:{facing:"$(f)"}}}
@@ -0,0 +1,57 @@
# Модель объекта — falling_block с моделью блока airdef:<prefix>_p<i>_y<j>[facing].
# В Horizon falling_block не виден селекторам (его нельзя ни сдвинуть, ни убить),
# зато он читает Time и Motion и исчезает при Time > 600. Поэтому каждый тик ставится новый
# с Time:599 и скоростью объекта: он живёт один тик и плавно интерполируется.
# Вызывается как логический маркер после движения. Параметры — в data маркера:
# prefix, dy (смещение по высоте), top/step/np (тангаж: верхний угол ×10, шаг ×10, число ступеней).
execute store result score $yaw airdef.tmp run data get entity @s Rotation[0] 10
execute store result score $pit airdef.tmp run data get entity @s Rotation[1] 10
# курс модели = yaw - 180°, 16 секторов по 22.5°: facing (по 90°) + доворот j
scoreboard players add $yaw airdef.tmp 5512
scoreboard players operation $yaw airdef.tmp %= $3600 airdef.tmp
scoreboard players operation $yaw airdef.tmp /= $225 airdef.tmp
scoreboard players operation $f airdef.tmp = $yaw airdef.tmp
scoreboard players operation $f airdef.tmp /= $4 airdef.tmp
execute store result storage airdef:v j int 1 run scoreboard players operation $yaw airdef.tmp %= $4 airdef.tmp
# тангаж: индекс ступени = round((top + pitch) / step)
execute store result score $vtop airdef.tmp run data get entity @s data.top
execute store result score $vstep airdef.tmp run data get entity @s data.step
execute store result score $vnp airdef.tmp run data get entity @s data.np
scoreboard players operation $pit airdef.tmp += $vtop airdef.tmp
scoreboard players operation $h airdef.tmp = $vstep airdef.tmp
scoreboard players operation $h airdef.tmp /= $2 airdef.tmp
scoreboard players operation $pit airdef.tmp += $h airdef.tmp
execute if score $pit airdef.tmp matches ..-1 run scoreboard players set $pit airdef.tmp 0
scoreboard players operation $pit airdef.tmp /= $vstep airdef.tmp
scoreboard players remove $vnp airdef.tmp 1
execute if score $pit airdef.tmp > $vnp airdef.tmp run scoreboard players operation $pit airdef.tmp = $vnp airdef.tmp
execute store result storage airdef:v i int 1 run scoreboard players get $pit airdef.tmp
execute if score $f airdef.tmp matches 0 run data modify storage airdef:v f set value "north"
execute if score $f airdef.tmp matches 1 run data modify storage airdef:v f set value "east"
execute if score $f airdef.tmp matches 2 run data modify storage airdef:v f set value "south"
execute if score $f airdef.tmp matches 3 run data modify storage airdef:v f set value "west"
# скорость = смещение с прошлого тика (×1000), телепорты и первый тик — без скорости
execute store result score $x airdef.tmp run data get entity @s Pos[0] 1000
execute store result score $y airdef.tmp run data get entity @s Pos[1] 1000
execute store result score $z airdef.tmp run data get entity @s Pos[2] 1000
scoreboard players operation $mx airdef.tmp = $x airdef.tmp
scoreboard players operation $mx airdef.tmp -= @s airdef.px
scoreboard players operation $my airdef.tmp = $y airdef.tmp
scoreboard players operation $my airdef.tmp -= @s airdef.py
scoreboard players operation $mz airdef.tmp = $z airdef.tmp
scoreboard players operation $mz airdef.tmp -= @s airdef.pz
execute unless score @s airdef.px matches -2147483648.. run function airdef:visual/still
execute unless score $mx airdef.tmp matches -5000..5000 run function airdef:visual/still
execute unless score $my airdef.tmp matches -5000..5000 run function airdef:visual/still
execute unless score $mz airdef.tmp matches -5000..5000 run function airdef:visual/still
# у земли не опускать: иначе блок «приземлится» и встанет в мир
execute if score $my airdef.tmp matches ..-1 unless block ~ ~-1.5 ~ #minecraft:air run scoreboard players set $my airdef.tmp 0
scoreboard players operation @s airdef.px = $x airdef.tmp
scoreboard players operation @s airdef.py = $y airdef.tmp
scoreboard players operation @s airdef.pz = $z airdef.tmp
execute store result storage airdef:v mx double 0.001 run scoreboard players get $mx airdef.tmp
execute store result storage airdef:v my double 0.001 run scoreboard players get $my airdef.tmp
execute store result storage airdef:v mz double 0.001 run scoreboard players get $mz airdef.tmp
data modify storage airdef:v prefix set from entity @s data.prefix
data modify storage airdef:v dy set from entity @s data.dy
function airdef:visual/summon with storage airdef:v
@@ -0,0 +1,6 @@
# случайный азимут и разброс по дальности
execute store result storage airdef:wave a.yaw int 1 run random value 0..359
execute store result storage airdef:wave a.extra int 1 run random value 0..40
function airdef:wave/one with storage airdef:wave a
scoreboard players remove $wave airdef.tmp 1
execute if score $wave airdef.tmp matches 1.. run function airdef:wave/loop
@@ -0,0 +1 @@
$execute rotated $(yaw) 0 positioned ^ ^ ^$(dist) positioned ^ ^ ^$(extra) positioned ~ ~50 ~ rotated ~180 0 run function airdef:drone/spawn_$(type)
@@ -0,0 +1,7 @@
# налёт к ближайшей цели. Аргументы: type, count, dist
execute unless entity @e[type=marker,tag=airdef.target] run return run tellraw @s [{"text":"[AirDef] ","color":"gold"},{"text":"Сначала отметьте цель","color":"red"}]
$scoreboard players set $wave airdef.tmp $(count)
$data modify storage airdef:wave a set value {type:"$(type)",dist:$(dist)}
execute as @e[type=marker,tag=airdef.target,sort=nearest,limit=1] at @s run function airdef:wave/loop
$tellraw @a [{"text":"[AirDef] ","color":"gold"},{"text":"ВОЗДУШНАЯ ТРЕВОГА: $(count) × $(type)","color":"red","bold":true}]
playsound minecraft:event.raid.horn master @a ~ ~ ~ 1000 1