text:
#> asset:teleporter/example2147483646/register
#
#
#
# @within function asset:teleporter/example2147483646/

# 重複防止レジストリに登録
    data modify storage asset:teleporter DPR append value {D:overworld,X:20,Y:13,Z:41}

# ID (int)
    data modify storage asset:teleporter ID set value 2147483646
# GroupID (string)
    data modify storage asset:teleporter GroupID set value "example"
# デフォルトの起動状態 ("InvisibleDeactivate" | "VisibleDeactivate" | "Activate")
    data modify storage asset:teleporter ActivationState set value "Activate"
# 色 ("white" | "aqua")
    data modify storage asset:teleporter Color set value "white"

# 登録
    function asset:teleporter/common/register


text:
#> asset:teleporter/example2147483647/register
#
#
#
# @within function asset:teleporter/example2147483647/

# 重複防止レジストリに登録
    data modify storage asset:teleporter DPR append value {D:overworld,X:39,Y:7,Z:-5}

# ID (int)
    data modify storage asset:teleporter ID set value 2147483647
# GroupID (string)
    data modify storage asset:teleporter GroupID set value "example"
# デフォルトの起動状態 ("InvisibleDeactivate" | "VisibleDeactivate" | "Activate")
    data modify storage asset:teleporter ActivationState set value "Activate"
# 色 ("white" | "aqua")
    data modify storage asset:teleporter Color set value "aqua"

# 登録
    function asset:teleporter/common/register

repo_name: ProjectTSB/TheSkyBlessing

repo_language: mcfunction

mime_type: text/plain


text:
#> asset:teleporter/common/register
#
#
#
# @input storage asset:teleporter
#   ID : int
#   GroupID : string
#   ActivationState : string("InvisibleDeactivate","VisibleDeactivate","Activate")
#   Color? : string("white","aqua")(default: "white")
# @within function asset:teleporter/*/register

# パラメータチェック
    execute unless data storage asset:teleporter ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ID","color":"red"}]
    execute unless data storage asset:teleporter GroupID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" GroupID","color":"red"}]
    execute unless data storage asset:teleporter ActivationState run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ActivationState","color":"red"}]
    execute unless data storage asset:teleporter Color run data modify storage asset:teleporter Color set value "white"
# 登録
    function asset_manager:teleporter/register/
# リセット
    data remove storage asset:teleporter ID
    data remove storage asset:teleporter GroupID
    data remove storage asset:teleporter ActivationState
    data remove storage asset:teleporter Color


text:
#> asset:artifact/example/give/2.give
#
# 神器の作成部 ここでID等を定義する
#
# @user
# @private

# 神器の説明や消費MPなどをここで設定する。
# 最後にasset:artifact/common/giveを実行することで入手可能。

data modify storage asset:artifact ID set value 2147483647
data modify storage asset:artifact Item set value "minecraft:raw_gold"
data modify storage asset:artifact Name set value '{"text":"雷のブローチ","color":"yellow"}'
data modify storage asset:artifact Lore set value ['{"text":"攻撃を与えたとき、対象に"}','{"text":"現在体力に依存した割合攻撃を追加与える"}','{"text":""}']
# data modify storage asset:artifact CostText set value '{"text":""}'
data modify storage asset:artifact RemainingCount set value 50
data modify storage asset:artifact Slot set value "hotbar"
data modify storage asset:artifact Trigger set value "onAttack"
# data modify storage asset:artifact Condition set value '{"text":""}'
# data modify storage asset:artifact AttackInfo set value {Damage:[0,0],AttackType:[Physical,Magic],ElementType:[Fire,Water,Thunder,None],BypassResist:1b,IsrangeAttack:never}
data modify storage asset:artifact MPCost set value 20
# data modify storage asset:artifact MPRequire set value 100
data modify storage asset:artifact LocalCooldown set value 40
# data modify storage asset:artifact SpecialCooldown set value 5
data modify storage asset:artifact CanUsedGod set value ["Flora","Nyaptov","Wi-ki"]
# data modify storage asset:artifact CustomNBT set value {Unbreakable:1b}

function asset:artifact/common/give


text:
#> asset:artifact/example/trigger/2.check_condition
#
# 神器の発動条件をチェックします
#
# @within function asset:artifact/example/trigger/1.trigger

# 神器IDの設定
    data modify storage asset:artifact TargetID set value 2147483647
# 神器の基本的な条件の確認を行うfunction、成功している場合CanUsedタグが付く
    function asset:artifact/common/check_condition/hotbar
# CanUsedタグをチェックして3.main.mcfunctionを実行する
    execute if entity @s[tag=CanUsed] run function asset:artifact/example/trigger/3.main


text:
#> asset:artifact/example/trigger/3.main
#
# 神器のメイン処理部
#
# @within function asset:artifact/example/trigger/2.check_condition

#> health
# @private
    #declare score_holder $Health
    #declare score_holder $Count

# 基本的な使用時の処理(MP消費や使用回数の処理など)を行う
    function asset:artifact/common/use/hotbar

# ここから先は神器側の効果の処理を書く
# VFX
    execute at @e[type=#lib:living,type=!player,tag=Victim,distance=..70,limit=1] run particle dust 100000000 100000000 0 1 ~ ~1.5 ~ 0.05 1 0.05 0 150
    execute at @e[type=#lib:living,type=!player,tag=Victim,distance=..70,limit=1] run playsound entity.lightning_bolt.impact player @a
# 個数を取得
    execute store result score $Count Temporary if data storage asset:context Items.hotbar[{tag:{TSB:{ID:2147483647}}}]
# ダメージ
    execute store result score $Health Temporary run data get entity @e[type=#lib:living,type=!player,tag=Victim,distance=..70,limit=1] AbsorptionAmount 100
    scoreboard players operation $Count Temporary *= $5 Const
    scoreboard players operation $Count Temporary += $10 Const
    scoreboard players operation $Health Temporary *= $Count Temporary
    scoreboard players operation $Health Temporary /= $100 Const
    execute store result storage lib: Argument.Damage float 0.01 run scoreboard players get $Health Temporary
# ダメージ/その他の設定
    data modify storage lib: Argument.AttackType set value "Magic"
    data modify storage lib: Argument.ElementType set value "Thunder"
    data modify storage lib: Argument.FixedDamage set value 1b
    function lib:damage/modifier
    execute as @e[type=#lib:living,type=!player,tag=Victim,distance=..70,limit=1] run function lib:damage/


text:
#> asset:artifact/example/trigger/1.trigger
#
# 指定したイベントタイミングで実行されるfunction
# ここで自身の神器が判定をしてmain処理を呼び出す
#
# @within tag/function asset:artifact/**

# storage asset:context idのfeet/legs/chest/head/mainhand/offhandに装備している神器のIDが入っているので比較し、~/2.check_condition.mcfunctionを実行する
    execute if data storage asset:context id{hotbar:[2147483647]} run function asset:artifact/example/trigger/2.check_condition


text:
#> asset:artifact/common/give
#
# 神器を入手します
#
# @input storage asset:artifact
#   ID : int
#   Item : ItemID
#   Name : TextComponent
#   Lore : TextComponent[]
#   RemainingCount? : int
#   Slot : Slot
#   Trigger : Trigger
#   Condition? : TextComponent
#   AttackInfo? : Component
#   MPCost : int
#   MPRequire? : int
#   CostText? : TextComponent
#   LocalCooldown? : int
#   SpecialCooldown? : int
#   DisableCooldownMessage? : boolean
#   DisableMPMessage? : boolean
#   CanUsedGod : God[]
# @output item 神器
# @within function asset:artifact/*/give/2.give

#> Inv
# @private
#declare score_holder $InvSize

# storage検証
    execute unless data storage asset:artifact ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ID","color":"red"}]
    execute unless data storage asset:artifact Item run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Item","color":"red"}]
    execute unless data storage asset:artifact Name run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Name","color":"red"}]
    execute unless data storage asset:artifact Lore run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Lore","color":"red"}]
    execute unless data storage asset:artifact Slot run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Slot","color":"red"}]
    execute unless data storage asset:artifact Trigger run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Trigger","color":"red"}]
    execute unless data storage asset:artifact MPCost run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" MPCost","color":"red"}]
    execute unless data storage asset:artifact CanUsedGod run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" CanUsedGod","color":"red"}]
# 各データ設定
    function asset_manager:artifact/create/set_data
# 神器排出
    execute unless data storage asset:context Type run data modify storage asset:context Type set value "give"
    # execute if data storage asset:context {Type:"box"} // 何もする必要がない
    execute if data storage asset:context {Type:"drop"} run loot spawn ~ ~ ~ mine 10000 0 10000 debug_stick
    execute if data storage asset:context {Type:"drop",Important:true} as @e[type=item,nbt={Item:{tag:{TSB:{}}}},distance=..0.3] run function asset:artifact/common/protect
    execute if data storage asset:context {Type:"give"} run function api:inventory/get_size
    execute if data storage asset:context {Type:"give"} if score $InvSize Lib matches ..35 run loot give @s mine 10000 0 10000 debug_stick
    execute if data storage asset:context {Type:"give"} if score $InvSize Lib matches 36.. run loot spawn ~ ~ ~ mine 10000 0 10000 debug_stick
    execute if data storage asset:context {Type:"give"} if score $InvSize Lib matches 36.. as @e[type=item,nbt={Item:{tag:{TSB:{}}}},distance=..0.3] run function asset:artifact/common/protect
    execute if data storage asset:context {Type:"replace"} run function asset:artifact/common/replace

# リセット
    scoreboard players reset $InvSize Lib
    data remove storage asset:context Type
    data remove storage asset:artifact ID
    data remove storage asset:artifact Item
    data remove storage asset:artifact Name
    data remove storage asset:artifact Lore
    data remove storage asset:artifact RemainingCount
    data remove storage asset:artifact Slot
    data remove storage asset:artifact Trigger
    data remove storage asset:artifact Condition
    data remove storage asset:artifact AttackInfo
    data remove storage asset:artifact MPCost
    data remove storage asset:artifact MPRequire
    data remove storage asset:artifact CostText
    data remove storage asset:artifact CanUsedGod
    data remove storage asset:artifact CustomNBT
    data remove storage asset:artifact LocalCooldown
    data remove storage asset:artifact SpecialCooldown
    data remove storage asset:artifact DisableCooldownMessage
    data remove storage asset:artifact DisableMPMessage


text:
#> asset:artifact/common/replace
#
# 直接特定Slotに神器を配置します
#
# @within function asset:artifact/common/give

# storageチェック
    execute unless data storage asset:context Slot run data modify storage asset:context Slot set value "mainhand"

# slot指定replace
    execute if data storage asset:context {Slot:"mainhand"} run item replace entity @s weapon.mainhand from block 10000 0 10000 container.0
    execute if data storage asset:context {Slot:"offhand"} run item replace entity @s weapon.offhand from block 10000 0 10000 container.0
    execute if data storage asset:context {Slot:"feet"} run item replace entity @s armor.feet from block 10000 0 10000 container.0
    execute if data storage asset:context {Slot:"legs"} run item replace entity @s armor.legs from block 10000 0 10000 container.0
    execute if data storage asset:context {Slot:"chest"} run item replace entity @s armor.chest from block 10000 0 10000 container.0
    execute if data storage asset:context {Slot:"head"} run item replace entity @s armor.head from block 10000 0 10000 container.0

# リセット
    data remove storage asset:context Slot


