Skip to content

Commit

Permalink
Merge branch 'master' into dev/lapis_737
Browse files Browse the repository at this point in the history
  • Loading branch information
Lapis-LJA committed Jan 23, 2024
2 parents 393ae3a + daf4960 commit dc69890
Show file tree
Hide file tree
Showing 80 changed files with 1,228 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/datapack-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- name: Test
uses: ChenCMD/datapack-linter@v2
with:
GITHUB_TOKEN: ${{ github.token }}
muteSuccessResult: true
ignoreLintPathPattern: |
animated_java:**
Expand Down Expand Up @@ -51,6 +52,12 @@ jobs:
function@asset:artifact/artifact_name/trigger/2.check_condition
function@asset:artifact/artifact_name/trigger/3.main
function@asset:artifact/artifact_name/give/2.give
function@asset:effect/effect_name/register
function@asset:effect/effect_name/given/
function@asset:effect/effect_name/tick/
function@asset:effect/effect_name/re-given/
function@asset:effect/effect_name/remove/
function@asset:effect/effect_name/end/
function@asset:island/island_id/register/register
function@asset:mob/mob_name/summon/2.summon
function@asset:mob/mob_name/register
Expand Down
2 changes: 1 addition & 1 deletion Asset/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2022 ProjectTSB
Copyright (c) 2020-2024 ProjectTSB

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 5 additions & 0 deletions Asset/data/asset/tags/functions/effect/end.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [

]
}
5 changes: 5 additions & 0 deletions Asset/data/asset/tags/functions/effect/given.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [

]
}
5 changes: 5 additions & 0 deletions Asset/data/asset/tags/functions/effect/load.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [

]
}
5 changes: 5 additions & 0 deletions Asset/data/asset/tags/functions/effect/re-given.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [

]
}
5 changes: 5 additions & 0 deletions Asset/data/asset/tags/functions/effect/register.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [

]
}
5 changes: 5 additions & 0 deletions Asset/data/asset/tags/functions/effect/remove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [

]
}
5 changes: 5 additions & 0 deletions Asset/data/asset/tags/functions/effect/tick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [

]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> api:entity/mob/effect/core/get/from_id.m
# @input args
# ID : int
# 欲しいエフェクトのID
# @within function api:entity/mob/effect/get/from_id

data remove storage api: Return.Effect
function oh_my_dat:please
$data modify storage api: Return.Effect set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Effects[{ID:$(ID)}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#> api:entity/mob/effect/core/give
#
#
#
# @within function api:entity/mob/effect/give

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

# ID
data modify storage asset:context id set from storage api: Argument.ID
# prefill
data modify storage asset:effect Duration set from storage api: Argument.Duration
data modify storage asset:effect Stack set from storage api: Argument.Stack
data modify storage asset:effect DurationOperation set from storage api: Argument.DurationOperation
data modify storage asset:effect StackOperation set from storage api: Argument.StackOperation
# API側Opt値のprefill
execute unless data storage asset:effect Stack run data modify storage asset:effect Stack set value 1
execute unless data storage asset:effect DurationOperation run data modify storage asset:effect DurationOperation set value "replace"
execute unless data storage asset:effect StackOperation run data modify storage asset:effect StackOperation set value "replace"
# register側Opt値のprefill
data modify storage asset:effect MaxDuration set value 2147483647
data modify storage asset:effect MaxStack set value 2147483647
data modify storage asset:effect ProcessOnDied set value "remove"
data modify storage asset:effect RequireClearLv set value 1

# データを取得
function #asset:effect/register
# データチェック
execute unless data storage asset:effect ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"次のIDのエフェクトは存在しません: "},{"storage":"api:","nbt":"Argument.ID"}]
# 継承が行われている場合そのデータを追加する
execute if data storage asset:effect ID if data storage asset:effect Extends[0] run function api:entity/mob/effect/core/put_id_to_map
# データが正しくあれば呼び出す
execute if data storage asset:effect ID run function asset_manager:effect/give/

# リセット
data remove storage asset:effect ID
data remove storage asset:effect Extends
data remove storage asset:effect Name
data remove storage asset:effect Description
data remove storage asset:effect Duration
data remove storage asset:effect Stack
data remove storage asset:effect DurationOperation
data remove storage asset:effect StackOperation
data remove storage asset:effect MaxDuration
data remove storage asset:effect MaxStack
data remove storage asset:effect IsBadEffect
data remove storage asset:effect ProcessOnDied
data remove storage asset:effect RequireClearLv
data remove storage asset:effect Field

