Skip to content

Commit 82e7810

Browse files
committed
🚚 lib:motion/ に処理を統合
1 parent 42dc252 commit 82e7810

18 files changed

Lines changed: 145 additions & 88 deletions

File tree

PlayerMotion/data/player_motion/functions/api/launch_looking.mcfunction

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Launches the player in the input direction
44
#
5-
# @within function lib:player_motion/launch_looking
5+
# @api
66

77
execute if entity @s[type=!player] run return fail
88
execute on vehicle run return fail

PlayerMotion/data/player_motion/functions/api/launch_xyz.mcfunction

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Launches the player in the input direction
44
#
5-
# @within function lib:player_motion/launch_xyz
5+
# @api
66

77
execute if entity @s[type=!player] run return fail
88
execute on vehicle run return fail
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
#> lib:motion/
2-
#
3-
# 実行座標の前方にlib: Argument.VectorMagnitudeの大きさのMotionを付与します。
4-
#
5-
# 実行者はPlayer以外のEntityである必要があります。
6-
#
7-
# ※いずれかのMotionが10以上の場合Minecraftの仕様上動作しません。
8-
#
2+
# @deprecated change to `lib:motion/looking`
93
# @input
104
# as entity
115
# storage lib:
126
# Argument.KnockbackResist?: boolean
137
# Argument.VectorMagnitude: double
148
# @api
159

16-
# 引数を設定
17-
execute unless data storage lib: Argument.KnockbackResist run data modify storage lib: Argument.KnockbackResist set value 0b
18-
19-
# PlayerならErrorを出力
20-
execute if entity @s[type=player] run tellraw @s [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"MotionLibの実行者はPlayer以外のEntityである必要があります"}]
21-
# Playerじゃなければ本処理に移行
22-
execute unless entity @s[type=player,tag=!Uninterferable] run function lib:motion/core/
10+
function lib:motion/looking

TheSkyBlessing/data/lib/functions/motion/_index.d.mcfunction

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# @private
33

44
#> Val
5-
# @within function lib:motion/core/*
5+
# @within function lib:motion/core/*/*
66
#declare score_holder $VectorMagnitude
7-
#declare score_holder $KnockbackResist
7+
#declare score_holder $KnockbackResist
8+
9+
#> api
10+
# @within function lib:motion/core/*/player
11+
#declare score_holder $strength
12+
#declare score_holder $x
13+
#declare score_holder $y
14+
#declare score_holder $z

TheSkyBlessing/data/lib/functions/motion/core/.mcfunction

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#> lib:motion/core/looking/
2+
#
3+
#
4+
#
5+
# @within function lib:motion/looking
6+
7+
# 値を取得
8+
execute store result score $VectorMagnitude Temporary run data get storage lib: Argument.VectorMagnitude 10000
9+
10+
# KB耐性を計算
11+
execute if data storage lib: Argument{KnockbackResist:1b} store result score $KnockbackResist Temporary run attribute @s generic.knockback_resistance get 100
12+
execute if data storage lib: Argument{KnockbackResist:1b} run function lib:motion/core/looking/knockback_resistance
13+
14+
# 適用
15+
execute if entity @s[type=player] run function lib:motion/core/looking/player
16+
execute if entity @s[type=!player,tag=!Uninterferable] run function lib:motion/core/looking/non-player
17+
18+
# リセット
19+
scoreboard players reset $VectorMagnitude Temporary
20+
scoreboard players reset $KnockbackResist Temporary

TheSkyBlessing/data/lib/functions/motion/core/knockback_resistance.mcfunction renamed to TheSkyBlessing/data/lib/functions/motion/core/looking/knockback_resistance.mcfunction

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
#> lib:motion/core/knockback_resistance
1+
#> lib:motion/core/looking/knockback_resistance
22
#
33
#
44
#
5-
# @within function lib:motion/core/
5+
# @within function lib:motion/core/looking/
66

77
#> private
88
# @private
9-
#declare score_holder $Calc
9+
#declare score_holder $Calc
1010

1111
# 100からノックバック耐性を引いた値を出す
1212
scoreboard players set $Calc Temporary 100
1313
scoreboard players operation $Calc Temporary -= $KnockbackResist Temporary
1414
scoreboard players operation $Calc Temporary >< $KnockbackResist Temporary
15-
# $VectorMagnitudeの数値ととノックバック耐性をかける
15+
# $VectorMagnitudeの数値とノックバック耐性をかける
1616
scoreboard players operation $VectorMagnitude Temporary *= $KnockbackResist Temporary
1717
# 100で割る
1818
scoreboard players operation $VectorMagnitude Temporary /= $100 Const
1919

2020
# 計算用スコアホルダーをリセット
21-
scoreboard players reset $Calc
21+
scoreboard players reset $Calc

TheSkyBlessing/data/lib/functions/motion/core/apply.mcfunction renamed to TheSkyBlessing/data/lib/functions/motion/core/looking/non-player.mcfunction

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#> lib:motion/core/apply
1+
#> lib:motion/core/looking/non-player
22
#
33
#
44
#
5-
# @within function lib:motion/core/
5+
# @within function lib:motion/core/looking/
66

77
#> Val
88
# @private
@@ -15,9 +15,9 @@
1515

1616
# 演算処理
1717
data modify storage lib: Pos set from entity 0-0-0-0-0 Pos
18-
execute store result score $VectorX Temporary run data get storage lib: Pos[0] 1000
19-
execute store result score $VectorY Temporary run data get storage lib: Pos[1] 1000
20-
execute store result score $VectorZ Temporary run data get storage lib: Pos[2] 1000
18+
execute store result score $VectorX Temporary run data get storage lib: Pos[0] 10
19+
execute store result score $VectorY Temporary run data get storage lib: Pos[1] 10
20+
execute store result score $VectorZ Temporary run data get storage lib: Pos[2] 10
2121

2222
scoreboard players operation $VectorX Temporary *= $VectorMagnitude Temporary
2323
scoreboard players operation $VectorY Temporary *= $VectorMagnitude Temporary
@@ -33,4 +33,4 @@
3333
scoreboard players reset $VectorX Temporary
3434
scoreboard players reset $VectorY Temporary
3535
scoreboard players reset $VectorZ Temporary
36-
data remove storage lib: Pos
36+
data remove storage lib: Pos
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#> lib:motion/core/looking/player
2+
#
3+
#
4+
#
5+
# @within function lib:motion/core/looking/
6+
7+
# PlayerMotionを呼び出す
8+
scoreboard players operation $strength PlayerMotion.Api.Launch = $VectorMagnitude Temporary
9+
function player_motion:api/launch_looking
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#> lib:motion/core/xyz/
2+
#
3+
#
4+
#
5+
# @within function lib:motion/xyz
6+
7+
# KB耐性を乗算
8+
execute if data storage lib: Argument{KnockbackResist:1b} store result score $KnockbackResist Temporary run attribute @s generic.knockback_resistance get 100
9+
execute if data storage lib: Argument{KnockbackResist:1b} run function lib:motion/core/xyz/knockback_resistance
10+
11+
# 適用
12+
execute if entity @s[type=player] run function lib:motion/core/xyz/player
13+
execute if entity @s[type=!player,tag=!Uninterferable] run data modify entity @s Motion set from storage lib: Vector
14+
15+
# リセット
16+
scoreboard players reset $KnockbackResist Temporary

0 commit comments

Comments
 (0)