text:
#> asset:artifact/common/_index.d
# @private

#> ReturnTag
# @within function
#   asset:artifact/*/*/2.check_condition
#   asset:artifact/*/*/2.check_condition/**
#   asset_manager:artifact/check/
#   asset:artifact/common/use/*
    #declare tag CanUsed

#> 処理用一時storage
# @within * asset:**
    #declare storage asset:temp


text:
#> asset:artifact/common/protect
#
#
#
# @within function asset:artifact/common/give

data modify entity @s Glowing set value true
data modify entity @s NoGravity set value true
data modify entity @s Age set value -32768
data modify entity @s Invulnerable set value true
data modify entity @s Motion set value [0d,0d,0d]
data modify entity @s Fire set value 2s


text:
#> asset:artifact/common/use/chest
#
# チェストプレートの神器の使用時共通処理を実行します
#
# @within function asset:artifact/*/*/3.main

data modify storage asset:artifact TargetSlot set value 'chest'
function asset_manager:artifact/use/
tag @s remove CanUsed


text:
#> asset:artifact/common/use/offhand
#
# オフハンドの神器の使用時共通処理を実行します
#
# @within function asset:artifact/*/*/3.main

data modify storage asset:artifact TargetSlot set value 'offhand'
function asset_manager:artifact/use/
tag @s remove CanUsed


text:
#> asset:artifact/common/use/feet
#
# ブーツの神器の使用時共通処理を実行します
#
# @within function asset:artifact/*/*/3.main

data modify storage asset:artifact TargetSlot set value 'feet'
function asset_manager:artifact/use/
tag @s remove CanUsed


text:
#> asset:artifact/common/use/hotbar
#
# チェストプレートの神器の使用時共通処理を実行します
#
# @within function asset:artifact/*/*/3.main

data modify storage asset:artifact TargetSlot set value 'hotbar'
function asset_manager:artifact/use/
tag @s remove CanUsed


text:
#> asset:artifact/common/use/head
#
# ヘルメットの神器の使用時共通処理を実行します
#
# @within function asset:artifact/*/*/3.main

data modify storage asset:artifact TargetSlot set value 'head'
function asset_manager:artifact/use/
tag @s remove CanUsed


text:
#> asset:artifact/common/use/mainhand
#
# メインハンドの神器の使用時共通処理を実行します
#
# @within function asset:artifact/*/*/3.main

data modify storage asset:artifact TargetSlot set value 'mainhand'
function asset_manager:artifact/use/
tag @s remove CanUsed


text:
#> asset:artifact/common/use/auto
#
# 神器の使用時共通処理を実行します
#
# @within function asset:artifact/*/*/3.main

data modify storage asset:artifact TargetSlot set value 'auto'
function asset_manager:artifact/use/
tag @s remove CanUsed


text:
#> asset:artifact/common/use/legs
#
# レギンスの神器の使用時共通処理を実行します
#
# @within function asset:artifact/*/*/3.main

data modify storage asset:artifact TargetSlot set value 'legs'
function asset_manager:artifact/use/
tag @s remove CanUsed


text:
#> asset:artifact/common/check_condition/chest
#
# チェストプレートの神器の基礎的な発動条件をチェックします
#
# 発動可能な場合実行者に`CanUsed`のtagが付与されます。
#
# @output tag @s CanUsed
# @within function asset:artifact/*/*/2.check_condition

data modify storage asset:artifact TargetSlot set value 'chest'
function asset_manager:artifact/check/


text:
#> asset:artifact/common/check_condition/offhand
#
# オフハンドの神器の基礎的な発動条件をチェックします
#
# 発動可能な場合実行者に`CanUsed`のtagが付与されます。
#
# @output tag @s CanUsed
# @within function asset:artifact/*/*/2.check_condition

data modify storage asset:artifact TargetSlot set value 'offhand'
function asset_manager:artifact/check/


text:
#> asset:artifact/common/check_condition/feet
#
# ブーツの神器の基礎的な発動条件をチェックします
#
# 発動可能な場合実行者に`CanUsed`のtagが付与されます。
#
# @output tag @s CanUsed
# @within function asset:artifact/*/*/2.check_condition

data modify storage asset:artifact TargetSlot set value 'feet'
function asset_manager:artifact/check/


text:
#> asset:artifact/common/check_condition/hotbar
#
# ヘルメットの神器の基礎的な発動条件をチェックします
#
# 発動可能な場合実行者に`CanUsed`のtagが付与されます。
#
# @output tag @s CanUsed
# @within function asset:artifact/*/*/2.check_condition

data modify storage asset:artifact TargetSlot set value 'hotbar'
function asset_manager:artifact/check/


text:
#> asset:artifact/common/check_condition/head
#
# ヘルメットの神器の基礎的な発動条件をチェックします
#
# 発動可能な場合実行者に`CanUsed`のtagが付与されます。
#
# @output tag @s CanUsed
# @within function asset:artifact/*/*/2.check_condition

data modify storage asset:artifact TargetSlot set value 'head'
function asset_manager:artifact/check/


text:
#> asset:artifact/common/check_condition/mainhand
#
# メインハンドの神器の基礎的な発動条件をチェックします
#
# 発動可能な場合実行者に`CanUsed`のtagが付与されます。
#
# @input as player
# @output tag @s CanUsed
# @within function asset:artifact/*/*/2.check_condition

data modify storage asset:artifact TargetSlot set value 'mainhand'
function asset_manager:artifact/check/


text:
#> asset:artifact/common/check_condition/auto
#
# 神器の基礎的な発動条件をチェックします
#
# 発動可能な場合実行者に`CanUsed`のtagが付与されます。
#
# @output tag @s CanUsed
# @within function asset:artifact/*/*/2.check_condition

data modify storage asset:artifact TargetSlot set value 'auto'
function asset_manager:artifact/check/


text:
#> asset:artifact/common/check_condition/legs
#
# レギンスの神器の基礎的な発動条件をチェックします
#
# 発動可能な場合実行者に`CanUsed`のtagが付与されます。
#
# @output tag @s CanUsed
# @within function asset:artifact/*/*/2.check_condition

data modify storage asset:artifact TargetSlot set value 'legs'
function asset_manager:artifact/check/


text:
#> asset:mob/super.tick
#
#
#
# @within function asset:mob/*/tick/

function asset_manager:mob/triggers/tick/call_super_method


text:
#> asset:mob/super.death
#
#
#
# @within function asset:mob/*/death/

function asset_manager:mob/triggers/death/call_super_method


text:
#> asset:mob/super.hurt
#
#
#
# @within function asset:mob/*/hurt/

function asset_manager:mob/triggers/hurt/call_super_method


text:
#> asset:mob/extends
#
#
#
# @within function asset:mob/*/register

# 既存にasset:context idが存在する場合に備えて退避させる
    function asset_manager:common/context_id/stash

# ID
    data modify storage asset:context id set from storage asset:mob Extends[-1]

# データを取得
    function #asset:mob/register
# データチェック
    execute unless data storage asset:mob ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"次のIDのMobは存在しません: "},{"storage":"asset:context","nbt":"id"}]
    execute unless data storage asset:mob {ExtendsSafe:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"次のIDのMobを継承することは出来ません: "},{"storage":"asset:context","nbt":"id"}]

# リセット
    data remove storage asset:mob ExtendsSafe

# 退避させたデータを戻す
    function asset_manager:common/context_id/pop


text:
#> asset:mob/super.attack
#
#
#
# @within function asset:mob/*/attack/

function asset_manager:mob/triggers/attack/call_super_method


text:
#> asset:mob/ex.2/register
#
#
#
# @within function asset:mob/ex.2/_/register

# extends
    data modify storage asset:mob Extends append value 65534
    function asset:mob/extends

# ExtendsSafe (boolean) (オプション)
    data modify storage asset:mob ExtendsSafe set value true
# ID (int)
    data modify storage asset:mob ID set value 65533
# 防具
    # 頭 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Head set value {id:"minecraft:golden_helmet",Count:1b}
    # 胴 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Chest set value {id:"minecraft:golden_chestplate",Count:1b}
    # 脚 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Legs set value {id:"minecraft:golden_leggings",Count:1b}
    # 足 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Feet set value {id:"minecraft:golden_boots",Count:1b}
# フィールド
    data modify storage asset:mob Field.myValue set value "ex.2"


text:
#> asset:mob/ex.2/_/register
#
#
#
# @within tag/function asset:mob/register

execute if data storage asset:context {id:65533} run function asset:mob/ex.2/register


text:
#> asset:mob/ex.2/_/summon
#
#
#
# @within tag/function asset:mob/summon

execute if data storage asset:context {id:65533} run function asset:mob/ex.2/summon/


text:
#> asset:mob/ex.2/_/tick
#
#
#
# @within tag/function asset:mob/tick

execute if data storage asset:context {id:65533} run function asset:mob/ex.2/tick/


text:
#> asset:mob/example/death/2.death
#
# Mobの死亡時の処理
#
# @within function asset:mob/example/death/1.trigger

tellraw @a [{"selector":"@a[tag=Killer]"},{"text":"ばいばい...."}]
execute at @a[tag=Killer] run summon lightning_bolt


text:
#> asset:mob/example/death/1.trigger
#
# Mobの死亡時に実行されるfunction
#
# @within tag/function asset:mob/death

execute if data storage asset:context {id:2147483647} run function asset:mob/example/death/2.death


text:
#> asset:mob/example/summon/2.summon
#
# Mobの召喚時の処理
#
# @within function asset:mob/example/summon/1.trigger

# 元となるMobを召喚する
    summon zombie ~ ~ ~ {Tags:["MobInit","AntiVoid"],DeathLootTable:"asset:mob/death/example"}
# ID (int)
    data modify storage asset:mob ID set value 2147483647
# Type (string) Wikiを参照
    data modify storage asset:mob Type set value "Enemy.Boss"
# 干渉可能か否か (boolean)
    data modify storage asset:mob Interferable set value true
# 名前 (TextComponentString) (オプション)
    data modify storage asset:mob Name set value '{"text":"サンプルの敵"}'
# 体力 (double) (オプション)
    data modify storage asset:mob Health set value 100.0
# 武器
    # メインハンド (Compound(Item)) (オプション)
        data modify storage asset:mob Weapon.Mainhand set value {id:"minecraft:iron_sword",Count:1b}
    # オフハンド (Compound(Item)) (オプション)
        # data modify storage asset:mob Weapon.Offhand set value
# 防具
    # 頭 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Head set value {id:"minecraft:iron_helmet",Count:1b}
    # 胴 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Chest set value {id:"minecraft:iron_chestplate",Count:1b}
    # 脚 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Legs set value {id:"minecraft:iron_leggings",Count:1b}
    # 足 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Feet set value {id:"minecraft:iron_boots",Count:1b}
# 攻撃力 (double) (オプション)
    data modify storage asset:mob AttackDamage set value 2.0
# 防御力 (double) (オプション) // 被ダメージがある程度大きい場合1ptにつき0.8%カット、小さい場合1ptにつき約4%カット 20pt以上は頭打ち
    data modify storage asset:mob Defense set value 0.0
# 特殊防御力 (double) (オプション) // 4pointにつきダメージを大きく減らす
    data modify storage asset:mob SpecialDefense set value 0.0
# 移動速度 (double) (オプション)
    data modify storage asset:mob Speed set value 0.23
# 索敵範囲 (double) (オプション)
    data modify storage asset:mob FollowRange set value 32.0