data remove storage asset:effect NonExistsInRom

# 退避させたasset:context idを戻す
function asset_manager:common/context_id/pop
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#> api:entity/mob/effect/core/put_id_to_map
#
#
#
# @within function api:entity/mob/effect/core/*

# ID:1, Extends: [2, 3, 4] => 1 -> 2, 2 -> 3, 3 -> 4

# Extends に1要素しかなければ ID をキーにする
execute unless data storage asset:effect Extends[1] run data modify storage api: Argument.Address set from storage asset:effect ID
# Extends に2要素あれば Extends の最後から2番目の要素をキーにする
execute if data storage asset:effect Extends[1] run data modify storage api: Argument.Address set from storage asset:effect Extends[-2]

# キーからROMを呼び出す
function api:rom/please

# データを保存しつつ、すでにデータが入っているかを確認する
execute store result storage asset:effect NonExistsInRom byte 1 run data modify storage rom: _[-4][-4][-4][-4][-4][-4][-4][-4].Effect.Extends set from storage asset:effect Extends[-1]

# リセット
data remove storage asset:effect Extends[-1]

# まだExtendsが残っていて、かつROMに保存されていなければれば再帰する
execute if data storage asset:effect Extends[0] if data storage asset:effect {NonExistsInRom:true} run function api:entity/mob/effect/core/put_id_to_map
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#> api:entity/mob/effect/core/remove/from_id
#
#
#
# @within function api:entity/mob/effect/remove/from_id

# 該当IDのデータを引っこ抜く
data modify storage asset:effect ID set from storage api: Argument.ID
function asset_manager:effect/common/try_pop_effect_data
# 存在する場合は残り時間を-1に設定して元に戻す
execute if data storage asset:effect TargetEffectData run data modify storage asset:effect TargetEffectData.Duration set value -1
execute if data storage asset:effect TargetEffectData run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Effects append from storage asset:effect TargetEffectData
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#> api:entity/mob/effect/core/remove/from_level/
#
#
#
# @within function api:entity/mob/effect/remove/from_level

# storage呼び出し
function oh_my_dat:please
# effect id抽出
data modify storage asset:effect IDList append from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Effects[].ID
# 条件を代入
data modify storage asset:effect ClearType set from storage api: Argument.ClearType
data modify storage asset:effect IsSingle set from storage api: Argument.IsSingle
# ループに入れる
function api:entity/mob/effect/core/remove/from_level/recursion
# リセット
data remove storage asset:effect IDList
data remove storage asset:effect Type
data remove storage asset:effect IsSingle
data remove storage asset:effect CanRemove
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#> api:entity/mob/effect/core/remove/from_level/recursion
#
#
#
# @within function
# api:entity/mob/effect/core/remove/from_level/
# api:entity/mob/effect/core/remove/from_level/recursion

#> private
# @private
#declare score_holder $ClearLv
#declare score_holder $RequiredLv

# 末尾を取り出す
data modify storage asset:effect ID set from storage asset:effect IDList[-1]
function asset_manager:effect/common/try_pop_effect_data

# 存在する場合
data modify storage asset:effect CanRemove set value true
# レベルチェック
execute unless data storage asset:effect TargetEffectData run data modify storage asset:effect CanRemove set value false
execute if data storage asset:effect TargetEffectData store result score $ClearLv Temporary run data get storage api: Argument.ClearLv 1
execute if data storage asset:effect TargetEffectData store result score $RequiredLv Temporary run data get storage api: Argument.RequireClearLv 1
execute unless score $ClearLv Temporary >= $RequiredLv Temporary run data modify storage asset:effect CanRemove set value false
# 削除条件の確認
execute if data storage asset:effect {TargetEffectData:{IsBadEffect:false},ClearType:"bad"} run data modify storage asset:effect CanRemove set value false
execute if data storage asset:effect {TargetEffectData:{IsBadEffect:true},ClearType:"good"} run data modify storage asset:effect CanRemove set value false
# 条件を満たしている場合残り時間に-1を代入する
execute if data storage asset:effect {CanRemove:true} run data modify storage asset:effect TargetEffectData.Duration set value -1
# 結果を戻す
execute if data storage asset:effect TargetEffectData run data modify storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Effects append from storage asset:effect TargetEffectData

