Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚚 Rename and update id predicates #177

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions datapacks/Bookshelf/data/bs.id/predicates/cuid_equal.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
2 changes: 1 addition & 1 deletion datapacks/Bookshelf/data/bs.id/predicates/cuid_lower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "$id.cuid.check"
"name": "$id.cuid"
},
"score": "bs.in"
}
Expand Down
4 changes: 2 additions & 2 deletions datapacks/Bookshelf/data/bs.id/predicates/cuid_match.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "$id.cuid.check"
"name": "$id.cuid.min"
},
"score": "bs.in"
},
"max": {
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "$id.cuid.check"
"name": "$id.cuid.max"
},
"score": "bs.in"
}
Expand Down
2 changes: 1 addition & 1 deletion datapacks/Bookshelf/data/bs.id/predicates/cuid_upper.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "$id.cuid.check"
"name": "$id.cuid"
},
"score": "bs.in"
}
Expand Down
24 changes: 24 additions & 0 deletions datapacks/Bookshelf/data/bs.id/predicates/suid_equal.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
2 changes: 1 addition & 1 deletion datapacks/Bookshelf/data/bs.id/predicates/suid_lower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "$id.suid.check"
"name": "$id.suid"
},
"score": "bs.in"
}
Expand Down
4 changes: 2 additions & 2 deletions datapacks/Bookshelf/data/bs.id/predicates/suid_match.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "$id.suid.check"
"name": "$id.suid.min"
},
"score": "bs.in"
},
"max": {
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "$id.suid.check"
"name": "$id.suid.max"
},
"score": "bs.in"
}
Expand Down
2 changes: 1 addition & 1 deletion datapacks/Bookshelf/data/bs.id/predicates/suid_upper.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "$id.suid.check"
"name": "$id.suid"
},
"score": "bs.in"
}
Expand Down
98 changes: 70 additions & 28 deletions docs/modules/id.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

:::
Expand All @@ -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
```

Expand All @@ -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
```

:::
Expand All @@ -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
```

:::
Expand All @@ -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
```

Expand All @@ -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
```

:::
Expand Down
Loading