# ノックバック耐性 (double) (オプション)
    data modify storage asset:mob KnockBackResist set value 0
# 属性倍率 // 防御力,特殊防御力による軽減計算前に計算
    # 物理倍率 (int) (オプション)
        data modify storage asset:mob Resist.Physical set value 0.85f
    # 魔法倍率 (int) (オプション)
        data modify storage asset:mob Resist.Magic set value 2f
    # 火倍率 (int) (オプション)
        data modify storage asset:mob Resist.Fire set value 0.2f
    # 水倍率 (int) (オプション)
        data modify storage asset:mob Resist.Water set value 2f
    # 雷倍率 (int) (オプション)
        data modify storage asset:mob Resist.Thunder set value 0.6f

# MobInitタグ持ちを対象にして召喚関数呼び出し
    execute as @e[type=zombie,tag=MobInit,distance=..0.01] run function asset:mob/common/summon


text:
#> asset:mob/example/summon/1.trigger
#
# Mob召喚処理の呼び出し時に実行されるfunction
#
# @within tag/function asset:mob/summon

execute if data storage asset:context {id:2147483647} run function asset:mob/example/summon/2.summon


text:
#> asset:mob/example/hurt/2.hurt
#
# Mobの被ダメージ時の処理
#
# @within function asset:mob/example/hurt/1.trigger

tellraw @a [{"selector":"@a[tag=Attacker]"},{"text":"痛いよ..."}]


text:
#> asset:mob/example/hurt/1.trigger
#
# Mobの被ダメージ時に呼び出されるfunction
#
# @within tag/function asset:mob/hurt

execute if data storage asset:context {id:2147483647} run function asset:mob/example/hurt/2.hurt


text:
#> asset:mob/example/attack/1.trigger
#
# Mobの攻撃時に実行されるfunction
#
# @within tag/function asset:mob/attack

execute if data storage asset:context {id:2147483647} run function asset:mob/example/attack/2.attack


text:
#> asset:mob/example/attack/2.attack
#
# Mobの攻撃時の処理
#
# @within function asset:mob/example/attack/1.trigger

tellraw @a [{"selector":"@a[tag=Victim]"},{"text":"なんて死んじゃえ！"}]


text:
#> asset:mob/example/tick/2.tick
#
# Mobのtick時の処理
#
# @within function asset:mob/example/tick/1.trigger

particle composter ~ ~1 ~ 0.4 0.4 0.4 0 10


text:
#> asset:mob/example/tick/1.trigger
#
# Mobが生きている間毎tick実行されるfunction
#
# @within tag/function asset:mob/tick

execute if data storage asset:context {id:2147483647} run function asset:mob/example/tick/2.tick


text:
#> asset:mob/ex.1/register
#
#
#
# @within function asset:mob/ex.1/_/register

# ExtendsSafe (boolean) (オプション)
    data modify storage asset:mob ExtendsSafe set value true
# ID (int)
    data modify storage asset:mob ID set value 65534
# Type (string) Wikiを参照
    data modify storage asset:mob Type set value "Enemy.Boss"
# 干渉可能か否か (boolean)
    data modify storage asset:mob Interferable set value true
# 名前 (TextComponentString) (オプション)
    data modify storage asset:mob Name set value '{"text":"サンプルの敵"}'
# 体力 (double) (オプション)
    data modify storage asset:mob Health set value 100.0
# 武器
    # メインハンド (Compound(Item)) (オプション)
        data modify storage asset:mob Weapon.Mainhand set value {id:"minecraft:iron_sword",Count:1b}
    # オフハンド (Compound(Item)) (オプション)
        # data modify storage asset:mob Weapon.Offhand set value
# 防具
    # 頭 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Head set value {id:"minecraft:iron_helmet",Count:1b}
    # 胴 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Chest set value {id:"minecraft:iron_chestplate",Count:1b}
    # 脚 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Legs set value {id:"minecraft:iron_leggings",Count:1b}
    # 足 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Feet set value {id:"minecraft:iron_boots",Count:1b}
# フィールド
    data modify storage asset:mob Field.myValue set value "ex.1"


text:
#> asset:mob/ex.1/_/register
#
#
#
# @within tag/function asset:mob/register

execute if data storage asset:context {id:65534} run function asset:mob/ex.1/register


text:
#> asset:mob/ex.1/_/summon
#
#
#
# @within tag/function asset:mob/summon

execute if data storage asset:context {id:65534} run function asset:mob/ex.1/summon/


text:
#> asset:mob/ex.1/_/hurt
#
#
#
# @within tag/function asset:mob/hurt

execute if data storage asset:context {id:65534} run function asset:mob/ex.1/hurt/


text:
#> asset:mob/ex.1/_/tick
#
#
#
# @within tag/function asset:mob/tick

execute if data storage asset:context {id:65534} run function asset:mob/ex.1/tick/


text:
#> asset:mob/ex.3/register
#
#
#
# @within function asset:mob/ex.3/_/register

# extends
    data modify storage asset:mob Extends append value 65533
    function asset:mob/extends

# ID (int)
    data modify storage asset:mob ID set value 65532
# 防具
    # 頭 (Compound(Item)) (オプション)
        data modify storage asset:mob Armor.Head set value {id:"minecraft:diamond_helmet",Count:1b}
# フィールド
    data modify storage asset:mob Field.myValue set value "ex.3"


text:
#> asset:mob/ex.3/_/register
#
#
#
# @within tag/function asset:mob/register

execute if data storage asset:context {id:65532} run function asset:mob/ex.3/register


text:
#> asset:mob/ex.3/_/summon
#
#
#
# @within tag/function asset:mob/summon

execute if data storage asset:context {id:65532} run function asset:mob/ex.3/summon/


text:
#> asset:mob/common/summon
#
# 召喚されたMobにデータを適用します
#
# @input storage asset:mob
#   ID : int
#   Type : string
#   Interferable : boolean
#   Name? : TextComponentString
#   Weapon.Mainhand? : Item
#   Weapon.Offhand? : Item
#   Armor.Head? : Item
#   Armor.Chest? : Item
#   Armor.Legs? : Item
#   Armor.Feet? : Item
#   Health? : double (x <= 2147483.647)
#   AttackDamage? : double (x <= 2048.0)
#   Defense? : double (x <= 30.0)
#   SpecialDefense? : double (x <= 20.0)
#   Speed? : double (x <= 1024.0)
#   FollowRange? : double (x <= 2048.0)
#   KnockBackResist? : double (x <= 1.0)
#   Resist.Physical? : float
#   Resist.Magic? : float
#   Resist.Fire? : float
#   Resist.Water? : float
#   Resist.Thunder? : float
#   Field? : compound
#   FieldOverride? : compound
# @output storage asset:mob Return.Summoned : boolean
# @within function
#   api:mob/core/summon
#   asset:mob/*/summon/2.summon

# validate
    execute unless entity @s run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"データを適用するEntityが存在しません\nasを利用して対象のEntityを実行者にしてください"}]
    execute unless data storage asset:mob ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ID","color":"red"}]
    execute unless data storage asset:mob Type run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Type","color":"red"}]
    execute unless data storage asset:mob Interferable run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" Interferable","color":"red"}]
    # execute unless data storage asset:mob Name run
    execute unless data storage asset:mob Weapon.Mainhand run data modify storage asset:mob Weapon.Mainhand set value {}
    execute unless data storage asset:mob Weapon.Offhand run data modify storage asset:mob Weapon.Offhand set value {}
    execute unless data storage asset:mob Armor.Head run data modify storage asset:mob Armor.Head set value {}
    execute unless data storage asset:mob Armor.Chest run data modify storage asset:mob Armor.Chest set value {}
    execute unless data storage asset:mob Armor.Legs run data modify storage asset:mob Armor.Legs set value {}
    execute unless data storage asset:mob Armor.Feet run data modify storage asset:mob Armor.Feet set value {}
    execute unless data storage asset:mob WeaponDropChances run data modify storage asset:mob WeaponDropChances set value [0f,0f]
    execute unless data storage asset:mob ArmorDropChances run data modify storage asset:mob ArmorDropChances set value [0f,0f,0f,0f]
    execute unless data storage asset:mob Health store result storage asset:mob Health double 0.01 run attribute @s generic.max_health get 100
    # execute unless data storage asset:mob AttackDamage run
    # execute unless data storage asset:mob Defense run
    # execute unless data storage asset:mob SpecialDefense run
    # execute unless data storage asset:mob Speed run
    # execute unless data storage asset:mob FollowRange run
    # execute unless data storage asset:mob KnockBackResist run
    execute unless data storage asset:mob Resist.Physical run data modify storage asset:mob Resist.Physical set value 1f
    execute unless data storage asset:mob Resist.Magic run data modify storage asset:mob Resist.Magic set value 1f
    execute unless data storage asset:mob Resist.Fire run data modify storage asset:mob Resist.Fire set value 1f
    execute unless data storage asset:mob Resist.Water run data modify storage asset:mob Resist.Water set value 1f
    execute unless data storage asset:mob Resist.Thunder run data modify storage asset:mob Resist.Thunder set value 1f
    # execute unless data storage asset:mob Field run
# データ適用
    execute if entity @s run function asset_manager:mob/summon/set_data
# リセット
    tag @s remove MobInit

# 初期化イベント
    execute if entity @s run function #asset:mob/initialize

# 返り値
    data modify storage asset:mob Return.Summoned set value true

# リセット
    data remove storage asset:mob ID
    data remove storage asset:mob Type
    data remove storage asset:mob Interferable
    data remove storage asset:mob Name
    data remove storage asset:mob Weapon
    data remove storage asset:mob Armor
    data remove storage asset:mob Health
    data remove storage asset:mob AttackDamage
    data remove storage asset:mob Defense
    data remove storage asset:mob SpecialDefense
    data remove storage asset:mob Speed
    data remove storage asset:mob FollowRange
    data remove storage asset:mob KnockBackResist
    data remove storage asset:mob Resist
    data remove storage asset:mob Field
    data remove storage asset:mob FieldOverride


text:
#> asset:trader/example/register/register
#
#
#
# @within function asset:trader/example/register/

# ID (int)
    data modify storage asset:trader ID set value -2147483647
# 名前 (TextComponent) (オプション)
    data modify storage asset:trader Name set value '{"text":"未知の商人"}'
# 方向 (float) (オプション)
    data modify storage asset:trader Rotation set value 180f
# 取引
    data modify storage asset:trader Trades append value {}
    # 要求物1 (int(artifactID) | { id: string, Count: byte } | { PresetItem: string(preset), Count: byte })
        data modify storage asset:trader Trades[-1].BuyA set value {PresetItem:"currency/high",Count:16b}
    # 要求物2 (int(artifactID) | { id: string, Count: byte } | { PresetItem: string(preset), Count: byte }) (オプション)
        data modify storage asset:trader Trades[-1].BuyB set value {id:"minecraft:egg",Count:1b}
    # 販売物 (int(artifactID) | { id: string, Count: byte } | { PresetItem: string(preset), Count: byte })
        data modify storage asset:trader Trades[-1].Sell set value 1
    # 取引可能回数 (int) (オプション)
        data modify storage asset:trader Trades[-1].MaxUses set value 5

# 登録
    function asset:trader/common/register


text:
#> asset:trader/common/register
#
#
#
# @within function asset:trader/*/register/register

# パラメータチェック
    execute unless data storage asset:trader ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ID","color":"red"}]