# リセット
data remove storage asset:effect ID
data remove storage asset:effect TargetEffectData

# 残っていたら再帰
data remove storage asset:effect IDList[-1]
execute unless data storage asset:effect {CanRemove:true,IsSingle:true} if data storage asset:effect IDList[0] run function api:entity/mob/effect/core/remove/from_level/recursion
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#> api:entity/mob/effect/get/all
#
# Effect一覧を取得する
#
# @input as player
# @api

# storage呼び出し
function oh_my_dat:please

# エフェクトを取得
data modify storage api: Return.EffectList set from storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Effects
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#> api:entity/mob/effect/get/from_id
#
# ID指定で自分の持つエフェクトを拾い上げる
#
# @input
# as player
# storage api:
# Argument.ID : int
# @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 api:entity/mob/effect/core/get/from_id.m with storage api: Argument
# reset
data remove storage api: Argument.ID
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> api:entity/mob/effect/get/size/all
#
# entityに付与されている全てのエフェクトの数を取得します。
#
# @api

# storage呼び出し
function oh_my_dat:please
# エフェクト数を取得
execute store result storage api: Return.EffectSize.All int 1 if data storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Effects[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> api:entity/mob/effect/get/size/bad
#
# entityに付与されている悪い効果のエフェクトの数を取得します。
#
# @api

# storage呼び出し
function oh_my_dat:please
# エフェクト数を取得
execute store result storage api: Return.EffectSize.Bad int 1 if data storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Effects[{IsBadEffect: 1b}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> api:entity/mob/effect/get/size/good
#
# entityに付与されている良い効果のエフェクトの数を取得します。
#
# @api

# storage呼び出し
function oh_my_dat:please
# エフェクト数を取得
execute store result storage api: Return.EffectSize.Good int 1 if data storage oh_my_dat: _[-4][-4][-4][-4][-4][-4][-4][-4].Effects[{IsBadEffect: 0b}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#> api:entity/mob/effect/give
#
# entityにエフェクトを与えます。
#
# @input storage api:
# Argument.ID : int
# Argument.Duration? : int (default: Asset | error)
# Argument.Stack? : int (default: 1)
# Argument.DurationOperation? : "forceReplace" | "replace" | "add" (default: "replace")
# Argument.StackOperation? : "forceReplace" | "replace" | "add" (default: "replace")
# @api

# validate
execute unless data storage api: Argument.ID run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません"},{"text":" ID","color":"red"}]
# 呼び出し
execute if data storage api: Argument.ID run function api:entity/mob/effect/core/give
# リセット
data remove storage api: Argument.ID
data remove storage api: Argument.Duration
data remove storage api: Argument.Stack
data remove storage api: Argument.DurationOperation
data remove storage api: Argument.StackOperation
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#> api:entity/mob/effect/remove/from_id
#
# entityから特定のエフェクトを削除します
#
# @input storage api:
# Argument.ID : int
# @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 if entity @s[tag=HasAssetEffect] run function api:entity/mob/effect/core/remove/from_id
# リセット
data remove storage api: Argument.ID
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#> api:entity/mob/effect/remove/from_level
#
# entityに付与されているエフェクトのうち、ClearLvと条件を満たすものを全て削除します
#
# @input storage api:
# Argument.ClearLv : int
# Argument.ClearType? : "all" | "bad" | "good" (default: "all")
# Argument.IsSingle? : bool (default: false)
# @api

# validate
execute unless data storage api: Argument.ClearLv run tellraw @a [{"storage":"global","nbt":"Prefix.ERROR"},{"text":"引数が足りません","color":"white"},{"text":" ClearLv","color":"red"}]
execute unless data storage api: Argument.ClearType run data modify storage api: Argument.ClearType set value "all"
execute unless data storage api: Argument.IsSingle run data modify storage api: Argument.IsSingle set value false
# 呼び出し
execute if data storage api: Argument.ClearLv if entity @s[tag=HasAssetEffect] run function api:entity/mob/effect/core/remove/from_level/
# リセット
data remove storage api: Argument.ClearLv
data remove storage api: Argument.ClearType
data remove storage api: Argument.IsSingle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#> asset:effect/ex.2/_/register
#
#
#
# @within tag/function asset:effect/register

execute if data storage asset:context {id:65534} run function asset:effect/ex.2/register
Loading

0 comments on commit dc69890

Please sign in to comment.