From 069d4f2ce3c6f7aa4ef4764d81635356b6c178ad Mon Sep 17 00:00:00 2001 From: Aksiome <54895777+aksiome@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:33:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Rename=20and=20update=20id=20pre?= =?UTF-8?q?dicates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../functions/update_cuids/loop.mcfunction | 4 +- .../functions/update_cuids/shift.mcfunction | 2 +- .../data/bs.id/predicates/cuid_equal.json | 24 +++++ .../data/bs.id/predicates/cuid_lower.json | 2 +- .../data/bs.id/predicates/cuid_match.json | 4 +- .../data/bs.id/predicates/cuid_upper.json | 2 +- .../data/bs.id/predicates/suid_equal.json | 24 +++++ .../data/bs.id/predicates/suid_lower.json | 2 +- .../data/bs.id/predicates/suid_match.json | 4 +- .../data/bs.id/predicates/suid_upper.json | 2 +- docs/modules/id.md | 98 +++++++++++++------ 11 files changed, 129 insertions(+), 39 deletions(-) create mode 100644 datapacks/Bookshelf/data/bs.id/predicates/cuid_equal.json create mode 100644 datapacks/Bookshelf/data/bs.id/predicates/suid_equal.json diff --git a/datapacks/Bookshelf/data/bs.id/functions/update_cuids/loop.mcfunction b/datapacks/Bookshelf/data/bs.id/functions/update_cuids/loop.mcfunction index e2384f4206..51599cbb2b 100644 --- a/datapacks/Bookshelf/data/bs.id/functions/update_cuids/loop.mcfunction +++ b/datapacks/Bookshelf/data/bs.id/functions/update_cuids/loop.mcfunction @@ -1,3 +1,3 @@ -scoreboard players add $id.cuid.check bs.in 1 -execute unless entity @e[predicate=bs.id:cuid_match,sort=arbitrary,limit=1] run function bs.id:update_cuids/shift +scoreboard players add $id.cuid bs.in 1 +execute unless entity @e[predicate=bs.id:cuid_equal,sort=arbitrary,limit=1] run function bs.id:update_cuids/shift execute if score #size bs.cid < #counter bs.cid run function bs.id:update_cuids/loop diff --git a/datapacks/Bookshelf/data/bs.id/functions/update_cuids/shift.mcfunction b/datapacks/Bookshelf/data/bs.id/functions/update_cuids/shift.mcfunction index 1d7abe8a73..2f152957e3 100644 --- a/datapacks/Bookshelf/data/bs.id/functions/update_cuids/shift.mcfunction +++ b/datapacks/Bookshelf/data/bs.id/functions/update_cuids/shift.mcfunction @@ -1,3 +1,3 @@ scoreboard players remove #counter bs.cid 1 scoreboard players remove @e[predicate=bs.id:cuid_upper,sort=arbitrary] bs.cid 1 -execute if score #size bs.cid < #counter bs.cid unless entity @e[predicate=bs.id:cuid_match,sort=arbitrary,limit=1] run function bs.id:update_cuids/shift +execute if score #size bs.cid < #counter bs.cid unless entity @e[predicate=bs.id:cuid_equal,sort=arbitrary,limit=1] run function bs.id:update_cuids/shift diff --git a/datapacks/Bookshelf/data/bs.id/predicates/cuid_equal.json b/datapacks/Bookshelf/data/bs.id/predicates/cuid_equal.json new file mode 100644 index 0000000000..648682dc7a --- /dev/null +++ b/datapacks/Bookshelf/data/bs.id/predicates/cuid_equal.json @@ -0,0 +1,24 @@ +{ + "condition": "minecraft:entity_scores", + "entity": "this", + "scores": { + "bs.cid": { + "min": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "$id.cuid" + }, + "score": "bs.in" + }, + "max": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "$id.cuid" + }, + "score": "bs.in" + } + } + } +} diff --git a/datapacks/Bookshelf/data/bs.id/predicates/cuid_lower.json b/datapacks/Bookshelf/data/bs.id/predicates/cuid_lower.json index 1145d1c614..5ad4132117 100644 --- a/datapacks/Bookshelf/data/bs.id/predicates/cuid_lower.json +++ b/datapacks/Bookshelf/data/bs.id/predicates/cuid_lower.json @@ -7,7 +7,7 @@ "type": "minecraft:score", "target": { "type": "minecraft:fixed", - "name": "$id.cuid.check" + "name": "$id.cuid" }, "score": "bs.in" } diff --git a/datapacks/Bookshelf/data/bs.id/predicates/cuid_match.json b/datapacks/Bookshelf/data/bs.id/predicates/cuid_match.json index 7d7daae434..74dc2dace6 100644 --- a/datapacks/Bookshelf/data/bs.id/predicates/cuid_match.json +++ b/datapacks/Bookshelf/data/bs.id/predicates/cuid_match.json @@ -7,7 +7,7 @@ "type": "minecraft:score", "target": { "type": "minecraft:fixed", - "name": "$id.cuid.check" + "name": "$id.cuid.min" }, "score": "bs.in" }, @@ -15,7 +15,7 @@ "type": "minecraft:score", "target": { "type": "minecraft:fixed", - "name": "$id.cuid.check" + "name": "$id.cuid.max" }, "score": "bs.in" } diff --git a/datapacks/Bookshelf/data/bs.id/predicates/cuid_upper.json b/datapacks/Bookshelf/data/bs.id/predicates/cuid_upper.json index acd419cd44..d40fc3f51e 100644 --- a/datapacks/Bookshelf/data/bs.id/predicates/cuid_upper.json +++ b/datapacks/Bookshelf/data/bs.id/predicates/cuid_upper.json @@ -7,7 +7,7 @@ "type": "minecraft:score", "target": { "type": "minecraft:fixed", - "name": "$id.cuid.check" + "name": "$id.cuid" }, "score": "bs.in" } diff --git a/datapacks/Bookshelf/data/bs.id/predicates/suid_equal.json b/datapacks/Bookshelf/data/bs.id/predicates/suid_equal.json new file mode 100644 index 0000000000..da943586d3 --- /dev/null +++ b/datapacks/Bookshelf/data/bs.id/predicates/suid_equal.json @@ -0,0 +1,24 @@ +{ + "condition": "minecraft:entity_scores", + "entity": "this", + "scores": { + "bs.id": { + "min": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "$id.suid" + }, + "score": "bs.in" + }, + "max": { + "type": "minecraft:score", + "target": { + "type": "minecraft:fixed", + "name": "$id.suid" + }, + "score": "bs.in" + } + } + } +} diff --git a/datapacks/Bookshelf/data/bs.id/predicates/suid_lower.json b/datapacks/Bookshelf/data/bs.id/predicates/suid_lower.json index 9eac45111b..bb6717940f 100644 --- a/datapacks/Bookshelf/data/bs.id/predicates/suid_lower.json +++ b/datapacks/Bookshelf/data/bs.id/predicates/suid_lower.json @@ -7,7 +7,7 @@ "type": "minecraft:score", "target": { "type": "minecraft:fixed", - "name": "$id.suid.check" + "name": "$id.suid" }, "score": "bs.in" } diff --git a/datapacks/Bookshelf/data/bs.id/predicates/suid_match.json b/datapacks/Bookshelf/data/bs.id/predicates/suid_match.json index 429c83ea7e..9d66e3efdd 100644 --- a/datapacks/Bookshelf/data/bs.id/predicates/suid_match.json +++ b/datapacks/Bookshelf/data/bs.id/predicates/suid_match.json @@ -7,7 +7,7 @@ "type": "minecraft:score", "target": { "type": "minecraft:fixed", - "name": "$id.suid.check" + "name": "$id.suid.min" }, "score": "bs.in" }, @@ -15,7 +15,7 @@ "type": "minecraft:score", "target": { "type": "minecraft:fixed", - "name": "$id.suid.check" + "name": "$id.suid.max" }, "score": "bs.in" } diff --git a/datapacks/Bookshelf/data/bs.id/predicates/suid_upper.json b/datapacks/Bookshelf/data/bs.id/predicates/suid_upper.json index 3b42624b09..fe7873355f 100644 --- a/datapacks/Bookshelf/data/bs.id/predicates/suid_upper.json +++ b/datapacks/Bookshelf/data/bs.id/predicates/suid_upper.json @@ -7,7 +7,7 @@ "type": "minecraft:score", "target": { "type": "minecraft:fixed", - "name": "$id.suid.check" + "name": "$id.suid" }, "score": "bs.in" } diff --git a/docs/modules/id.md b/docs/modules/id.md index d729ab9d6f..eeed374581 100644 --- a/docs/modules/id.md +++ b/docs/modules/id.md @@ -105,21 +105,35 @@ You can find below all predicates available in this module. ### Check simple unique ID ::::{tab-set} -:::{tab-item} Match +:::{tab-item} Has -```{function} bs.id:suid_match +```{function} bs.id:has_suid + +Determine if an entity has a `bs.id` score. +``` + +*Give an suid to all entities that aren't identified by a `bs.id` score:* + +```mcfunction +execute as @e[predicate=!bs.id:has_suid] run function #bs.id:give_suid +``` + +::: +:::{tab-item} Equal + +```{function} bs.id:suid_equal Find an entity that has the same `bs.id` as the input value. :Inputs: - **Score `$id.suid.check bs.in`**: Value to check against. + **Score `$id.suid bs.in`**: Value to check against. ``` *Find the entity that has a `bs.id` equal to 1:* ```mcfunction -scoreboard players set $id.suid.check bs.in 1 -execute as @e[predicate=bs.id:suid_match,limit=1] run say I'm the one +scoreboard players set $id.suid bs.in 1 +execute as @e[predicate=bs.id:suid_equal,limit=1] run say I'm the one ``` ::: @@ -130,13 +144,13 @@ execute as @e[predicate=bs.id:suid_match,limit=1] run say I'm the one Filter entities that have a `bs.id` less than or equal to the input value. :Inputs: - **Score `$id.suid.check bs.in`**: Value to check against. + **Score `$id.suid bs.in`**: Value to check against. ``` *Filter entities that have a `bs.id` less than or equal to 17:* ```mcfunction -scoreboard players set $id.suid.check bs.in 17 +scoreboard players set $id.suid bs.in 17 execute as @e[predicate=bs.id:suid_lower] run say I'm a minor ``` @@ -148,28 +162,35 @@ execute as @e[predicate=bs.id:suid_lower] run say I'm a minor Filter entities that have a `bs.id` greater than or equal to the input value. :Inputs: - **Score `$id.suid.check bs.in`**: Value to check against. + **Score `$id.suid bs.in`**: Value to check against. ``` *Filter entities that have a `bs.id` greater than or equal to 18:* ```mcfunction -scoreboard players set $id.suid.check bs.in 18 +scoreboard players set $id.suid bs.in 18 execute as @e[predicate=bs.id:suid_upper] run say I'm an adult ``` ::: -:::{tab-item} Has +:::{tab-item} Match -```{function} bs.id:has_suid +```{function} bs.id:suid_match -Determine if an entity has a `bs.id` score. +Filter entities that have a `bs.id` between the given values. + +:Inputs: + **Score `$id.suid.min bs.in`**: Min value to check against. + + **Score `$id.suid.max bs.in`**: Min value to check against. ``` -*Give an suid to all entities that aren't identified by a `bs.id` score:* +*Filter entities that have a `bs.id` between 2 and 4:* ```mcfunction -execute as @e[predicate=!bs.id:has_suid] run function #bs.id:give_suid +scoreboard players set $id.suid.min bs.in 2 +scoreboard players set $id.suid.max bs.in 4 +execute as @e[predicate=bs.id:suid_match,limit=1] run say In range ``` ::: @@ -182,21 +203,35 @@ execute as @e[predicate=!bs.id:has_suid] run function #bs.id:give_suid ### Check chain unique ID ::::{tab-set} -:::{tab-item} Match +:::{tab-item} Has -```{function} bs.id:cuid_match +```{function} bs.id:has_cuid + +Determine if an entity has a `bs.cid` score. +``` + +*Give an cuid to all entities that aren't identified by a `bs.cid` score:* + +```mcfunction +execute as @e[predicate=!bs.id:has_cuid] run function #bs.id:give_cuid +``` + +::: +:::{tab-item} Equal + +```{function} bs.id:cuid_equal Find an entity that has the same `bs.cid` as the input value. :Inputs: - **Score `$id.cuid.check bs.in`**: Value to check against. + **Score `$id.cuid bs.in`**: Value to check against. ``` *Find the entity that has a `bs.cid` equal to 1:* ```mcfunction -scoreboard players set $id.cuid.check bs.in 1 -execute as @e[predicate=bs.id:cuid_match,limit=1] run say I'm the one +scoreboard players set $id.cuid bs.in 1 +execute as @e[predicate=bs.id:cuid_equal,limit=1] run say I'm the one ``` ::: @@ -207,13 +242,13 @@ execute as @e[predicate=bs.id:cuid_match,limit=1] run say I'm the one Filter entities that have a `bs.cid` less than or equal to the input value. :Inputs: - **Score `$id.cuid.check bs.in`**: Value to check against. + **Score `$id.cuid bs.in`**: Value to check against. ``` *Filter entities that have a `bs.cid` less than or equal to 17:* ```mcfunction -scoreboard players set $id.cuid.check bs.in 17 +scoreboard players set $id.cuid bs.in 17 execute as @e[predicate=bs.id:cuid_lower] run say I'm a minor ``` @@ -225,28 +260,35 @@ execute as @e[predicate=bs.id:cuid_lower] run say I'm a minor Filter entities that have a `bs.cid` greater than or equal to the input value. :Inputs: - **Score `$id.cuid.check bs.in`**: Value to check against. + **Score `$id.cuid bs.in`**: Value to check against. ``` *Filter entities that have a `bs.cid` greater than or equal to 18:* ```mcfunction -scoreboard players set $id.cuid.check bs.in 18 +scoreboard players set $id.cuid bs.in 18 execute as @e[predicate=bs.id:cuid_upper] run say I'm an adult ``` ::: -:::{tab-item} Has +:::{tab-item} Match -```{function} bs.id:has_cuid +```{function} bs.id:cuid_match -Determine if an entity has a `bs.cid` score. +Filter entities that have a `bs.cid` between the given values. + +:Inputs: + **Score `$id.cuid.min bs.in`**: Min value to check against. + + **Score `$id.cuid.max bs.in`**: Min value to check against. ``` -*Give an cuid to all entities that aren't identified by a `bs.cid` score:* +*Filter entities that have a `bs.cid` between 2 and 4:* ```mcfunction -execute as @e[predicate=!bs.id:has_cuid] run function #bs.id:give_cuid +scoreboard players set $id.cuid.min bs.in 2 +scoreboard players set $id.cuid.max bs.in 4 +execute as @e[predicate=bs.id:cuid_match,limit=1] run say In range ``` :::