# 登録
    function asset_manager:trader/register/
# リセット
    data remove storage asset:trader ID
    data remove storage asset:trader Name
    data remove storage asset:trader Rotation
    data remove storage asset:trader Trades


text:
#> asset:spawner/example/register
#
#
#
# @within function asset:spawner/example/

# ID (int)
    data modify storage asset:spawner ID set value 2147483647
# 体力 (int) このスポナーから召喚されたMobがN体殺されると破壊されるか
    data modify storage asset:spawner HP set value 1
# SpawnPotentials(int | int[] | ({ Weight: int, Id: int })[]) MobAssetのIDを指定する
    data modify storage asset:spawner SpawnPotentials set value 2147483647
# 一度に召喚する数 (int)
    data modify storage asset:spawner SpawnCount set value 1
# 動作範囲 (int) この範囲にプレイヤーが存在するとき、Mobの召喚を開始する
    data modify storage asset:spawner SpawnRange set value 8
# 初回召喚時間 (int)
    data modify storage asset:spawner Delay set value 1
# 最低召喚間隔 (int)
    data modify storage asset:spawner MinSpawnDelay set value 2
# 最大召喚間隔 (int)
    data modify storage asset:spawner MaxSpawnDelay set value 2
# 近くのエンティティの最大数 (int)
    data modify storage asset:spawner MaxNearbyEntities set value 1
# この範囲にプレイヤーが存在するとき、Mobの召喚を開始する // distance <= 100
    data modify storage asset:spawner RequiredPlayerRange set value 10

function asset:spawner/common/register


text:
#> asset:spawner/common/register
#
#
#
# @within function asset:spawner/*/register

# パラメータチェック
    execute unless data storage asset:spawner ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ID","color":"red"}]
    execute unless data storage asset:spawner SpawnPotentials run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" SpawnPotentials","color":"red"}]
    execute unless data storage asset:spawner HP run data modify storage asset:spawner HP set value 2147483647
    execute unless data storage asset:spawner SpawnCount run data modify storage asset:spawner SpawnCount set value 3
    execute unless data storage asset:spawner SpawnRange run data modify storage asset:spawner SpawnRange set value 4
    execute unless data storage asset:spawner Delay run data modify storage asset:spawner Delay set value 20
    execute unless data storage asset:spawner MinSpawnDelay run data modify storage asset:spawner MinSpawnDelay set value 100
    execute unless data storage asset:spawner MaxSpawnDelay run data modify storage asset:spawner MaxSpawnDelay set value 400
    execute unless data storage asset:spawner MaxNearbyEntities run data modify storage asset:spawner MaxNearbyEntities set value 6
    execute unless data storage asset:spawner RequiredPlayerRange run data modify storage asset:spawner RequiredPlayerRange set value 16
# 登録
    function asset_manager:spawner/register/
# リセット
    data remove storage asset:spawner SpawnPotentials
    data remove storage asset:spawner HP
    data remove storage asset:spawner SpawnCount
    data remove storage asset:spawner SpawnRange
    data remove storage asset:spawner Delay
    data remove storage asset:spawner MinSpawnDelay
    data remove storage asset:spawner MaxSpawnDelay
    data remove storage asset:spawner MaxNearbyEntities
    data remove storage asset:spawner RequiredPlayerRange


text:
#> api:_index.d
# @private

#> Public
# @public
    #declare storage api:


text:
#> api:global_vars/get_difficulty
#
# 難度値を取得します
# 難度値はそれぞれ以下の難易度を表します
# 1:イージー
# 2:ノーマル
# 3:ハード
# 4..6:それ以上
#
# @output storage api: Return.Difficulty : int @ 1..6
# @api

execute store result storage api: Return.Difficulty int 1 run scoreboard players get $Difficulty Global


text:
#> api:heal/modifier
#
# ヒールライブラリの引数を実行者の補正値で補正します
#
# @input
#   as entity
#   storage api: Argument.Heal : float
#   storage api: Argument.FIxedHeal : boolean
# @output storage api: Argument.Heal : float
# @api

# 補正
    execute if entity @s[type=player] unless data storage api: Argument{FixedHeal:true} run function api:heal/core/modifier


text:
#> api:heal/reset
#
# api:healの引数をリセットします
#
# @api

data remove storage api: Argument.Heal
data remove storage api: Argument.FixedHeal


text:
#> api:heal/core/non-player
#
# プレイヤー以外に対する処理
#
# @within function api:heal/

#> Private
# @private
    #declare score_holder $Health (e2)
    #declare score_holder $MaxHealth (e2)
    #declare score_holder $MaxHealthMultiplier (e1)
    #declare score_holder $Heal (e2)
    #declare score_holder $Fluctuation (e2)

# HP取得
    execute store result score $Health Temporary run data get entity @s AbsorptionAmount 100
# 最大体力/最大体力倍率取得
    execute store result score $MaxHealth Temporary run function api:mob/get_max_health
    scoreboard players operation $MaxHealth Temporary *= $100 Const
    execute store result score $MaxHealthMultiplier Temporary run function api:mob/get_max_health_multiplier
# 代入
    execute store result score $Heal Temporary run data get storage api: Argument.Heal 100
# マルチ補正
    execute unless data storage api: Argument{FixedHeal:true} if score $MaxHealthMultiplier Temporary matches 1.. run scoreboard players operation $Heal Temporary *= $MaxHealthMultiplier Temporary
    execute unless data storage api: Argument{FixedHeal:true} run scoreboard players operation $Heal Temporary /= $10 Const
# 減算
    scoreboard players operation $Health Temporary += $Heal Temporary
# 最大体力チェック
    scoreboard players operation $Health Temporary < $MaxHealth Temporary
# 代入 / kill
    execute store result entity @s AbsorptionAmount float 0.01 run scoreboard players get $Health Temporary
# 回復量表示
    scoreboard players operation $Fluctuation Lib = $Heal Temporary
    execute at @s run function lib:status_log/show_health
# リセット
    scoreboard players reset $Health Temporary
    scoreboard players reset $MaxHealth Temporary
    scoreboard players reset $MaxHealthMultiplier Temporary
    scoreboard players reset $Heal Temporary


text:
#> api:heal/core/receive_modifier
#
# 被回復量に補正をかける
#
# @within function api:heal/core/player

#> Temp
# @private
    #declare score_holder $Heal
    #declare score_holder $Modifier

# ユーザーストレージ呼び出し
    function oh_my_dat:please
# 必要なデータ取得
    execute store result score $Heal Temporary run data get storage api: Argument.Heal 100
    execute store result score $Modifier Temporary run data get storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Modifiers.ReceiveHeal 100
# 補正
    scoreboard players operation $Heal Temporary *= $Modifier Temporary
# 代入
    execute store result storage api: Argument.Heal float 0.0001 run scoreboard players get $Heal Temporary
# リセット
    scoreboard players reset $Heal Temporary
    scoreboard players reset $Modifier Temporary


text:
#> api:heal/core/player
#
# プレイヤーに対する処理
#
# @within function api:heal/

#> Private
# @private
    #declare score_holder $Fluctuation

# 負数の場合の処理
    execute store result score $Fluctuation Temporary run data get storage api: Argument.Heal
    execute if score $Fluctuation Temporary matches ..-1 run data modify storage api: Argument.Heal set value 0
# リセット
    scoreboard players reset $Fluctuation Temporary
# 被回復量補正を掛ける
    execute unless data storage lib: Argument{FixedHeal:true} run function api:heal/core/receive_modifier
# 代入
    data modify storage api: Argument.Fluctuation set from storage api: Argument.Heal
# Healthを持つEntityであれば実行
    function lib:score_to_health_wrapper/fluctuation


text:
#> api:heal/core/modifier
#
# 回復量に補正をかける
#
# @within function api:heal/modifier

#> Temp
# @private
    #declare score_holder $Heal
    #declare score_holder $Modifier

# ユーザーストレージ呼び出し
    function oh_my_dat:please
# 必要なデータ取得
    execute store result score $Heal Temporary run data get storage api: Argument.Heal 100
    execute store result score $Modifier Temporary run data get storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Modifiers.Heal 100
# 補正
    scoreboard players operation $Heal Temporary *= $Modifier Temporary
# 代入
    execute store result storage api: Argument.Heal float 0.0001 run scoreboard players get $Heal Temporary
# リセット
    scoreboard players reset $Heal Temporary
    scoreboard players reset $Modifier Temporary


text:
#> api:rom/please
#
#
#
# @input storage api: Argument.Address : int @ 0..65535
# @api

# validate
    execute unless data storage api: Argument.Address run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Address","color":"red"}]
# 新たに提供する必要があるかをチェックする
    execute store result score $Address Temporary run data get storage api: Argument.ID
# validate 2
    execute unless score $Address Temporary matches 0..65535 run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"アドレスは0から65535の範囲でのみ提供されますが、","color":"white"},{"score":{"name":"$Address","objective":"Temporary"}},{"text":"が要求されました。"}]
# 必要な場合は提供する
    execute unless score $Address Temporary = $LatestProvidedAddress Global run function rom:provide
# リセット
    data remove storage api: Argument.Address
    scoreboard players reset $Address Temporary
    scoreboard players reset $LatestProvidedAddress Global


text:
#> api:inventory/clear
#
# 実行者のインベントリから引数と等価なアイテムの個数チェックおよび削除をします
#
# @input
#   as player
#   storage api:
#       Argument.Target: Item(Count will be ignored)
#       Argument.Amount?: int
# @output score $Return.Amount Lib : if Argument.Amount == 0
# @api

# インベントリの取得
    function api:data_get/inventory
# 引数の修正
    data remove storage api: Argument.Target.Slot
    data remove storage api: Argument.Target.Count
    execute unless data storage api: Argument.Amount run data modify storage api: Argument.Amount set value 8192
# 削除個数の取得
    execute store result score $Amount Temporary run data get storage api: Argument.Amount
# セッション開ける
    function lib:array/session/open
# インベントリを反転する
    data modify storage lib: Array set from storage api: Inventory
    function lib:array/reverse
# インベントリのチェック
    execute if score $Amount Temporary matches 0 run function api:inventory/core/clear/test/
    execute if score $Amount Temporary matches 1.. run function api:inventory/core/clear/remove/
# リセット
    function lib:array/session/close
    data remove storage api: NewInv
    data remove storage api: Argument
    scoreboard players reset $Amount Temporary


text:
#> api:inventory/get_size
#
# 実行者の防具スロット/オフハンドを除くインベントリのサイズを取得します
#
# @output score $InvSize Lib
# @api

#> Inv
# @private
#declare score_holder $InvSize

function api:data_get/inventory
execute store result score $InvSize Lib if data storage api: Inventory[]
execute if data storage api: Inventory[{Slot:100b}] run scoreboard players remove $InvSize Lib 1
execute if data storage api: Inventory[{Slot:101b}] run scoreboard players remove $InvSize Lib 1
execute if data storage api: Inventory[{Slot:102b}] run scoreboard players remove $InvSize Lib 1
execute if data storage api: Inventory[{Slot:103b}] run scoreboard players remove $InvSize Lib 1
execute if data storage api: Inventory[{Slot:-106b}] run scoreboard players remove $InvSize Lib 1


text:
#> api:inventory/_index.d
# @private

#> clear
# @within api:inventory/**clear**
    #declare score_holder $Amount
    #declare score_holder $notEqual
    #declare score_holder $Count
    #declare score_holder $NewCount
    #declare score_holder $Return.Amount


