From 797fa071bc39c8a51553e26debfad353ff293435 Mon Sep 17 00:00:00 2001 From: Ponpon Date: Wed, 15 Jan 2025 20:43:39 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A8=E3=83=B3=E3=83=86=E3=82=A3=E3=83=86?= =?UTF-8?q?=E3=82=A3=E3=81=AE=E3=83=80=E3=83=A1=E3=83=BC=E3=82=B8=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20(#674)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/entity/damage_type/magic.json | 5 +++++ data/entity/damage_type/physical.json | 5 +++++ data/entity/damage_type/unreasonable.json | 5 +++++ data/entity/function/damage/apply/.mcfunction | 11 +++++++++++ .../function/damage/apply/core/.mcfunction | 15 +++++++++++++++ .../damage/apply/core/apply.macro.mcfunction | 3 +++ .../function/damage/apply/core/mob.mcfunction | 11 +++++++++++ .../damage/apply/core/player.mcfunction | 12 ++++++++++++ .../resolve_percentage_damage/.mcfunction | 12 ++++++++++++ .../resolve_percentage_damage/mob.mcfunction | 6 ++++++ .../player.mcfunction | 6 ++++++ .../function/damage/apply/magic.mcfunction | 9 +++++++++ .../function/damage/apply/physical.mcfunction | 9 +++++++++ .../damage/apply/unreasonable.mcfunction | 9 +++++++++ data/entity/predicate/damage/check_death.json | 19 +++++++++++++++++++ .../tags/damage_type/bypasses_cooldown.json | 8 ++++---- .../tags/damage_type/no_knockback.json | 8 ++++---- 17 files changed, 145 insertions(+), 8 deletions(-) create mode 100644 data/entity/damage_type/magic.json create mode 100644 data/entity/damage_type/physical.json create mode 100644 data/entity/damage_type/unreasonable.json create mode 100644 data/entity/function/damage/apply/.mcfunction create mode 100644 data/entity/function/damage/apply/core/.mcfunction create mode 100644 data/entity/function/damage/apply/core/apply.macro.mcfunction create mode 100644 data/entity/function/damage/apply/core/mob.mcfunction create mode 100644 data/entity/function/damage/apply/core/player.mcfunction create mode 100644 data/entity/function/damage/apply/core/resolve_percentage_damage/.mcfunction create mode 100644 data/entity/function/damage/apply/core/resolve_percentage_damage/mob.mcfunction create mode 100644 data/entity/function/damage/apply/core/resolve_percentage_damage/player.mcfunction create mode 100644 data/entity/function/damage/apply/magic.mcfunction create mode 100644 data/entity/function/damage/apply/physical.mcfunction create mode 100644 data/entity/function/damage/apply/unreasonable.mcfunction create mode 100644 data/entity/predicate/damage/check_death.json diff --git a/data/entity/damage_type/magic.json b/data/entity/damage_type/magic.json new file mode 100644 index 0000000000..06a4578468 --- /dev/null +++ b/data/entity/damage_type/magic.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0, + "scaling": "never", + "message_id": "tusb:magic" +} diff --git a/data/entity/damage_type/physical.json b/data/entity/damage_type/physical.json new file mode 100644 index 0000000000..02d33f7972 --- /dev/null +++ b/data/entity/damage_type/physical.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0, + "scaling": "never", + "message_id": "tusb:physical" +} diff --git a/data/entity/damage_type/unreasonable.json b/data/entity/damage_type/unreasonable.json new file mode 100644 index 0000000000..79e5e14b48 --- /dev/null +++ b/data/entity/damage_type/unreasonable.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0, + "scaling": "never", + "message_id": "tusb:unreasonable" +} diff --git a/data/entity/function/damage/apply/.mcfunction b/data/entity/function/damage/apply/.mcfunction new file mode 100644 index 0000000000..221f1b563b --- /dev/null +++ b/data/entity/function/damage/apply/.mcfunction @@ -0,0 +1,11 @@ +#> entity:damage/apply/ +# 設定された物理、魔法、理外のダメージを実行者に与える。 + +# 物理ダメージ +function entity:damage/apply/physical + +# 魔法ダメージ +function entity:damage/apply/magic + +# 理外ダメージ +function entity:damage/apply/unreasonable diff --git a/data/entity/function/damage/apply/core/.mcfunction b/data/entity/function/damage/apply/core/.mcfunction new file mode 100644 index 0000000000..3ddc9a2543 --- /dev/null +++ b/data/entity/function/damage/apply/core/.mcfunction @@ -0,0 +1,15 @@ +#> entity:damage/apply/core/ + +## ダメージ処理の実行チェック +# ダメージ値が指定されていなければ中断 +execute unless data storage entity:_ damage.value run return fail +# 実行者が死亡していれば中断 +execute if predicate entity:damage/check_death run return fail + + +# ダメージ値が割合設定ならば解決する +execute if data storage entity:_ damage.value{} run function entity:damage/apply/core/resolve_percentage_damage/ + +# 実行者のentity_typeによって処理を変更する +execute if entity @s[type=player] run function entity:damage/apply/core/player +execute unless entity @s[type=player] run function entity:damage/apply/core/mob diff --git a/data/entity/function/damage/apply/core/apply.macro.mcfunction b/data/entity/function/damage/apply/core/apply.macro.mcfunction new file mode 100644 index 0000000000..72ebdff876 --- /dev/null +++ b/data/entity/function/damage/apply/core/apply.macro.mcfunction @@ -0,0 +1,3 @@ +#> entity:damage/apply/core/apply.macro +# 受け取ったダメージ属性とダメージ値からdamageコマンドを実行する +$damage @s $(value) $(type) diff --git a/data/entity/function/damage/apply/core/mob.mcfunction b/data/entity/function/damage/apply/core/mob.mcfunction new file mode 100644 index 0000000000..9f52798f40 --- /dev/null +++ b/data/entity/function/damage/apply/core/mob.mcfunction @@ -0,0 +1,11 @@ +#> entity:damage/apply/core/mob +# モブへダメージを与える + +# damageコマンドを実行する +function entity:damage/apply/core/apply.macro with storage entity:_ damage + +# HPを更新する +function enemy:damage/update_health + +# Hitダメージフラグを付与 +execute if data storage entity: damage{hit:1b} run tag @s add HitDamageTaken diff --git a/data/entity/function/damage/apply/core/player.mcfunction b/data/entity/function/damage/apply/core/player.mcfunction new file mode 100644 index 0000000000..367b13f77a --- /dev/null +++ b/data/entity/function/damage/apply/core/player.mcfunction @@ -0,0 +1,12 @@ +#> entity:damage/apply/core/player +# プレイヤーへダメージを与える + +# カスタム死亡ログがあればそれを表示するためにデフォルト死亡ログを非表示 +execute if data storage entity: damage.deathcause run gamerule showDeathMessages false + +# damageコマンドを実行する +function entity:damage/apply/core/apply.macro with storage entity:_ damage + +# カスタム死亡ログがあって死亡すればログを表示 +execute if data storage entity: damage.deathcause if data entity @s {Health:0f} run tellraw @a {"storage":"entity:","nbt":"damage.deathcause","interpret":true} +execute if data storage entity: damage.deathcause run gamerule showDeathMessages true diff --git a/data/entity/function/damage/apply/core/resolve_percentage_damage/.mcfunction b/data/entity/function/damage/apply/core/resolve_percentage_damage/.mcfunction new file mode 100644 index 0000000000..006df6bf45 --- /dev/null +++ b/data/entity/function/damage/apply/core/resolve_percentage_damage/.mcfunction @@ -0,0 +1,12 @@ +#> entity:damage/apply/core/resolve_percentage_damage/ +# 割合ダメージを実際のダメージへ計算する + +# 計算に必要な数値をentity_typeに合わせて取得する +execute if entity @s[type=player] run function entity:damage/apply/core/resolve_percentage_damage/player +execute unless entity @s[type=player] run function entity:damage/apply/core/resolve_percentage_damage/mob + +# 計算 +execute store result score _ _ run data get storage entity:_ damage.value.percent 100 +scoreboard players operation _ HP *= _ _ +data modify storage entity:_ damage.value set value 0d +execute store result storage entity:_ damage.value double 0.01 run scoreboard players get _ HP diff --git a/data/entity/function/damage/apply/core/resolve_percentage_damage/mob.mcfunction b/data/entity/function/damage/apply/core/resolve_percentage_damage/mob.mcfunction new file mode 100644 index 0000000000..d9d224ebef --- /dev/null +++ b/data/entity/function/damage/apply/core/resolve_percentage_damage/mob.mcfunction @@ -0,0 +1,6 @@ +#> entity:damage/apply/core/resolve_percentage_damage/mob + +# 現在HPを取得 +execute if data storage entity:_ damage.value{select:"current"} run scoreboard players operation _ HP = @s HP +# 最大HPを取得 +execute if data storage entity:_ damage.value{select:"max"} run scoreboard players operation _ HP = @s HPMax diff --git a/data/entity/function/damage/apply/core/resolve_percentage_damage/player.mcfunction b/data/entity/function/damage/apply/core/resolve_percentage_damage/player.mcfunction new file mode 100644 index 0000000000..da78de5b1a --- /dev/null +++ b/data/entity/function/damage/apply/core/resolve_percentage_damage/player.mcfunction @@ -0,0 +1,6 @@ +#> entity:damage/apply/core/resolve_percentage_damage/player + +# 現在HPを取得 +execute if data storage entity:_ damage.value{select:"current"} store result score _ HP run data get entity @s Health +# 最大HPを取得 +execute if data storage entity:_ damage.value{select:"max"} store result score _ HP run attribute @s generic.max_health get diff --git a/data/entity/function/damage/apply/magic.mcfunction b/data/entity/function/damage/apply/magic.mcfunction new file mode 100644 index 0000000000..1104a3dd40 --- /dev/null +++ b/data/entity/function/damage/apply/magic.mcfunction @@ -0,0 +1,9 @@ +#> entity:damage/apply/magic +# 設定された魔法ダメージを実行者に与える + +# このダメージについての指定 +data modify storage entity:_ damage set value {type:"entity:magic"} +data modify storage entity:_ damage.value set from storage entity: damage.magic + +# core処理を実行 +function entity:damage/apply/core/ diff --git a/data/entity/function/damage/apply/physical.mcfunction b/data/entity/function/damage/apply/physical.mcfunction new file mode 100644 index 0000000000..d38ea8facd --- /dev/null +++ b/data/entity/function/damage/apply/physical.mcfunction @@ -0,0 +1,9 @@ +#> entity:damage/apply/physical +# 設定された物理ダメージを実行者に与える + +# このダメージについての指定 +data modify storage entity:_ damage set value {type:"entity:physical"} +data modify storage entity:_ damage.value set from storage entity: damage.physical + +# core処理を実行 +function entity:damage/apply/core/ diff --git a/data/entity/function/damage/apply/unreasonable.mcfunction b/data/entity/function/damage/apply/unreasonable.mcfunction new file mode 100644 index 0000000000..e2b0c0accf --- /dev/null +++ b/data/entity/function/damage/apply/unreasonable.mcfunction @@ -0,0 +1,9 @@ +#> entity:damage/apply/unreasonable +# 設定された理外ダメージを実行者に与える + +# このダメージについての指定 +data modify storage entity:_ damage set value {type:"entity:unreasonable"} +data modify storage entity:_ damage.value set from storage entity: damage.unreasonable + +# core処理を実行 +function entity:damage/apply/core/ diff --git a/data/entity/predicate/damage/check_death.json b/data/entity/predicate/damage/check_death.json new file mode 100644 index 0000000000..5a86f7874a --- /dev/null +++ b/data/entity/predicate/damage/check_death.json @@ -0,0 +1,19 @@ +{ + "condition": "any_of", + "terms": [ + { + "condition": "entity_properties", + "entity": "this", + "predicate": { + "nbt": "{Health:0f}" + } + }, + { + "condition": "entity_properties", + "entity": "this", + "predicate": { + "nbt": "{Tags:[Garbage]}" + } + } + ] +} diff --git a/data/minecraft/tags/damage_type/bypasses_cooldown.json b/data/minecraft/tags/damage_type/bypasses_cooldown.json index 5d68a24c36..c1b11a642d 100644 --- a/data/minecraft/tags/damage_type/bypasses_cooldown.json +++ b/data/minecraft/tags/damage_type/bypasses_cooldown.json @@ -1,7 +1,7 @@ { "values": [ - "tusb:unreasonable", - "tusb:magic", - "tusb:physics" + "entity:physical", + "entity:magic", + "entity:unreasonable" ] -} \ No newline at end of file +} diff --git a/data/minecraft/tags/damage_type/no_knockback.json b/data/minecraft/tags/damage_type/no_knockback.json index 5d68a24c36..c1b11a642d 100644 --- a/data/minecraft/tags/damage_type/no_knockback.json +++ b/data/minecraft/tags/damage_type/no_knockback.json @@ -1,7 +1,7 @@ { "values": [ - "tusb:unreasonable", - "tusb:magic", - "tusb:physics" + "entity:physical", + "entity:magic", + "entity:unreasonable" ] -} \ No newline at end of file +}