text:
#> api:inventory/core/clear/test/foreach
#
#
#
# @within function
#   api:inventory/core/clear/test/
#   api:inventory/core/clear/test/foreach

# Countを保存しておく
    execute store result score $Count Temporary run data get storage lib: Array[-1].Count
# Count削除
    data remove storage lib: Array[-1].Count
# 比較
    execute store success score $notEqual Temporary run data modify storage lib: Array[-1] set from storage api: Argument.Target
# 同アイテムの場合、
    execute if score $notEqual Temporary matches 0 run scoreboard players operation $Return.Amount Lib += $Count Temporary
# 末尾データ削除
    data remove storage lib: Array[-1]
# リセット
    scoreboard players reset $Count Temporary
    scoreboard players reset $notEqual Temporary
# まだアイテムがある場合は再帰
    execute if data storage lib: Array[0] run function api:inventory/core/clear/test/foreach


text:
#> api:inventory/core/clear/remove/map
# @within function
#   api:inventory/core/clear/remove/
#   api:inventory/core/clear/remove/map

# 末尾データを新しいインベントリに追加する
    data modify storage api: NewInv append from storage lib: Array[-1]
# Count削除
    data remove storage lib: Array[-1].Count
    data remove storage lib: Array[-1].Slot
# 比較
    execute store success score $notEqual Temporary run data modify storage lib: Array[-1] set from storage api: Argument.Target
# 同アイテムの場合はそれぞれの個数を書き換える
    execute if score $notEqual Temporary matches 0 run function api:inventory/core/clear/remove/subtract_values
# 末尾データ削除
    data remove storage lib: Array[-1]
# リセット
    scoreboard players reset $notEqual Temporary
# まだアイテムがある場合は再帰
    execute if score $Amount Temporary matches ..0 if data storage lib: Array[0] run function lib:array/reverse
    execute if score $Amount Temporary matches ..0 if data storage lib: Array[0] run data modify storage api: NewInv append from storage lib: Array[]
    execute if score $Amount Temporary matches 1.. if data storage lib: Array[0] run function api:inventory/core/clear/remove/map


text:
#> api:inventory/core/clear/remove/subtract_values
# @within function api:inventory/core/clear/remove/map

# 個数取得
    execute store result score $Count Temporary run data get storage api: NewInv[-1].Count
# アイテムの新しい個数をセット
    scoreboard players operation $NewCount Temporary = $Count Temporary
    scoreboard players operation $NewCount Temporary -= $Amount Temporary
    execute if score $NewCount Temporary matches ..-1 run scoreboard players set $NewCount Temporary 0
    execute store result storage api: NewInv[-1].Count byte 1 run scoreboard players get $NewCount Temporary
# 目標数を減算
    scoreboard players operation $Amount Temporary -= $Count Temporary
# リセット
    scoreboard players reset $Count Temporary
    scoreboard players reset $NewCount Temporary


text:
#> api:inventory/refer_selected_item_slot/replace_from_shulker_box
#
# ShulkerAの一つ目のアイテムを実行者の対象スロットにreplaceします
#
# @input storage api: SelectedItemSlot: int
# @api

execute if data storage api: {SelectedItemSlot:0} run loot replace entity @s hotbar.0 1 mine 10000 0 10000 debug_stick
execute if data storage api: {SelectedItemSlot:1} run loot replace entity @s hotbar.1 1 mine 10000 0 10000 debug_stick
execute if data storage api: {SelectedItemSlot:2} run loot replace entity @s hotbar.2 1 mine 10000 0 10000 debug_stick
execute if data storage api: {SelectedItemSlot:3} run loot replace entity @s hotbar.3 1 mine 10000 0 10000 debug_stick
execute if data storage api: {SelectedItemSlot:4} run loot replace entity @s hotbar.4 1 mine 10000 0 10000 debug_stick
execute if data storage api: {SelectedItemSlot:5} run loot replace entity @s hotbar.5 1 mine 10000 0 10000 debug_stick
execute if data storage api: {SelectedItemSlot:6} run loot replace entity @s hotbar.6 1 mine 10000 0 10000 debug_stick
execute if data storage api: {SelectedItemSlot:7} run loot replace entity @s hotbar.7 1 mine 10000 0 10000 debug_stick
execute if data storage api: {SelectedItemSlot:8} run loot replace entity @s hotbar.8 1 mine 10000 0 10000 debug_stick


text:
#> api:inventory/refer_selected_item_slot/get_item
#
# Inventoryから対象スロットのアイテムを取得します
#
# @input storage api:
#   Inventory: SlottedItem
#   SelectedItemSlot: int
# @output storage api: Item
# @api

data modify storage api: Item set value {}

execute if data storage api: {SelectedItemSlot:0} run data modify storage api: Item set from storage api: Inventory[{Slot:0b}]
execute if data storage api: {SelectedItemSlot:1} run data modify storage api: Item set from storage api: Inventory[{Slot:1b}]
execute if data storage api: {SelectedItemSlot:2} run data modify storage api: Item set from storage api: Inventory[{Slot:2b}]
execute if data storage api: {SelectedItemSlot:3} run data modify storage api: Item set from storage api: Inventory[{Slot:3b}]
execute if data storage api: {SelectedItemSlot:4} run data modify storage api: Item set from storage api: Inventory[{Slot:4b}]
execute if data storage api: {SelectedItemSlot:5} run data modify storage api: Item set from storage api: Inventory[{Slot:5b}]
execute if data storage api: {SelectedItemSlot:6} run data modify storage api: Item set from storage api: Inventory[{Slot:6b}]
execute if data storage api: {SelectedItemSlot:7} run data modify storage api: Item set from storage api: Inventory[{Slot:7b}]
execute if data storage api: {SelectedItemSlot:8} run data modify storage api: Item set from storage api: Inventory[{Slot:8b}]
data remove storage api: Item.Slot


text:
#> api:inventory/refer_selected_item_slot/replace_air
#
# 実行者の対象スロットをairでreplace
#
# @input storage api: SelectedItemSlot: int
# @api

execute if data storage api: {SelectedItemSlot:0} run item replace entity @s hotbar.0 with air
execute if data storage api: {SelectedItemSlot:1} run item replace entity @s hotbar.1 with air
execute if data storage api: {SelectedItemSlot:2} run item replace entity @s hotbar.2 with air
execute if data storage api: {SelectedItemSlot:3} run item replace entity @s hotbar.3 with air
execute if data storage api: {SelectedItemSlot:4} run item replace entity @s hotbar.4 with air
execute if data storage api: {SelectedItemSlot:5} run item replace entity @s hotbar.5 with air
execute if data storage api: {SelectedItemSlot:6} run item replace entity @s hotbar.6 with air
execute if data storage api: {SelectedItemSlot:7} run item replace entity @s hotbar.7 with air
execute if data storage api: {SelectedItemSlot:8} run item replace entity @s hotbar.8 with air


text:
#> api:teleporter/set_activation_state/from_id
#
#
#
# @input storage api:
#   Argument.ID : int
#   Argument.ActivationState : string("InvisibleDeactivate","VisibleDeactivate","Activate")
# @api

# validate
    execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 処理はそっちにお任せ
    execute if data storage api: Argument.ID run function asset_manager:teleporter/update_activation_state/
# リセット
    data remove storage api: Argument.ID
    data remove storage api: Argument.ActivationState


text:
#> api:teleporter/set_activation_state/from_nearest
#
#
#
# @input storage api: Argument.ActivationState : string("InvisibleDeactivate","VisibleDeactivate","Activate")
# @api

execute if entity @e[type=marker,tag=Teleporter,distance=..5,limit=1] as @e[type=marker,tag=Teleporter,distance=..5] run function oh_my_dat:please
execute if entity @e[type=marker,tag=Teleporter,distance=..5,limit=1] run data modify storage api: Argument.ID set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].TeleporterData.ID
execute if entity @e[type=marker,tag=Teleporter,distance=..5,limit=1] if data storage api: Argument.ID run function api:teleporter/set_activation_state/from_id


text:
#> api:artifact/replace/from_rarity
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api: Argument.Rarity
# @api

# validate
    execute unless data storage api: Argument.Rarity run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Rarity","color":"red"}]
# 呼び出し
    data modify storage asset:context Type set value "replace"
    execute if data storage api: Argument.Rarity run function asset_manager:artifact/give
# リセット
    data remove storage api: Argument.Rarity


text:
#> api:artifact/replace/from_id
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api:
#   Argument.ID
#   Argument.Slot
# @api

# validate
    execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 既存にasset:context idが存在する場合に備えて退避させる
    function asset_manager:common/context_id/stash
# 代入
    data modify storage asset:context id set from storage api: Argument.ID
    execute if data storage api: Argument.Slot run data modify storage asset:context Slot set from storage api: Argument.Slot
    data modify storage asset:context Type set value "replace"
# 呼び出し
    execute if data storage api: Argument.ID run function #asset:artifact/give
# 退避させたasset:context idを戻す
    function asset_manager:common/context_id/pop
# リセット
    data remove storage api: Argument.ID
    data remove storage api: Argument.Slot


text:
#> api:artifact/spawn/from_rarity
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api:
#   Argument.Rarity : (1 | 2 | 3 | 4)
#   Argument.Important : boolean
# @api

# validate
    execute unless data storage api: Argument.Rarity run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Rarity","color":"red"}]
# 呼び出し
    data modify storage asset:context Type set value "drop"
    data modify storage asset:context Important set from storage api: Argument.Important
    execute if data storage api: Argument.Rarity run function asset_manager:artifact/give
# リセット
    data remove storage asset:context Important
    data remove storage api: Argument.Rarity
    data remove storage api: Argument.Important


text:
#> api:artifact/spawn/from_id
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api:
#   Argument.Rarity : (1 | 2 | 3 | 4)
#   Argument.Important : boolean
# @api

# validate
    execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 既存にasset:context idが存在する場合に備えて退避させる
    function asset_manager:common/context_id/stash
# 代入
    data modify storage asset:context id set from storage api: Argument.ID
    data modify storage asset:context Type set value "drop"
    data modify storage asset:context Important set from storage api: Argument.Important
# 呼び出し
    execute if data storage api: Argument.ID run function #asset:artifact/give
# 退避させたasset:context idを戻す
    function asset_manager:common/context_id/pop
# リセット
    data remove storage asset:context Important
    data remove storage api: Argument.ID
    data remove storage api: Argument.Important


text:
#> api:artifact/box/from_rarity
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api: Argument.Rarity
# @api

# validate
    execute unless data storage api: Argument.Rarity run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Rarity","color":"red"}]
# 呼び出し
    data modify storage asset:context Type set value "box"
    execute if data storage api: Argument.Rarity run function asset_manager:artifact/give
# リセット
    data remove storage api: Argument.Rarity


text:
#> api:artifact/box/from_id
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api: Argument.ID
# @api

# validate
    execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 既存にasset:context idが存在する場合に備えて退避させる
    function asset_manager:common/context_id/stash
# 代入
    data modify storage asset:context id set from storage api: Argument.ID
    data modify storage asset:context Type set value "box"
# 呼び出し
    execute if data storage api: Argument.ID run function #asset:artifact/give
# 退避させたasset:context idを戻す
    function asset_manager:common/context_id/pop
# リセット
    data remove storage api: Argument.ID


text:
#> api:artifact/give/from_rarity
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api: Argument.Rarity
# @api

# validate
    execute unless data storage api: Argument.Rarity run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Rarity","color":"red"}]
# 呼び出し
    data modify storage asset:context Type set value "give"
    execute if data storage api: Argument.Rarity run function asset_manager:artifact/give
# リセット
    data remove storage api: Argument.Rarity


text:
#> api:artifact/give/from_id
#
# 神器Assetの入手処理を叩く処理
#
# @input storage api: Argument.ID
# @api

# validate
    execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ID","color":"red"}]
# 既存にasset:context idが存在する場合に備えて退避させる
    function asset_manager:common/context_id/stash
# 代入
    data modify storage asset:context id set from storage api: Argument.ID
    data modify storage asset:context Type set value "give"
# 呼び出し
    execute if data storage api: Argument.ID run function #asset:artifact/give
# 退避させたasset:context idを戻す
    function asset_manager:common/context_id/pop
# リセット
    data remove storage api: Argument.ID


text:
#> api:lost_items/give
#
# プレイヤーが失ったアイテムをN個返却します
#
# @input
#   as player
#   storage api: Argument.Count
# @api

# validate
    execute unless data storage api: Argument.Count run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Count","color":"red"}]
# 代入
    execute store result score $GiveCount Temporary run data get storage api: Argument.Count
# 呼び出し
    execute if score $GiveCount Temporary matches 1.. run function player_manager:lost_item/give_part/
# リセット
    data remove storage api: Argument.Count


text:
#> api:lost_items/get_length
#
# プレイヤーが失ったアイテムの数を取得します。
#
# @input as player
# @output result score MP
# @api

# EntityStorage呼び出し
    function oh_my_dat:please
# 取得する
    execute if data storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].LostItems[]


text:
#> api:damage/modifier_continuation
#
# Argument.Damageを実行者の補正値で補正します
#
# この関数はresetを使用しない状態で二度目のmodifierをかける場合に利用してください。
#
# @input
#   as entity
#   storage api:
#       Argument.Damage : float
#       Argument.AttackType : Enum
#       Argument.ElementType? : Enum
#       Argument.FixedDamage? : boolean
#       └ Argument.BypassModifier? : boolean
# @output storage api: Argument.Damage : float
# @api

# 引数チェック
    execute unless data storage api: Argument.Damage run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Damage","color":"red"}]
    execute unless data storage api: Argument.AttackType run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" AttackType","color":"red"}]
    execute unless data storage api: Argument.ElementType run data modify storage api: Argument.ElementType set value "None"
    execute if data storage api: Argument{FixedDamage:true} run data modify storage api: Argument.BypassModifier set value true
    execute unless data storage api: Argument.BypassModifier run data modify storage api: Argument.BypassModifier set value false
# 補正されていないのに呼び出された場合のエラー
    execute unless data storage api: {DamageLibModified:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"lib:damage/modifier_continuation","color":"gold"},{"text":"が","color":"white"},{"text":"lib:damage/modifier","color":"gold"},{"text":"より前に使用されています。","color":"white"}]
    execute if data storage global {IsProduction:1b} unless data storage api: {DamageLibModified:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"あなたが製作者ではない場合、Discordサーバーのお問い合わせより報告してください。","color":"white"}]
# 補正フラグを立てる
    data modify storage api: DamageLibModified set value true
# 補正
    execute if entity @s[type=player] run function api:damage/core/modify/player
    execute if entity @s[type=!player] run function api:damage/core/modify/non-player


text:
#> api:damage/_index.d
# @private

#> 変数定義
# @within function api:damage/core/**
    #declare score_holder $Damage
    #declare score_holder $EPF
    #declare score_holder $Health
    #declare score_holder $defensePoints
    #declare score_holder $toughness
    #declare score_holder $Resistance
    #declare score_holder $LatestModifiedUser
    #declare score_holder $LatestModifiedEntity

#> Declare
# @within function api:damage/core/trigger_on_damage/**
    #declare tag TargetAttacker


text:
#> api:damage/modifier
#
# Argument.Damageを実行者の補正値で補正します
#
# @input
#   as entity
#   storage api:
#       Argument.Damage : float
#       Argument.AttackType : Enum
#       Argument.ElementType? : Enum
#       Argument.FixedDamage? : boolean
#       └ Argument.BypassModifier? : boolean
# @output storage api: Argument.Damage : float
# @api

# 引数チェック
    execute unless data storage api: Argument.Damage run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" Damage","color":"red"}]
    execute unless data storage api: Argument.AttackType run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" AttackType","color":"red"}]
    execute unless data storage api: Argument.ElementType run data modify storage api: Argument.ElementType set value "None"
    execute if data storage api: Argument{FixedDamage:true} run data modify storage api: Argument.BypassModifier set value true
    execute unless data storage api: Argument.BypassModifier run data modify storage api: Argument.BypassModifier set value false
# すでに補正されている場合のエラー
    execute if data storage api: {DamageLibModified:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"lib:damage/modifier","color":"gold"},{"text":"がresetされずに使用されています。","color":"white"}]
    execute if data storage global {IsProduction:0b} if data storage api: {DamageLibModified:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"直近に使用された","color":"white"},{"text":"lib:damage/","color":"gold"},{"text":"が"}]
    execute if data storage global {IsProduction:0b} if data storage api: {DamageLibModified:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"最後に","color":"white"},{"text":"lib:damage/reset","color":"gold"},{"text":"を行なっていない可能性があります。","color":"white"}]
    execute if data storage global {IsProduction:0b} if data storage api: {DamageLibModified:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"また、意図してresetせずに使用する場合、二つ目以降の","color":"white"},{"text":"lib:damage/modifier","color":"gold"},{"text":"を","color":"white"}]
    execute if data storage global {IsProduction:0b} if data storage api: {DamageLibModified:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"lib:damage/modifier_continuation","color":"gold"},{"text":"に変更してください。","color":"white"}]
    execute if data storage global {IsProduction:1b} if data storage api: {DamageLibModified:true} run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"あなたが製作者ではない場合、Discordサーバーのお問い合わせより報告してください。","color":"white"}]
# 補正フラグを立てる
    data modify storage api: DamageLibModified set value true
# 補正
    execute if entity @s[type=player] run function api:damage/core/modify/player
    execute if entity @s[type=!player] run function api:damage/core/modify/non-player


text:
#> api:damage/reset
#
# api:damageの引数及び
#
# @api

# 補正されずに実行されている場合の処理は2022/05/20現在許容されているため記載しない。

# 補正フラグを下ろす
    data modify storage api: DamageLibModified set value false
# リセット
    function api:damage/core/reset


text:
#> api:damage/core/attack
#
# ダメージ与えるよ
#
# @within function api:damage/

# 計算に必要な値を取得
    function api:damage/core/get_status/
# 与えるダメージの計算
    function api:damage/core/calc/
# Mobに適用
    function api:damage/core/health_subtract/
# リセット
    scoreboard players reset $Health Temporary
    scoreboard players reset $Damage Temporary


text:
#> api:damage/core/trigger_on_attack
#
# attackトリガー用の進捗を手動でトリガーします
#
# @within function api:damage/core/health_subtract/non-player

#> Declare
# @private
    #declare tag TargetAttacker

# プレイヤー特定
    execute as @a if score @s UserID = $LatestModifiedUser UserID run tag @s add TargetAttacker
# 特定用タグ
    tag @s add VictimFromLibrary
# トリガー
    tag @a[tag=TargetAttacker] add TriggerFlag.Attack
    execute if entity @s[tag=FindFlag0.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 0-0
    execute if entity @s[tag=FindFlag0.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 0-1
    execute if entity @s[tag=FindFlag1.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 1-0
    execute if entity @s[tag=FindFlag1.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 1-1
    execute if entity @s[tag=FindFlag2.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 2-0
    execute if entity @s[tag=FindFlag2.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 2-1
    execute if entity @s[tag=FindFlag3.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 3-0
    execute if entity @s[tag=FindFlag3.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 3-1
    execute if entity @s[tag=FindFlag4.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 4-0
    execute if entity @s[tag=FindFlag4.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 4-1
    execute if entity @s[tag=FindFlag5.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 5-0
    execute if entity @s[tag=FindFlag5.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 5-1
    execute if entity @s[tag=FindFlag6.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 6-0
    execute if entity @s[tag=FindFlag6.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 6-1
    execute if entity @s[tag=FindFlag7.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 7-0
    execute if entity @s[tag=FindFlag7.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 7-1
    execute if entity @s[tag=FindFlag8.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 8-0
    execute if entity @s[tag=FindFlag8.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 8-1
    execute if entity @s[tag=FindFlag9.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 9-0
    execute if entity @s[tag=FindFlag9.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 9-1
    execute if entity @s[tag=FindFlag10.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 10-0
    execute if entity @s[tag=FindFlag10.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 10-1
    execute if entity @s[tag=FindFlag11.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 11-0
    execute if entity @s[tag=FindFlag11.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 11-1
    execute if entity @s[tag=FindFlag12.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 12-0
    execute if entity @s[tag=FindFlag12.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 12-1
    execute if entity @s[tag=FindFlag13.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 13-0
    execute if entity @s[tag=FindFlag13.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 13-1
    execute if entity @s[tag=FindFlag14.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 14-0
    execute if entity @s[tag=FindFlag14.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 14-1
    execute if entity @s[tag=FindFlag15.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 15-0
    execute if entity @s[tag=FindFlag15.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacked_entity 15-1
# リセット
    tag @a[tag=TargetAttacker] remove TargetAttacker
    tag @s remove VictimFromLibrary


text:
#> api:damage/core/modify_damage
#
# ダメージをlib: Modifiersを元に補正します
#
# @within function
#   api:damage/core/modify/player
#   api:damage/core/get_status/modify_and_get_damage

#> Temp
# @private
    #declare score_holder $Damage
    #declare score_holder $Modifier
    #declare score_holder $Temp
    #declare score_holder $Average

# 必要なデータの取得と加算
    # 元ダメージ
        execute store result score $Damage Temporary run data get storage api: Argument.Damage 100
    # Base値による補正
        execute store result score $Modifier Temporary run data get storage api: Modifiers.Base 100
        execute unless data storage api: Modifiers.Base run scoreboard players set $Modifier Temporary 100
    # 第一属性
        execute if data storage api: Argument{AttackType:"Physical"} store result score $Temp Temporary run data get storage api: Modifiers.Physical 100
        execute if data storage api: Argument{AttackType:"Physical"} unless data storage api: Modifiers.Physical run scoreboard players set $Temp Temporary 100
        execute if data storage api: Argument{AttackType:"Magic"} store result score $Temp Temporary run data get storage api: Modifiers.Magic 100
        execute if data storage api: Argument{AttackType:"Magic"} unless data storage api: Modifiers.Magic run scoreboard players set $Temp Temporary 100
        scoreboard players operation $Average Temporary += $Temp Temporary
    # 第二属性
        execute if data storage api: Argument{ElementType:"None"} run scoreboard players operation $Temp Temporary = $Average Temporary
        execute if data storage api: Argument{ElementType:"Fire"} store result score $Temp Temporary run data get storage api: Modifiers.Fire 100
        execute if data storage api: Argument{ElementType:"Fire"} unless data storage api: Modifiers.Fire run scoreboard players set $Temp Temporary 100
        execute if data storage api: Argument{ElementType:"Water"} store result score $Temp Temporary run data get storage api: Modifiers.Water 100
        execute if data storage api: Argument{ElementType:"Water"} unless data storage api: Modifiers.Water run scoreboard players set $Temp Temporary 100
        execute if data storage api: Argument{ElementType:"Thunder"} store result score $Temp Temporary run data get storage api: Modifiers.Thunder 100
        execute if data storage api: Argument{ElementType:"Thunder"} unless data storage api: Modifiers.Thunder run scoreboard players set $Temp Temporary 100
        scoreboard players operation $Average Temporary += $Temp Temporary
    # 平均値
        scoreboard players operation $Average Temporary /= $2 Const
    # 補正値の計算
        scoreboard players operation $Modifier Temporary *= $Average Temporary
        scoreboard players operation $Modifier Temporary /= $100 Const
# 最低値設定
    scoreboard players operation $Modifier Temporary > $25 Const
# 補正
    scoreboard players operation $Damage Temporary *= $Modifier Temporary
# 代入
    execute store result storage api: ModifiedDamage double 0.0001 run scoreboard players get $Damage Temporary
# リセット
    data remove storage api: Modifiers
    scoreboard players reset $Average Temporary
    scoreboard players reset $Damage Temporary
    scoreboard players reset $Modifier Temporary
    scoreboard players reset $Temp Temporary


text:
#> api:damage/core/reset
#
#
#
# @within function api:damage/reset

data remove storage api: Argument.Damage
data remove storage api: Argument.AttackType
data remove storage api: Argument.ElementType
data remove storage api: Argument.DeathMessage
data remove storage api: Argument.FixedDamage
data remove storage api: Argument.BypassModifier
data remove storage api: Argument.BypassArmorDefense
data remove storage api: Argument.BypassToughness
data remove storage api: Argument.BypassEnchantments
data remove storage api: Argument.BypassResistance
data remove storage api: Argument.DisableParticle
data remove storage api: Argument.ReduceEnchantment

scoreboard players reset $LatestModifiedUser UserID
scoreboard players reset $LatestModifiedEntity MobUUID


text:
#> api:damage/core/calc/enchantment
#
# エンチャントによる軽減を計算します
#
# @within function api:damage/core/calc/

#> Temp
# @private
#declare score_holder $Mul

# $EPF(e2) = min(20, $EPF(e0)) * e2 / 50
    scoreboard players operation $EPF Temporary < $20 Const
    scoreboard players operation $EPF Temporary *= $2 Const
# $CalcF(e2) = 1 * e2 - $EPF(e2)
    scoreboard players operation $Mul Temporary = $100 Const
    scoreboard players operation $Mul Temporary -= $EPF Temporary
# $damage(e2) = $damage(e2) * $CalcF(e2) / e2
    scoreboard players operation $Damage Temporary *= $Mul Temporary
    scoreboard players operation $Damage Temporary /= $100 Const
# リセット
    scoreboard players reset $Mul Temporary


text:
#> api:damage/core/calc/defense
#
# 防御による軽減を計算します
#
# @within function api:damage/core/calc/

#> Temp
# @private
    #declare score_holder $CalcA
    #declare score_holder $CalcB
    #declare score_holder $CalcB2
    #declare score_holder $CalcB3
    #declare score_holder $CalcC
    #declare score_holder $CalcD
    #declare score_holder $CalcE

# $CalcA(e2) = $defensePoints(e2) * e2 / 5 / e2
    scoreboard players operation $CalcA Temporary = $defensePoints Temporary
    scoreboard players operation $CalcA Temporary *= $20 Const
    scoreboard players operation $CalcA Temporary /= $100 Const
# $CalcB3(e2) = $toughness(e2) * e2 / 4 / e2 + 2 * e2  : $damage >= 1000 * e2
# $CalcB3(e4) = $toughness(e2) * e2 / 4      + 2 * e4  : $damage  < 1000 * e2
    scoreboard players operation $CalcB3 Temporary = $toughness Temporary
    scoreboard players operation $CalcB3 Temporary *= $25 Const
    execute if score $Damage Temporary matches 100000.. run scoreboard players operation $CalcB3 Temporary /= $100 Const
    execute if score $Damage Temporary matches 100000.. run scoreboard players operation $CalcB3 Temporary += $200 Const
    execute if score $Damage Temporary matches ..099999 run scoreboard players operation $CalcB3 Temporary += $20000 Const
# $CalcB2(e2) = $damage(e2) * e2 / $CalcB3(e2)  : $damage >= 1000 * e2
# $CalcB2(e2) = $damage(e2) * e4 / $CalcB3(e4)  : $damage  < 1000 * e2
    scoreboard players operation $CalcB2 Temporary = $Damage Temporary
    execute if score $Damage Temporary matches 100000.. run scoreboard players operation $CalcB2 Temporary *= $100 Const
    execute if score $Damage Temporary matches ..099999 run scoreboard players operation $CalcB2 Temporary *= $10000 Const
    scoreboard players operation $CalcB2 Temporary /= $CalcB3 Temporary
# $CalcB(e2) = $defensePoints(e2) - $CalcB2(e2)
    scoreboard players operation $CalcB Temporary = $defensePoints Temporary
    scoreboard players operation $CalcB Temporary -= $CalcB2 Temporary
# $CalcC(e4) = min(max($CalcA(e2), $CalcB(e2)), 20 * e2) * e2 / 25
    scoreboard players operation $CalcC Temporary = $CalcA Temporary
    scoreboard players operation $CalcC Temporary > $CalcB Temporary
    scoreboard players operation $CalcC Temporary < $2000 Const
    scoreboard players operation $CalcC Temporary *= $4 Const
# $CalcD(e3) = (1 * e4 - $CalcC(e4)) / e1  : $damage >= 1000 * e2
# $CalcD(e4) = (1 * e4 - $CalcC(e4))       : $damage  < 1000 * e2
    scoreboard players operation $CalcD Temporary = $10000 Const
    scoreboard players operation $CalcD Temporary -= $CalcC Temporary
    execute if score $Damage Temporary matches 100000.. run scoreboard players operation $CalcD Temporary /= $10 Const
# $damage(e4) = $damage(e2) * $CalcD(e3) / e1  : $damage >= 1000 * e2
# $damage(e4) = $damage(e2) * $CalcD(e4) / e2  : $damage  < 1000 * e2
    scoreboard players operation $CalcE Temporary = $Damage Temporary
    scoreboard players operation $CalcE Temporary *= $CalcD Temporary
    execute if score $Damage Temporary matches 100000.. run scoreboard players operation $CalcE Temporary /= $10 Const
    execute if score $Damage Temporary matches ..099999 run scoreboard players operation $CalcE Temporary /= $100 Const
    scoreboard players operation $Damage Temporary = $CalcE Temporary
# リセット
    scoreboard players reset $CalcA Temporary
    scoreboard players reset $CalcB Temporary
    scoreboard players reset $CalcB2 Temporary
    scoreboard players reset $CalcB3 Temporary
    scoreboard players reset $CalcC Temporary
    scoreboard players reset $CalcD Temporary
    scoreboard players reset $CalcE Temporary


text:
#> api:damage/core/calc/resistance
#
# 耐性エフェクトによる軽減を計算します
#
# @within function api:damage/core/calc/

#> Temp
# @private
#declare score_holder $Mul

# $Resistance(e1) *= min(5, $Resistance(e0)) * e1 / 5
    scoreboard players operation $Resistance Temporary < $10 Const
# $Mul(e1) = 1 * e1 - $Resistance(e1)
    scoreboard players operation $Mul Temporary = $10 Const
    scoreboard players operation $Mul Temporary -= $Resistance Temporary
# $damage(e2) = $damage(e2) * $Mul(e1) / e1
    scoreboard players operation $Damage Temporary *= $Mul Temporary
    scoreboard players operation $Damage Temporary /= $10 Const
# リセット
    scoreboard players reset $Mul Temporary


text:
#> api:damage/core/trigger_on_damage/as_attacker
#
#
#
# @within function api:damage/core/trigger_on_damage/

# 特定用タグ
    tag @s add AttackerFromLibrary
# トリガー
    execute if entity @s[tag=FindFlag0.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 0-0
    execute if entity @s[tag=FindFlag0.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 0-1
    execute if entity @s[tag=FindFlag1.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 1-0
    execute if entity @s[tag=FindFlag1.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 1-1
    execute if entity @s[tag=FindFlag2.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 2-0
    execute if entity @s[tag=FindFlag2.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 2-1
    execute if entity @s[tag=FindFlag3.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 3-0
    execute if entity @s[tag=FindFlag3.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 3-1
    execute if entity @s[tag=FindFlag4.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 4-0
    execute if entity @s[tag=FindFlag4.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 4-1
    execute if entity @s[tag=FindFlag5.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 5-0
    execute if entity @s[tag=FindFlag5.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 5-1
    execute if entity @s[tag=FindFlag6.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 6-0
    execute if entity @s[tag=FindFlag6.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 6-1
    execute if entity @s[tag=FindFlag7.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 7-0
    execute if entity @s[tag=FindFlag7.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 7-1
    execute if entity @s[tag=FindFlag8.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 8-0
    execute if entity @s[tag=FindFlag8.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 8-1
    execute if entity @s[tag=FindFlag9.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 9-0
    execute if entity @s[tag=FindFlag9.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 9-1
    execute if entity @s[tag=FindFlag10.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 10-0
    execute if entity @s[tag=FindFlag10.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 10-1
    execute if entity @s[tag=FindFlag11.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 11-0
    execute if entity @s[tag=FindFlag11.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 11-1
    execute if entity @s[tag=FindFlag12.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 12-0
    execute if entity @s[tag=FindFlag12.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 12-1
    execute if entity @s[tag=FindFlag13.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 13-0
    execute if entity @s[tag=FindFlag13.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 13-1
    execute if entity @s[tag=FindFlag14.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 14-0
    execute if entity @s[tag=FindFlag14.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 14-1
    execute if entity @s[tag=FindFlag15.0] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 15-0
    execute if entity @s[tag=FindFlag15.1] run advancement grant @a[tag=TargetAttacker] only mob_manager:entity_finder/check_attacking_entity 15-1
# リセット
    tag @s remove TargetAttacker
    tag @s remove AttackerFromLibrary


text:
#> api:damage/core/get_status/get_resistance_lv
#
#
#
# @within function api:damage/core/get_status/

# ActiveEffectsの取得
    execute if entity @s[type=player] run function api:data_get/active_effects
    execute if entity @s[type=!player] run data modify storage api: ActiveEffects set from entity @s ActiveEffects
# 耐性lv(0-indexed)の取得
    execute store result score $Resistance Temporary run data get storage api: ActiveEffects[{Id:11}].Amplifier
    execute unless data storage api: ActiveEffects[{Id:11}].Amplifier run scoreboard players set $Resistance Temporary -1
# 127lv(0-indexed)の場合、lib:damageの演出用に付与されているものなので、HiddenEffectを再度参照する
    execute if score $Resistance Temporary matches 127 unless data storage api: ActiveEffects[{Id:11}].HiddenEffect run scoreboard players set $Resistance Temporary -1
    execute if score $Resistance Temporary matches 127 store result score $Resistance Temporary run data get storage api: ActiveEffects[{Id:11}].HiddenEffect.Amplifier
# 0-indexed -> 1-indexed
    scoreboard players add $Resistance Temporary 1
# リセット
    data remove storage api: ActiveEffects


text:
#> api:damage/core/get_status/modify_and_get_damage
#
# ダメージをModifierで補正し、取得する
#
# @within function api:damage/core/get_status/

# 属性の耐性値で補正値する
    function oh_my_dat:please
    data modify storage api: Modifiers set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Modifiers.Defense
    function api:damage/core/modify_damage
    execute store result score $Damage Temporary run data get storage api: ModifiedDamage 100
# リセット
    data remove storage api: ModifiedDamage


text:
#> api:damage/core/get_epf/non-player
#
#
#
# @within function api:damage/core/get_epf/

data modify storage api: Enchantments append from entity @s ArmorItems[].tag.Enchantments[]


text:
#> api:damage/core/get_epf/get_non-protection_epf
#
#
#
# @within function api:damage/core/get_epf/

#> Temp
# @private
    #declare score_holder $Temp
    #declare score_holder $TypeModifier

# ReduceEnchantmentIdのデータ正規化
execute if data storage lib: Argument.ReduceEnchantment.id run data modify storage lib: ReduceEnchantmentID set from storage lib: Argument.ReduceEnchantment.id
execute unless data storage lib: Argument.ReduceEnchantment.id run data modify storage lib: ReduceEnchantmentID set from storage lib: Argument.ReduceEnchantment

# セッション開く
    function lib:array/session/open
# 該当エンチャントのIndex(es)を調べる
# CompareResult = Array.map(v => v.id === CompareTarget)
    data modify storage lib: Array append from storage lib: Enchantments[].id
    data modify storage lib: CompareTarget set from storage lib: ReduceEnchantmentID
    function lib:array/compare_single
# 該当エンチャントのデータを取得する
# Array = Array.filter((_, i) => !Masks[i])
    data modify storage lib: Array set from storage api: Enchantments
    data modify storage lib: Masks set from storage lib: CompareResult
  # data modify storage api: MaskElement set value null
    function lib:array/mask_inverted
# エンチャントレベルの総和を計算する
# SumResult = Array.map(v => v.lvl).reduce((a, b) => a + b)
    data modify storage lib: Temp append from storage lib: Array[].lvl
    data modify storage lib: Array set from storage lib: Temp
    data remove storage lib: Temp
    function lib:array/math/sum
# 計算結果を取得する
    execute store result score $Temp Temporary run data get storage lib: SumResult
# セッションを閉じる
    function lib:array/session/close
# エンチャント係数を取得する
    execute if data storage lib: Argument.ReduceEnchantment.modifier store result score $TypeModifier Temporary run data get storage lib: Argument.ReduceEnchantment.modifier
    execute unless score $TypeModifier Temporary matches -2147483648.. if data storage lib: {ReduceEnchantmentID:      "minecraft:fire_protection"} run scoreboard players set $TypeModifier Temporary 2
    execute unless score $TypeModifier Temporary matches -2147483648.. if data storage lib: {ReduceEnchantmentID:     "minecraft:blast_protection"} run scoreboard players set $TypeModifier Temporary 2
    execute unless score $TypeModifier Temporary matches -2147483648.. if data storage lib: {ReduceEnchantmentID:"minecraft:projectile_protection"} run scoreboard players set $TypeModifier Temporary 2
    execute unless score $TypeModifier Temporary matches -2147483648.. if data storage lib: {ReduceEnchantmentID:      "minecraft:feather_falling"} run scoreboard players set $TypeModifier Temporary 3
    execute unless score $TypeModifier Temporary matches -2147483648.. run scoreboard players set $TypeModifier Temporary 1
# エンチャント係数を掛ける
    scoreboard players operation $Temp Temporary *= $TypeModifier Temporary
# EPFに加算する
    scoreboard players operation $EPF Temporary += $Temp Temporary
# リセット
    scoreboard players reset $Temp Temporary
    scoreboard players reset $TypeModifier Temporary


text:
#> api:damage/core/get_epf/player
#
# プレイヤーの防具のProtectionを軽量に取得します
#
# @within function api:damage/core/get_epf/

function api:data_get/inventory
data modify storage api: Enchantments append from storage api: Inventory[{Slot:103b}].tag.Enchantments[]
data modify storage api: Enchantments append from storage api: Inventory[{Slot:102b}].tag.Enchantments[]
data modify storage api: Enchantments append from storage api: Inventory[{Slot:101b}].tag.Enchantments[]
data modify storage api: Enchantments append from storage api: Inventory[{Slot:100b}].tag.Enchantments[]


text:
#> api:damage/core/modify/non-player
#
#
#
# @within function api:damage/modifier*

# プレイヤー情報の記録
    scoreboard players operation $LatestModifiedEntity MobUUID = @s MobUUID


text:
#> api:damage/core/modify/player
#
# damageLibの中でも攻撃元に関係する処理部
#
# @within function api:damage/modifier*

# プレイヤー情報の記録
    scoreboard players operation $LatestModifiedUser UserID = @s UserID
# ダメージに補正値を掛ける
    execute if data storage api: Argument{BypassModifier:false} run function oh_my_dat:please
    execute if data storage api: Argument{BypassModifier:false} run data modify storage api: Modifiers set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Modifiers.Attack
    execute if data storage api: Argument{BypassModifier:false} run function api:damage/core/modify_damage
    execute if data storage api: Argument{BypassModifier:false} run data modify storage api: Argument.Damage set from storage api: ModifiedDamage
# リセット
    data remove storage api: ModifiedDamage


text:
#> api:damage/core/health_subtract/non-player
#
# Mobに対するHP減算回りの処理
#
# @within function api:damage/core/health_subtract/

#>
# @private
#declare score_holder $Fluctuation
#declare tag UUIDAttacker

# ダメージ表示
    scoreboard players operation $Fluctuation Lib = $Damage Temporary
    scoreboard players operation $Fluctuation Lib /= $-100 Const
    execute at @s run function lib:status_log/show_health
# ダメージを一桁下げる
    scoreboard players operation $Damage Temporary /= $10 Const
# MobのHealthよりダメージが高い場合Healthに設定
    scoreboard players operation $Damage Temporary < $Health Temporary
# 減算
    scoreboard players operation $Health Temporary -= $Damage Temporary
# ノックバックを無効に
    attribute @s minecraft:generic.knockback_resistance modifier add 3-0-1-0-100000001 "Temp_Resist" 1 add
# 敵対させるためのダメージ
    execute if score $Health Temporary matches 1.. as @a if score @s UserID = $LatestModifiedUser UserID run tag @s add UUIDAttacker
    execute if score $Health Temporary matches 1.. run damage @s 0 minecraft:player_attack by @p[tag=UUIDAttacker]
# ノックバック無効を削除
    attribute @s minecraft:generic.knockback_resistance modifier remove 3-0-1-0-100000001
# 代入 / kill
    execute if score $Health Temporary matches 1.. store result entity @s AbsorptionAmount float 0.001 run scoreboard players get $Health Temporary
    execute if score $Health Temporary matches ..0 as @a if score @s UserID = $LatestModifiedUser UserID run tag @s add Killer
    execute if score $Health Temporary matches ..0 as @p[tag=Killer] run advancement grant @s only core:handler/killed
    execute if score $Health Temporary matches ..0 run damage @s 9999 minecraft:player_attack by @p[tag=Killer]
    execute if score $Health Temporary matches ..0 run kill @s
# リセット
    tag @a[tag=UUIDAttacker] remove UUIDAttacker
# onAttackのトリガー
    execute if score $Health Temporary matches 1.. run function api:damage/core/trigger_on_attack


text:
#> api:damage/core/health_subtract/player
#
#
#
# @within function api:damage/core/health_subtract/

# 引数として代入
    execute store result storage api: Argument.Fluctuation double -0.0001 run scoreboard players get $Damage Temporary
    execute store result storage api: Argument.Attacker int 1 run scoreboard players get $LatestModifiedEntity MobUUID
    data modify storage api: Argument.AttackType set from storage api: Argument.AttackType
    data modify storage api: Argument.ElementType set from storage api: Argument.ElementType
# 体力の減少を反映させる
    function lib:score_to_health_wrapper/fluctuation
# onAttackのトリガー
    function api:damage/core/trigger_on_damage/


text:
#> api:data_get/xp_p
#
# 対象のXpPをstorageに軽量に取得します。
#
# @input as player
# @output storage api: XpP
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.XpP.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.XpP.Data set from entity @s XpP
# outputのstorageに移す
    data modify storage api: XpP set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.XpP.Data


text:
#> api:data_get/sleep_timer
#
# 対象のSleepTimerをstorageに軽量に取得します。
#
# @input as player
# @output storage api: SleepTimer
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepTimer.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepTimer.Data set from entity @s SleepTimer
# outputのstorageに移す
    data modify storage api: SleepTimer set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepTimer.Data


text:
#> api:data_get/sleeping_x
#
# 対象のSleepingXをstorageに軽量に取得します。
#
# @input as player
# @output storage api: SleepingX
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepingX.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepingX.Data set from entity @s SleepingX
# outputのstorageに移す
    data modify storage api: SleepingX set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepingX.Data


text:
#> api:data_get/portal_cooldown
#
# 対象のPortalCooldownをstorageに軽量に取得します。
#
# @input as player
# @output storage api: PortalCooldown
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.PortalCooldown.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.PortalCooldown.Data set from entity @s PortalCooldown
# outputのstorageに移す
    data modify storage api: PortalCooldown set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.PortalCooldown.Data


text:
#> api:data_get/sleeping_y
#
# 対象のSleepingYをstorageに軽量に取得します。
#
# @input as player
# @output storage api: SleepingY
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepingY.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepingY.Data set from entity @s SleepingY
# outputのstorageに移す
    data modify storage api: SleepingY set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.SleepingY.Data


text:
#> api:data_get/inventory
#
# 対象のInventoryをstorageに軽量に取得します。
#
# @input as player
# @output storage api: Inventory
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.Inventory.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.Inventory.Data set from entity @s Inventory
# outputのstorageに移す
    data modify storage api: Inventory set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.Inventory.Data


text:
#> api:data_get/rotation_fetch
#
# Rotationデータを汎用Entityから取得します
#
# @within function api:data_get/rotation

# fetch
    execute in overworld run tp @s ~ ~ ~ ~ ~
    data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.Rotation.Data set from entity @s Rotation
# リセット
    execute in overworld run tp @s 0.0 0.0 0.0 0.0 0.0


text:
#> api:data_get/id
#
# 対象のidをstorageに軽量に取得します。
#
# @input as player
# @output storage api: id
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.id.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.id.Data set from entity @s id
# outputのstorageに移す
    data modify storage api: id set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.id.Data


text:
#> api:data_get/hurt_time
#
# 対象のHurtTimeをstorageに軽量に取得します。
#
# @input as player
# @output storage api: HurtTime
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.HurtTime.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.HurtTime.Data set from entity @s HurtTime
# outputのstorageに移す
    data modify storage api: HurtTime set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.HurtTime.Data


text:
#> api:data_get/fire
#
# 対象のFireをstorageに軽量に取得します。
#
# @input as player
# @output storage api: Fire
# @public

#>Temp
# @private
    #declare score_holder $NotLatestData

# EntityStorage呼び出し
    function oh_my_dat:please
# 最新のものかチェックし、最新じゃなければ取得
    execute store result score $NotLatestData Temporary run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.Fire.Time set from storage global Time
    execute if score $NotLatestData Temporary matches 1 run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.Fire.Data set from entity @s Fire
# outputのstorageに移す
    data modify storage api: Fire set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].DataCache.Fire.Data