diff --git a/docs/commands/block-entities.md b/docs/commands/block-entities.md index b28a70f236d..4cc106a040a 100644 --- a/docs/commands/block-entities.md +++ b/docs/commands/block-entities.md @@ -30,150 +30,163 @@ To preserve credits to the creator, the community termed this method as "Max's B ## Setup *To be typed in chat:* -1. `/summon armor_stand Grumm` +1. `/summon armor_stand ~~~ 81 ~ default "Grumm"` + - We will set the Y (horizontal) rotation to `81` to align with the normal Minecraft block grid. - It is necessary to name it 'Grumm' to avoid inverted block textures. -2. `/execute as @e [type= armor_stand, name=Grumm, c=1] at @s run tp @s ~~~ 260` - - This will match the MBE rotation to the normal Minecraft block grid. :::tip -- Crouch & right-click (on mcpe: long press) the armor stand 6 times to place it in Pose 7 - - Doing this negates the need to use the 2nd command in the system below. +- Crouch & right-click (on mcpe: long press) the armor stand 6 times to place it in 'Entertain' pose. + - Doing this negates the need to use the 1st command in the system below. - **Only use this if you wish to reduce one command from the system.** ::: -3. Lastly, place the desired block item in the armor stand's main-hand. +2. Lastly, place the desired block item in the armor stand's main-hand. :::tip - `/replaceitem entity @e [name=Grumm] slot.weapon.offhand 0 ` - - Instead of manually placing the desired block item in the armor stand's main-hand, use this command to place it in it's offhand to prevent players from taking the item. + - Instead of manually placing the desired block item in the armor stand's main-hand, use this command to place it in it's off-hand to prevent players from taking the item. ::: ## System -> Note: Adding a delay of 100-200 ticks is recommended. - -BP/functions/MBE/render.mcfunction +BP/functions/mbe/render.mcfunction ```yaml -effect @e [type= armor_stand, name=Grumm] invisibility 999999 1 true -playanimation @e [type= armor_stand, name=Grumm] animation.armor_stand.entertain_pose null 0 "0" align.arms -playanimation @e [type= armor_stand, name=Grumm] animation.player.move.arms.zombie null 0 "0" size.mini_block -playanimation @e [type= armor_stand, name=Grumm] animation.ghast.scale null 0 "0" size.full_block -playanimation @e [type= armor_stand, name=Grumm] animation.fireworks_rocket.move null 0 "0" align.full_block -execute as @e [type= armor_stand, name=Grumm] at @s run tp ~~~ +## Align Arms +playanimation @e [type=armor_stand, name=Grumm] animation.armor_stand.entertain_pose null 0 "0" wiki:align.arms + +## Mini Block Size +playanimation @e [type=armor_stand, name=Grumm] animation.player.move.arms.zombie null 0 "0" wiki:size.mini_block + +## Full Block (optional) +### Size +playanimation @e [type=armor_stand, name=Grumm] animation.ghast.scale null 0 "0" wiki:size.full_block +### Align +playanimation @e [type=armor_stand, name=Grumm] animation.fireworks_rocket.move null 0 "0" wiki:align.full_block + +## Freeze Armor Stand +execute as @e [type=armor_stand, name=Grumm] at @s run tp ~~~ + +## Hide Armor Stand Body +effect @e [type=armor_stand, name=Grumm] invisibility 999999 1 true ``` ![commandBlockChain6](/assets/images/commands/commandBlockChain/6.png) ### Purpose Of Each Command -1. Hides the armor stand body. -2. Automatically sets the armor stand pose to 7 for arms alignment. Skip this command you prefer to do it manually. -3. __Required command__. Increases size to present as mini-block. -4. *Optional command.* Increases size to present as full-block. -5. *Optional command.* Aligns the full-block size MBE properly. - - Skip 4 & 5 if you do not need full-block size MBE. -6. Locks in place to prevent fall in case block beneath is removed. +1. Automatically sets the armor stand pose to 'Entertain' for arms alignment. Skip this command if you prefer to do it manually. +2. __Required command__. Increases size to present as mini-block. +3. *Optional command.* Increases size to present as full-block. +4. *Optional command.* Aligns the full-block size MBE properly. + - Skip 3 & 4 if you do not need full-block size MBE. +5. Locks the armor stand in place to prevent fall in case block beneath is removed. +6. Hides the armor stand body. + +Note: Providing a controller name allows us to stack animations without overwriting the previous one. Example: +- `wiki:align.full_block` (where `wiki` is a namespace). + +Using the same controller names above is not required. However, it can help avoid collisions with other playanimation commands. ## Rotations & Alignments > Note: These rotation commands (when item placed in main-hand) are to be triggered once through a command block. - + ```yaml -# Face North -tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2260 ~-0.097 81 +# Face north +/tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2260 ~-0.097 81 -# Face South -tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2260 ~0.097 260 +# Face south +/tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2260 ~0.097 260 -# Face East -tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2260 ~-1.1245 171 +# Face east +/tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2260 ~-1.1245 171 -# Face West -tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2260 ~1.1245 350 +# Face west +/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2260 ~1.1245 350 ``` - + ```yaml -# Face North -tp @e [type=armor_stand, name=Grumm, c=1] ~-0.417~-0.5 ~-0.035 81 +# Face north +/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.417~-0.5 ~-0.035 81 -# Face South -tp @e [type=armor_stand, name=Grumm, c=1] ~0.417 ~-0.5 ~0.035 260 +# Face south +/tp @e [type=armor_stand, name=Grumm, c=1] ~0.417 ~-0.5 ~0.035 260 -# Face East -tp @e [type=armor_stand, name=Grumm, c=1] ~0.035 ~-0.5 ~-0.417 171 +# Face east +/tp @e [type=armor_stand, name=Grumm, c=1] ~0.035 ~-0.5 ~-0.417 171 -# Face West -tp @e [type=armor_stand, name=Grumm, c=1] ~-0.035 ~-0.5 ~0.417 350 +# Face west +/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.035 ~-0.5 ~0.417 350 ``` - + ```yaml -# Face North -tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2325 ~1.1245 350 +# Face north +/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2325 ~1.1245 350 -# Face South -tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2325 ~-1.1245 171 +# Face south +/tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2325 ~-1.1245 171 -# Face East -tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2325 ~-0.097 81 +# Face east +/tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2325 ~-0.097 81 -# Face West -tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2325 ~0.097 260 +# Face west +/tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2325 ~0.097 260 ``` - + ```yaml -# Face North -tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2325 ~1.1245 350 +# Face north +/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2325 ~1.1245 350 -# Face South -tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2325 ~-1.1245 171 +# Face south +/tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2325 ~-1.1245 171 -# Face East -tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2325 ~-0.097 81 +# Face east +/tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2325 ~-0.097 81 -# Face West -tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2325 ~0.097 260 +# Face west +/tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2325 ~0.097 260 ``` - + ```yaml -# Face North -tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.484 ~-0.097 81 +# Face north +/tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.484 ~-0.097 81 -# Face South -tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.484 ~0.097 260 +# Face south +/tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.484 ~0.097 260 -# Face East -tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.484 ~-1.1245 171 +# Face east +/tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.484 ~-1.1245 171 -# Face West -tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.484 ~1.1245 350 +# Face west +/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.484 ~1.1245 350 ``` @@ -181,9 +194,9 @@ tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.484 ~1.1245 350 ## Saving & Loading MBE 1. To save, run: - - `/execute as @e [type=armor_stand, name=Grumm, c=1] at @s run structure save MBE ~~~ ~~~` + - `/execute at @e [type=armor_stand, name=Grumm, c=1] run structure save wiki ~~~ ~~~ true disk false` 2. To load, run: - - `/structure load MBE ` + - `/structure load wiki ` -> Note: Structure name `MBE` can be changed to your preference. +> Note: Structure name `wiki` can be changed to your preference. diff --git a/docs/commands/block-states.md b/docs/commands/block-states.md index 7ac2fd6a9b3..98c79872fae 100644 --- a/docs/commands/block-states.md +++ b/docs/commands/block-states.md @@ -19,12 +19,12 @@ This is used in a multitude of commands. Such as `/clone`, `/execute`, `/fill`, In Bedrock Edition, we used Aux values (also known as Metadata) to define a block. However, as of 1.19.70 and beyond, this is no longer supported and have been fully replaced with Block States instead. -example + ```yaml -#Aux Value Example: +# Aux Value example: /setblock ~ ~ ~ wool 1 -#It's Block State equivalent: +# It's Block State equivalent: /setblock ~ ~ ~ wool ["color"="orange"] ``` @@ -87,10 +87,10 @@ For example, the following commands will work: ```yaml -#Testing for a Stone Button. (aux value 0) +# Testing for a Stone Button (Aux Value 0) /execute if block ~~~ stone_button run say success -#Testing for a non-pressed Stone Button facing west. (aux value 1) +# Testing for a non-pressed Stone Button facing west (Aux Value 1) /execute if block ~~~ stone_button [“button_pressed_bit”=false,”facing_direction”=1] run say success ``` diff --git a/docs/commands/comparing-scores.md b/docs/commands/comparing-scores.md new file mode 100644 index 00000000000..4c88405ddd3 --- /dev/null +++ b/docs/commands/comparing-scores.md @@ -0,0 +1,157 @@ +--- +title: Comparing And Retrieving Scores +category: Scoreboard Systems +mention: + - BedrockCommands + - zheaEvyline +description: Learn to test for targets of matching scores / targets with the highest or lowest score. +--- + +## Introduction + +[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) + +In this guide, you will learn how to test for targets of matching scores / targets with the highest or lowest score. + +## Get Highest Score ( > ) + +**Commands:** + +BP/functions/scoreboards/player/get_highest_score.mcfunction + +```yaml +## Get Highest Score +scoreboard players operation Highest > * + +## Your Commands Here (Example) +execute as if score @s = Highest run +``` +![Chain of 2 Command Blocks](/assets/images/commands/commandBlockChain/2.png) + +**Command 1:** This command compares the `Highest` score with every other tracked score in the specified objective, and if the `Highest` score is lesser than the one being compared to, then the `Highest` score will be assigned the value of that score. To illustrate: + +| # | Player | Objective: `kills` | Comparison with `Highest` | `Highest` after comparison | +|:--:|:----------:|:------------------:|:---------------------------:|:-------------------------:| +| 1 | Alex | 10 | `Highest > Alex` | `Highest = 10` | +| 2 | Kai | 5 | `Highest > Kai` | `Highest = 10` | +| 3 | Steve | 20 | `Highest > Alex` | `Highest = 20` | + +*No change when `Highest` score is compared to player 2 after player 1 (since 10 is already greater than 5).* + +:::info NOTE: + +Wildcard (` * `) compares with all tracked scores — that includes offline players. To compare with only online players or entities, use `@a` or `@e`. + +::: + +**Command 2:** This command can be modified or expanded. It allows you to run your desired command if the `` score is equal to `Highest` score. +- Note: Use `@p` or `@e [c=1]` in place of `` if you want to limit your selection to only one. + +**Example:** + +BP/functions/scoreboards/player/get_highest_score/kills.mcfunction + +```yaml +## Get Highest Score +scoreboard players operation Highest kills > * kills + +## Tag Players With Most Kills +tag @a remove topKills +execute as @a if score @s kills = Highest kills run tag @s add topKills +``` +![Chain of 3 Command Blocks](/assets/images/commands/commandBlockChain/3.png) + +## Get Lowest Score ( < ) + +**Commands:** + +BP/functions/scoreboards/player/get_lowest_score.mcfunction + +```yaml +## Get Lowest Score +scoreboard players operation Lowest < * + +## Your Commands Here +execute as if score @s = Lowest run +``` +![Chain of 2 Command Blocks](/assets/images/commands/commandBlockChain/2.png) + +**Command 1:** This command compares the `Lowest` score with every other tracked score in the specified objective, and if the `Lowest` score is greater than the one being compared to, then the `Lowest` score will be assigned the value of that score. To illustrate: + +| # | Player | Objective: `blocks_travelled` | Comparison with `Lowest` | `Lowest` after comparison | +|:--:|:----------:|:------------------:|:---------------------------:|:-------------------------:| +| 1 | Alex | 100 | `Lowest < Alex` | `Lowest = 100` | +| 2 | Kai | 50 | `Lowest < Kai` | `Lowest = 50` | +| 3 | Steve | 200 | `Lowest < Alex` | `Lowest = 50` | + +*No change when `Lowest` score is compared to player 3 after player 2 (since 50 is already less than 200).* + +:::info NOTE: + +Wildcard (` * `) compares with all tracked scores — that includes offline players. To compare with only online players or entities, use `@a` or `@e`. + +::: + +**Command 2:** This command can be modified or expanded. It allows you to run your desired command if the `` score is equal to `Lowest` score. +- Note: Use `@p` or `@e [c=1]` in place of `` if you want to limit your selection to only one. + +**Example:** + +BP/functions/scoreboards/player/get_lowest_score/distance_travelled.mcfunction + +```yaml +## Get Lowest Score +scoreboard players operation Lowest distance_travelled < * distance_travelled + +## Tag Players With Least Distance Travelled +tag @a remove eliminate +execute as @a if score @s distance_travelled = Lowest distance_travelled run tag @s add eliminate +``` +![Chain of 3 Command Blocks](/assets/images/commands/commandBlockChain/3.png) + +## Get Matching Scores ( = ) + +This command compares the executing target's score with other selected targets. It runs the specified command for each target with a matching score. + +**Command:** + +BP/functions/scoreboards/player/get_matching_score.mcfunction + +```yaml +execute as @a at @s at @a [rm=0.01] if score @s = @p run say @s and @p have matching scores! +``` +![One Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) + +:::info NOTE: + +In the `` (where `/say` is used as an example), `@s` refers to the executing entity or player (the target), and `@p` or `@e [c=1]` refers to the entity or player being compared with. +::: + +**Visualisation:** + +![](/assets/images/commands/comparing-scores/GetMatchingScores.gif) + +**Example 1:** Teleport pet to owner if farther than 6 blocks: + +BP/functions/scoreboards/player/get_matching_score/pet.mcfunction + +```yaml +## Teleport to Owner +execute as @e [tag=pet] at @s at @a [rm=7] if score @s id = @p id run tp @s @p +``` +![One Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) + +**Example 2:** Set plot owner to Creative mode and others to Adventure mode: + +BP/functions/scoreboards/player/get_matching_score/plot.mcfunction + +```yaml +## Set Owners to Creative Mode +execute as @e [tag=plot] at @s at @a [r=16] if score @s id = @p id run gamemode c @p [m=!c] + +## Set Non-Owners to Adventure Mode +execute as @e [tag=plot] at @s at @a [r=16] unless score @s id = @p id run gamemode a @p [m=!a] +``` +![Chain of 2 Command Blocks](/assets/images/commands/commandBlockChain/2.png) + + diff --git a/docs/commands/damage.md b/docs/commands/damage.md index 4f693a32d19..6096222081d 100644 --- a/docs/commands/damage.md +++ b/docs/commands/damage.md @@ -43,14 +43,14 @@ Introduced in Minecraft Release `1.18.10`, the /damage command deals precise dam ```yaml -#Deal 4 damage to all players +# Deal 4 damage to all players /damage @a 4 -#Deal 3 'fire' damage to all entities of type 'sheep' +# Deal 3 'fire' damage to all entities of type 'sheep' /damage @e [type=sheep] 3 fire -#Deal 40 'entity attack' damage from a random player to all entities of type 'sheep' -/damage @a 40 entity_attack entity @r [type=sheep] +# Deal 40 'entity attack' damage from a random player to all entities of type 'sheep' +/damage @e [type=sheep] 40 entity_attack entity @r ``` ## Damage Cause List diff --git a/docs/commands/entity-counter.md b/docs/commands/entity-counter.md index cc87626a35e..e64efa46856 100644 --- a/docs/commands/entity-counter.md +++ b/docs/commands/entity-counter.md @@ -26,22 +26,28 @@ If you are working with functions and prefer to have the objective added automat ## System -BP/functions/entity_counter.mcfunction +BP/functions/scoreboards/entity_counter.mcfunction ```yaml +## Reset Previous Count scoreboard players set * count 0 -execute as @e [type=player] run scoreboard players add alivePlayers count 1 -execute as @e [type=creeper] run scoreboard players add creepers count 1 - -#Your Commands Here (examples) -execute if score alivePlayers count matches 4.. run title @a actionbar There are more than 4 players on the world. -execute if score creepers count matches ..3 run title @a actionbar There are less than 3 creepers on the world. +## Get Current Count (Examples) +### Alive players +execute as @e [type=player] run scoreboard players add AlivePlayers count 1 +### Creepers +execute as @e [type=creeper] run scoreboard players add Creepers count 1 + +## Your Commands Here (Examples) +### Message if 4+ alive players +execute if score AlivePlayers count matches 4.. run title @a actionbar There are more than 4 players on the world. +### Message if 3 or less creepers +execute if score Creepers count matches ..3 run title @a actionbar There are less than 3 creepers on the world. ``` ![Chain Of 5 Command Blocks](/assets/images/commands/commandBlockChain/5.png) -Here, we are tracking alive players and creepers as examples, but you can track any entity you like and as many as you need. You may also alter the fake-player-names to your preference. Example: 'alivePlayers' to just 'players'. +Here, we are tracking alive players and creepers as examples, but you can track any entity you like and as many as you need. You may also alter the fake-player-names to your preference. Example: 'AlivePlayers' to just 'Players'. Similarly, we're running `/title` commands as examples: - a) when there are 4 or more players `4..` @@ -53,7 +59,7 @@ You can modify/expand these as well. Example: a `/kill` command instead of a `/t 1. **Command 1:** Sets the score to `0` for all fake-player-names in the`count` scoreboard objective, including that of any tracked players and entities. 2. **Command 2, 3:** From each target that you want to track the count of, a score will be added to their corresponding fake-player-name. Thus, obtaining their total count. - - Example: Creeper mobs to 'creepers' fake-player-name. + - Example: Creeper mobs to 'Creepers' fake-player-name. 3. **Command 4, 5:** These are example commands which can be modified / expanded. - Based on the total count obtained, we can use the `/execute if score` condition to run our desired commands when certain values are met. - **` n `** any number *n* @@ -69,7 +75,7 @@ If you are using functions instead of command blocks, the ` entity_counter ` fun ```json { "values": [ - "entity_counter" + "scoreboards/entity_counter" ] } ``` @@ -82,7 +88,8 @@ If using functions, your pack folder structure will be as follows: 'BP/functions', 'BP/pack_icon.png', 'BP/manifest.json', - 'BP/functions/entity_counter.mcfunction', + 'BP/functions/scoreboards', + 'BP/functions/scoreboards/entity_counter.mcfunction', 'BP/functions/tick.json' ]" > diff --git a/docs/commands/index.md b/docs/commands/index.md index 075266c2651..73b8e3a4ae0 100644 --- a/docs/commands/index.md +++ b/docs/commands/index.md @@ -11,4 +11,6 @@ categories: color: blue - title: Techniques color: orange + - title: Functions + color: blue --- diff --git a/docs/commands/logic-gates.md b/docs/commands/logic-gates.md index 13b299f9d3b..0726f4d2e4a 100644 --- a/docs/commands/logic-gates.md +++ b/docs/commands/logic-gates.md @@ -87,16 +87,16 @@ Here is a list of target selector arguments that can be used in the execute logi - `/execute unless entity @e [type=!chicken, type=!cow] run ` - Run the command if the entity is either a chicken or a cow. -- `/execute unless entity @p [scores={scoreA=!5, scoreB=!5}] run ` - - Run the command if the player has either a score of 5 in objective scoreA or scoreB. +- `/execute unless entity @p [scores={objective.a=!5, objective.b=!5}] run ` + - Run the command if the player has a score of 5 in either scoreboard `objective.a` or `objective.b`. - `/execute unless entity @p [hasitem=[{item=diamond_sword,quantity=0},{item=iron_sword,quantity=0}]] run ` - Run the command if the player has either a diamond sword or an iron sword. > Note: You may use more than two inputs (selector arguments) for the OR gate, and the command will execute if it meets any one or more of the inputs. Combining any of the different argument selectors will also work. Examples: -- `/execute unless entity @p[tag=!red, scores={score1=!1..5}] run ` -- `/execute unless entity @p[name=!player, hasitem=[{item=iron_sword, quantity=0}]] run ` -- `/execute unless entity @e[type=!chicken, tag=!green, scores={score1=!5}, family=!mob}] run ` +- `/execute unless entity @p [tag=!red, scores={objective.a=!1..5}] run ` +- `/execute unless entity @p [name=!player, hasitem=[{item=iron_sword, quantity=0}]] run ` +- `/execute unless entity @e [type=!chicken, tag=!green, scores={objective.b=!5}, family=!mob}] run ` For any doubts or queries, you may join our Discord linked above and any of our community experts will be glad to assist you. diff --git a/docs/commands/look-detection.md b/docs/commands/look-detection.md index f23bfda14c2..5a735e07bd5 100644 --- a/docs/commands/look-detection.md +++ b/docs/commands/look-detection.md @@ -19,7 +19,7 @@ This command-technique allows you to detect when a target looks at a player/enti ## Command -BP/functions/look_detector.mcfunction +BP/functions/states/player/is_looking_at.mcfunction ```yaml execute as at @s anchored eyes facing positioned ^^^1 positioned ~~-1.62~ rotated as @s positioned ^^^-1 if entity @s [r=0.2] run @@ -47,7 +47,8 @@ execute as at @s anchored eyes facing positioned - sets the execution rotation facing an entity or coordinate. Example: - `facing 0 0 0` facing coordinate: 0,0,0. - `facing entity @e [type=pig, c=1] eyes` (facing eyes of nearest pig) - - `facing entity @e [type=zombie, c=1] feet` (facing feet of nearest zombie) + - `facing entity @e [type=cow, r=30] feet` (facing eyes of cows in a 30 block radius) + - `facing entity @e [type=zombie] feet` (facing feet of zombies) - `positioned ^^^1` - from previous point, pushes the execution position 1 block forward in the direction of the entity/coordinate. - `positioned ~~-1.62~` @@ -65,34 +66,36 @@ execute as at @s anchored eyes facing positioned **Examples:** -1. Run a `/say` command when looking at the eyes of the nearest cow tagged 'target': +1. Run a `/say` command when looking at the eyes of cows or sheeps tagged 'target': -BP/functions/look_detector.mcfunction +BP/functions/states/player/is_looking_at/target.mcfunction ```yaml -execute as @a at @s anchored eyes facing entity @e [type=cow, tag=target, c=1] eyes positioned ~~-1.62~ positioned ^^^1 rotated as @s positioned ^^^-1 if entity @s [r=0.2] run say hello cow! +execute as @a at @s anchored eyes facing entity @e [type=cow, tag=target] eyes positioned ~~-1.62~ positioned ^^^1 rotated as @s positioned ^^^-1 if entity @s [r=0.2] run say hello cow! +execute as @a at @s anchored eyes facing entity @e [type=sheep, tag=target] eyes positioned ~~-1.62~ positioned ^^^1 rotated as @s positioned ^^^-1 if entity @s [r=0.2] run say hello sheep! ``` ![A Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) -2. Run a `/say` command when looking at the position 10,20,30: +2. Run a `/say` command when looking at the position `(10, 20, 30)` or `(6, 7, 8)`: -BP/functions/look_detector.mcfunction +BP/functions/states/player/is_looking_at/position.mcfunction ```yaml execute as @a at @s anchored eyes facing 10 20 30 positioned ~~-1.62~ positioned ^^^1 rotated as @s positioned ^^^-1 if entity @s [r=0.2] run say hello block! +execute as @a at @s anchored eyes facing 6 7 8 positioned ~~-1.62~ positioned ^^^1 rotated as @s positioned ^^^-1 if entity @s [r=0.2] run say hello block! ``` ![A Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) **Alternative Structure:** -BP/functions/look_detector.mcfunction +BP/functions/states/player/is_looking_at.mcfunction ```yaml execute as at facing entity @s eyes positioned as @s positioned ^^^1 rotated as @s positioned ^^^1 if entity @s[r=0.02] run ``` ![A Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) -If you don't need to detect the target looking at the *eyes* of an entity but their feet or a coordinate, you may use this structure which negates the need for the `anchored eyes` condition as the execution position begins from the entity/coordinate rather than the target. +If you don't need to detect the target looking at the *eyes* of an entity but their feet or a coordinate, you may use this structure which negates the need for the `anchored eyes` instruction as the execution position begins from the entity/coordinate rather than the target. ## Calculate Viewing Angle @@ -109,4 +112,3 @@ or, the inverse to calculate what viewing angle a certain radius / distance (`r` With the above calculation, the example value of `r=0.2` leaves us with roughly a 12° angle by which we can miss the exact target in either direction and still have it considered "close enough." - diff --git a/docs/commands/mcfunctions.md b/docs/commands/mcfunctions.md index 9f848ec50ec..3a69eb1577f 100644 --- a/docs/commands/mcfunctions.md +++ b/docs/commands/mcfunctions.md @@ -33,17 +33,59 @@ Functions are useful in many ways to reduce the time spent going from command bl ]" > +To help create a consistent format, make it easier for everyone to follow, and to maintain uniformity across your functions, it is advised to follow these best-practices for your folder structure: + +1. Folders and files in a pack must be named using `snake_case` + - This means only **lowercase** alphanumeric characters and underscores (` _ `) are allowed. + - ✅️ `BP/functions/scoreboards/objective/add_all.mcfunction` + - ❌️ `BP/functions/SCOREBOARDS/Objective/Add-all.mcfunction` +2. They must be properly nested: + - ✅️ `function teleport/zone/hell` + - ❌ `function teleport_hellzone` +3. The names must follow an `action_object` structure. Meaning verbs should come before subjects. + - ✅️ `add_all` + - ✅️ `shuffle_position` + - ❌️ `all_add` + - ❌️ `position_shuffle` +4. The total character length of any path must not exceed 80 characters (console limitation). +5. Content folders should use consistent pluralization: Stick with names that are either all plural or all singular, don't mix and match. Example: + +✅️ Consistent: +``` +BP/functions/abilities/ice_blast.mcfunction +BP/functions/events/player/on_death.mcfunction +BP/functions/events/world/on_initialise.mcfunction +BP/functions/quests/jungle/1.mcfunction +``` +- All content folders `abilities`, `events`, and `quests` are consistently pluralized. +- The content folders in `events` are also consistent, as both `player` and `world` are singular. + +❌️ Inconsistent: +``` +BP/functions/ability/ice_blast.mcfunction +BP/functions/event/players/on_death.mcfunction +BP/functions/event/world/on_initialise.mcfunction +BP/functions/quests/jungle/1.mcfunction +``` +- Only `quests` content folder is pluralized while `ability`, and `event` are singular. +- Also, in the `event` folder, the `players` folder is plural while `world` is singular. + ## Notes For Beginners +*Below is an example function file for beginners reference:* + BP/functions/effects.mcfunction ```yaml -#Spawn Effects +# These effects are for the spawn effect @a [tag=atSpawn] regeneration 12 255 true effect @a [tag=atSpawn] saturation 12 255 true effect @a [tag=atSpawn] weakness 12 255 true + +# These effects are for the nether +effect @a [tag=inNether] fire_resistance 12 255 true ``` -- Commands in a function may not begin with a slash `/`. Each new line in a function file represents a new command. You may start a line with `#` to add comments. +- Commands in a function may not begin with a slash (` / `). Each new line in a function file represents a new command (ignored if left blank). You may start a line with a hashtag ( ` # `) to add comments — the space after `#` is only a format preference. For comments style guide for functions, see the section **[below](#comments-style-guide)**. - All commands in a function are run in the *same tick*. Because of this, a function which causes large changes may cause a sudden lag spike and it is helpful to delegate some commands across multiple ticks, if possible. Commands in a function are still run in the same sequence, however. @@ -53,6 +95,55 @@ effect @a [tag=atSpawn] weakness 12 255 true - Running commands with a specified delay in a function involves using scoreboard timers to incrementally count up each tick until a certain point, and executing commands at specific scores within the file. See [Scoreboard Timers](/commands/scoreboard-timers) page to learn it's setup. +## Comments Style Guide + +- When working with functions that contain many commands, it's helpful to keep them organized by using multiple hashtags in comments to indicate different header levels. +- *Optionally*, to further distinguish these levels, you can apply different styles: + - level 1 headers - **# UPPERCASE** + - level 2 headers - **## Title Case** + - level 3 headers - **### Sentence Case** +- Try to avoid the use of more than three header levels or too many headers overall, as this can make the code look cluttered. For your reference, see the example file below: + + + + + +BP/functions/abilities/fire_trail.mcfunction + +```yaml +# ON PLAYER ITEM DROP + +## Give Effects +### Fire resistance +execute at @e [type=item, name="Fire Trail Ability"] run effect @p [r=3] fire_resistance 10 255 +### Speed +execute at @e [type=item, name="Fire Trail Ability"] run effect @p [r=3] speed 10 1 true + +## Add Particle Time (10s) +execute at @e [type=item, name="Fire Trail Ability"] run scoreboard players set @p [r=3] abilities.fire_trail 200 + +## Delete Item +kill @e [type=item, name="Fire Trail Ability"] + + +# ENTITY TIMER + +## Emit Particle Trail +execute at @a [scores={abilities.fire_trail=1..}] run particle minecraft:basic_flame_particle ~~~ + +## Countdown Timer +scoreboard players remove @a [scores={abilities.fire_trail=1..}] abilities.fire_trail 1 +``` + + + + +Note the use of two lines of spacing before level 1 headers and one line of spacing before level 2 headers for improved readability. + +This practice helps create a consistent format, making it easier for everyone to follow, and maintain uniformity across your functions. + +For Scoreboard and Tags style guide, see **[here](/meta/style-guide#scoreboard-and-tags)**. + ## Creating A Function 1. Locate the `📁 com.mojang` folder and navigate to `📁 development_behavior_packs` @@ -120,7 +211,7 @@ Functions can be executed in-game by typing `/function name_of_function`. This w Nested functions, for example `BP/functions/lobby/items/1.mcfunction` can be run using the nested folder path, in this case `/function lobby/items/1` -## tick.json +## Tick JSON The final file within a function is the **tick.json** file. This specifies functions to run server-side on every game tick, (similar to a repeating command block). It is located in the `BP/functions` folder. By default, functions running in this file execute at origin `0, 0, 0` in the overworld. diff --git a/docs/commands/movement-detections.md b/docs/commands/movement-detections.md index 28c75740bd8..33a7ebaf701 100644 --- a/docs/commands/movement-detections.md +++ b/docs/commands/movement-detections.md @@ -11,7 +11,7 @@ description: These command-techniques allow you to detect certain player/entity [Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) -[Image Credits: Official Minecraft Wiki - ](https://minecraft.wiki/)__[CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/)__ +[Image Credits: Unofficial Minecraft Wiki - ](https://minecraft.wiki/)__[CC BY-NC-SA 3.0](https://creativecommons.org/licenses/by-nc-sa/3.0/)__ These command-techniques allow you to detect certain player/entity 'states' and subsequently execute your desired commands. @@ -33,19 +33,22 @@ This technique allows you to detect when your target is/isn't moving, accounting - Make sure you add the `is_moving` scoreboard objective: - `/scoreboard objectives add is_moving dummy` -BP/functions/states/is_moving.mcfunction +BP/functions/states/player/is_moving.mcfunction ```yaml -#moving +## Movement Detection +### Mark as not moving execute as @a at @s positioned ~~10000~ if entity @e [type=leash_knot, r=0.1252] run scoreboard players set @s is_moving 0 +### Mark as moving execute as @a at @s positioned ~~10000~ unless entity @e [type=leash_knot, r=0.1252] run scoreboard players add @s is_moving 1 -#update point +## Update Point +### Delete previous point execute as @e [type=leash_knot] at @s unless entity @s [y=-80, dy=9974] run kill @s +### Mark current point execute at @a positioned ~~10000~ run summon leash_knot ~~~ - -#Your Commands Here (example) +## Your Commands Here (Examples) execute as @a [scores={is_moving=0}] run say I'm not moving execute as @a [scores={is_moving=1}] run say I started moving execute as @a [scores={is_moving=1..}] run say I'm still moving @@ -79,27 +82,34 @@ If you desperately need to detect walking and sprinting separately **solely usin Walk/Sprint Detection may not work as intended with effects & enchantments. ::: -BP/functions/states/is_moving.mcfunction +BP/functions/states/player/is_moving.mcfunction ```yaml -#moving +## Movement Detection +### Mark as not moving execute as @a at @s positioned ~~10000~ if entity @e [type=leash_knot, r=0.1252] run scoreboard players set @s is_moving 0 +### Mark as moving execute as @a at @s positioned ~~10000~ unless entity @e [type=leash_knot, r=0.1252] run scoreboard players add @s is_moving 1 -#walking +## Walk Detection +### Mark as not walking scoreboard players set @a is_walking 0 +### Mark as walking execute as @a at @s positioned ~~10000~ if entity @e [type=leash_knot, rm=0.21585, r=0.2805] run scoreboard players set @s is_walking 1 -#sprinting +## Sprint Detection +### Mark as not sprinting scoreboard players set @a is_sprinting 0 +### Mark as sprinting execute as @a at @s positioned ~~10000~ if entity @e [type=leash_knot, rm=0.2806, r=0.9] run scoreboard players set @s is_sprinting 1 -#update point +## Update Point +### Delete previous point execute as @e [type=leash_knot] at @s unless entity @s [y=-80, dy=9974] run kill @s +### Mark current point execute at @a positioned ~~10000~ run summon leash_knot ~~~ - -#Your Commands Here (example) +## Your Commands Here (Examples) execute as @a [scores={is_walking=0}] run say I'm not walking execute as @a [scores={is_walking=1}] run say I'm walking ``` @@ -138,14 +148,16 @@ Note: When sleeping, the player's hitbox is reduced to 0.2 blocks. - Make sure you add the `is_sleeping` scoreboard objective: - `/scoreboard objectives add is_sleeping dummy` -BP/functions/states/is_sleeping.mcfunction +BP/functions/states/player/is_sleeping.mcfunction ```yaml +## Sleep Detection +### Mark as not sleeping execute as @a at @s if entity @s [y=~0.3, dy=0] scoreboard players set @s is_sleeping 0 +### Mark as sleeping execute as @a at @s unless entity @s [y=~0.3, dy=0] run scoreboard players add @s is_sleeping 1 - -#Your Commands Here (example) +## Your Commands Here (Examples) execute as @a [scores={is_sleeping=0}] run say I'm not sleeping execute as @a [scores={is_sleeping=1}] run say I started sleeping execute as @a [scores={is_sleeping=1..}] run say I'm still sleeping @@ -180,14 +192,16 @@ Thanks to the introduction of Short Sneaking parity in 1.20.10 which reduces the - Make sure you add the `is_sneaking` scoreboard objective: - `/scoreboard objectives add is_sneaking dummy` -BP/functions/states/is_sneaking.mcfunction +BP/functions/states/player/is_sneaking.mcfunction ```yaml +## Sneak Detection +### Mark as not sneaking execute as @a at @s if entity @s [y=~1.5, dy=0] run scoreboard players set @s is_sneaking 0 +### Mark as sneaking execute as @a at @s unless entity @s [y=~1.5, dy=0] if entity @s [y=~0.7, dy=0] run scoreboard players add @s is_sneaking 1 - -#Your Commands Here (example) +## Your Commands Here (Examples) execute as @a [scores={is_sneaking=0}] run say I'm not sneaking execute as @a [scores={is_sneaking=1}] run say I started sneaking execute as @a [scores={is_sneaking=1..}] run say I'm still sneaking @@ -227,14 +241,16 @@ Swimming in water or gliding with Elytra will be detected as crawling. - Make sure you add the `is_crawling` scoreboard objective: - `/scoreboard objectives add is_crawling dummy` -BP/functions/states/is_crawling.mcfunction +BP/functions/states/player/is_crawling.mcfunction ```yaml +## Crawl Detection +### Mark as not crawling execute as @a at @s if entity @s [y=~0.7, dy=0] run scoreboard players set @s is_crawling 0 +### Mark as crawling execute as @a at @s unless entity @s [y=~0.7, dy=0] if entity @s [y=~0.3, dy=0] run scoreboard players add @s is_crawling 1 - -#Your Commands Here (example) +## Your Commands Here (Examples) execute as @a [scores={is_crawling=0}] run say I'm not crawling execute as @a [scores={is_crawling=1}] run say I started crawling execute as @a [scores={is_sneaking=1..}] run say I'm still crawling @@ -269,19 +285,26 @@ If you desperately need to detect all three states separately **solely using com - ![issue3](/assets/images/commands/movement-detections/issue3.png) ::: -BP/functions/states/is_crawling.mcfunction +BP/functions/states/player/is_crawling.mcfunction ```yaml +## Set Player States +### Not gliding execute as @a at @s if entity @s [y=~0.7, dy=0] run scoreboard players set @s is_gliding 0 +### Not crawling execute as @a at @s if entity @s [y=~0.7, dy=0] run scoreboard players set @s is_crawling 0 +### Not swimming execute as @a at @s if entity @s [y=~0.7, dy=0] run scoreboard players set @s is_swimming 0 +## Detect Player States +### Gliding execute as @a [hasitem={item=elytra,location=slot.armor.chest}] at @s unless entity @s [y=~0.7, dy=0] if entity @s [y=~0.3, dy=0] if block ~~1.01~ air if block ~~-0.01~ air rotated ~ 0 if block ^^1.01^-1 air if block ^^-0.01^-1 air if block ^^1.01^1 air if block ^^-0.01^1 air run scoreboard players add @s is_gliding 1 +### Crawling execute as @a [scores={is_gliding=0}] at @s unless entity @s [y=~0.7, dy=0] if entity @s [y=~0.3, dy=0] unless block ~~~ water unless block ~~1.01~ water run scoreboard players add @s is_crawling 1 +### Swimming execute as @a [scores={is_gliding=0,is_crawling=0}] at @s unless entity @s [y=~0.7, dy=0] if entity @s [y=~0.3, dy=0] run scoreboard players add @s is_swimming 1 - -#Your Commands Here (example) +## Your Commands Here (Examples) execute as @a [scores={is_swimming=0}] run say I'm not swimming execute as @a [scores={is_crawling=1}] run say I started crawling execute as @a [scores={is_gliding=1..}] run say I'm still gliding @@ -298,4 +321,21 @@ execute as @a [scores={is_gliding=1..}] run say I'm still gliding - **Command 6:** If the player's hitbox is *not* higher than 0.6 blocks, is not gliding or crawling, we mark them as swimming (1) by adding a score. - **Command 7, 8, 9:** These are example commands (for each state) which can be modified / expanded. - +## Folder Structure + +If you are working with functions, your folder structure may look something like this: + + diff --git a/docs/commands/new-execute.md b/docs/commands/new-execute.md index cd53471af77..47647206ebf 100644 --- a/docs/commands/new-execute.md +++ b/docs/commands/new-execute.md @@ -9,7 +9,7 @@ mentions: - Hatchibombotar - TheItsNameless - SmokeyStack -description: Learn new /execute command. +description: /execute command explained. --- ## Introduction @@ -43,9 +43,9 @@ Back in the Summer of 2017 during the Update Aquatic's development, the develope This allows for much greater control for what `/execute` can do to a command, and allows splitting up the executor and the command's position. -## New Syntax +## Syntax -Now, let us review the new `/execute` syntax. They are as follows: +Now, let us review the `/execute` syntax. They are as follows: ### `/execute as` @@ -81,7 +81,13 @@ Sets the dimension in which the command should run. Currently accepted values are `overworld`, `nether`, and `the_end`. -This change in dimension will respect that dimension's scale; going from the Overworld to The Nether will apply a scale of x0.125 to the position, and vice versa will apply a x8 scale to the position. +For example, to execute as a target if in The End, run: + +``` +/execute in the_end positioned 0 -100 0 as @a [rm=1] run say I'm in the End dimension +``` + +Note: Change in dimension will respect that dimension's scale; going from the Overworld to The Nether will apply a scale of x0.125 to the position, and vice versa will apply a x8 scale to the position. ### `/execute positioned` @@ -229,18 +235,18 @@ The old functionality of `/execute` can be replicated with `as at @s`. 1. Teleport with an offset. ```yaml -#Old syntax +# Old syntax: /execute @p ~ ~1.62 ~ teleport @s ^ ^ ^3 -#New Syntax +# New syntax: /execute as @p at @s positioned ~ ~1.62 ~ run teleport @s ^ ^ ^3 ``` 2. Chaining multiple executes. ```yaml -#Old syntax +# Old syntax: /execute @e[type=sheep] ~ ~ ~ execute @e[type=item,r=5] ~ ~ ~ detect ~ ~-1 ~ stone kill @s -#New syntax +# New syntax: /execute at @e[type=sheep] as @e[type=item,r=5] at @s if block ~ ~-1 ~ stone run kill @s ``` @@ -249,13 +255,13 @@ The old functionality of `/execute` can be replicated with `as at @s`. Now for some examples of things that were not possible to do in one command, or were more difficult to perform before the new syntax was introduced. ```yaml -#Testing a fake player's score +# Testing a fake-player-name's score: /execute if score game_settings var matches 3.. run say [Game] Difficulty set to Hard. -#Comparing if two scores are equal +# Comparing if two scores are equal: /execute as @a if score @s x = @s y run say My X is equal to my Y. -#Test for an entity without targeting it +# Test for an entity without targeting it: /execute as @a at @s if entity @e[type=armor_stand,r=10] run gamemode survival @s ``` diff --git a/docs/commands/on-first-join.md b/docs/commands/on-first-join.md index b6f80628a16..57b8559225a 100644 --- a/docs/commands/on-first-join.md +++ b/docs/commands/on-first-join.md @@ -16,14 +16,16 @@ description: This system will run your desired commands on the event that a play This system will run your desired commands on the event that a player joins the world for the first time. ## System -BP/functions/events/on_player_first_join.mcfunction +BP/functions/events/player/on_first_join.mcfunction ```yaml -#Your Commands Here (examples) +## Your Commands Here (Examples) +### Give stone pickaxe ×1 give @a [tag=!joined] stone_pickaxe -give @a [tag=!joined] bread 16 1 - +### Give bread ×16 +give @a [tag=!joined] bread 16 +## Mark as Joined tag @a [tag=!joined] add joined ``` @@ -49,7 +51,7 @@ If you are using functions instead of command blocks, the ` on_first_join ` func ```json { "values": [ - "on_player_first_join" + "events/player/on_first_join" ] } ``` @@ -63,7 +65,8 @@ If using functions, your pack folder structure will be as follows: 'BP/pack_icon.png', 'BP/manifest.json', 'BP/functions/events', - 'BP/functions/events/on_player_first_join.mcfunction', + 'BP/functions/events/player', + 'BP/functions/events/player/on_first_join.mcfunction', 'BP/functions/tick.json' ]" > @@ -72,6 +75,6 @@ If using functions, your pack folder structure will be as follows: The tag names (in this case: 'joined') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: - ` joined_0fe678 ` -- ` on_player_first_join_0fe678.mcfunction ` +- ` on_first_join_0fe678.mcfunction ` ::: diff --git a/docs/commands/on-first-world-load.md b/docs/commands/on-first-world-load.md index dc79a602e77..abd9ec80452 100644 --- a/docs/commands/on-first-world-load.md +++ b/docs/commands/on-first-world-load.md @@ -7,14 +7,14 @@ mentions: - SmokeyStack - cda94581 nav_order: 6 -description: This system will run your desired commands on the event that the world is loaded for the first time. +description: This system will run your desired commands on the event that the world is loaded for the first time after applying your pack. --- ## Introduction [Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) -This system will run your desired commands on the event that the world is loaded for the first time. +This system will run your desired commands on the event that the world is loaded for the first time after applying your pack. > Note: A [Function](/commands/mcfunctions) Pack is required to achieve this system, since it is the `tick.json` file which allows us to run commands as soon as the world is initialised. @@ -24,23 +24,25 @@ This system will run your desired commands on the event that the world is loaded ```json { "values": [ - "on_world_initialise" + "events/world/on_initialise" ] } ``` ## System -BP/functions/events/on_world_initialise.mcfunction +BP/functions/events/world/on_initialise.mcfunction ```yaml +## Initialisation +### Add objective scoreboard objectives add world dummy +### Register to objective scoreboard players add initialised world 0 - -#Your Commands Here (example) +## Your Commands Here (Example) execute if score initialised world matches 0 run say New world created! - +## Mark as Initialised scoreboard players set initialised world 1 ``` @@ -50,14 +52,14 @@ Just make sure to follow the given order and properly apply the `/execute if sco ## Explanation -- **` initialised=0 `** world has just initialised and we are yet to run the initlisation commands we want. +- **` initialised=0 `** world has just initialised and we are yet to run the initialisation commands we need. - **` initialised=1 `** world has been initialised and we have executed the initialisation commands. An objective of the name `world` is added for us to save scores to it so that we can track whether the world has been initialised or not. This also allows us to structure our commands to only execute at world initialisation. -Following the creation of the objective, a score of `0` is added to the fake-player-name 'initialised'. This will add it to the objective and enable us to use the `/execute if score` condition to run our desired commands. +Following the creation of the objective, a score of `0` is added to the fake-player-name 'initialised'. This will register it to the objective and enable us to use the `/execute if score` condition to run our desired commands. -Finally, the score for fake-player-name 'initialised' is set to `1` after all the commands are executed. This is to prevent it from executing more than once. +Finally, the score for fake-player-name 'initialised' is set to `1` after all the commands are executed. This is to prevent it from entering a loop and executing more than once. ## Folder Structure @@ -68,7 +70,8 @@ Finally, the score for fake-player-name 'initialised' is set to `1` after all th 'BP/pack_icon.png', 'BP/manifest.json', 'BP/functions/events', - 'BP/functions/events/on_world_initialise.mcfunction', + 'BP/functions/events/world', + 'BP/functions/events/world/on_initialise.mcfunction', 'BP/functions/tick.json' ]" > @@ -77,6 +80,6 @@ Finally, the score for fake-player-name 'initialised' is set to `1` after all th The scoreboard names (in this case: 'world') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: - ` world_0fe678 ` -- ` on_world_initialise_0fe678.mcfunction ` +- ` on_initialise_0fe678.mcfunction ` ::: diff --git a/docs/commands/on-player-death.md b/docs/commands/on-player-death.md index 4e8b3f94bb9..5123d7f6b63 100644 --- a/docs/commands/on-player-death.md +++ b/docs/commands/on-player-death.md @@ -24,17 +24,19 @@ If you are working with functions and prefer to have the objective added automat ## System -BP/functions/events/on_player_death.mcfunction +BP/functions/events/player/on_death.mcfunction ```yaml +## Set Player States +### Not alive scoreboard players set @a [scores={is_alive=!2}] is_alive 0 +### Alive scoreboard players set @e [type=player] is_alive 1 - -#Your Commands Here (example) +## Your Commands Here (Example) execute as @a [scores={is_alive=0}] run say I died - +## Mark that Commands for Dead Players Have Been Executed scoreboard players set @a [scores={is_alive=0}] is_alive 2 ``` @@ -62,13 +64,13 @@ Just make sure to follow the given order and properly apply the ` scores={alive= ## Tick JSON -If you are using functions instead of command blocks, the ` on_player_death ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. +If you are using functions instead of command blocks, the ` on_death ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. BP/functions/tick.json ```json { "values": [ - "on_player_death" + "events/player/on_death" ] } ``` @@ -82,7 +84,8 @@ If using functions, your pack folder structure will be as follows: 'BP/pack_icon.png', 'BP/manifest.json', 'BP/functions/events', - 'BP/functions/events/on_player_death.mcfunction', + 'BP/functions/events/player', + 'BP/functions/events/player/on_death.mcfunction', 'BP/functions/tick.json' ]" > @@ -91,7 +94,7 @@ If using functions, your pack folder structure will be as follows: The scoreboard names (in this case: 'is_alive') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: - ` is_alive_0fe678 ` -- ` on_player_death_0fe678.mcfunction ` +- ` on_death_0fe678.mcfunction ` ::: @@ -109,12 +112,16 @@ If two or more players are teleported to the same point and one of them dies but BP/functions/states/is_dead.mcfunction ```yaml +## Set Player States +### Not dead scoreboard players set @e [type=player] is_dead 0 +### Dead execute as @a at @s unless entity @e [type=player, r=0.01] run scoreboard players add @s is_dead 1 - -#Your Commands Here (example) +## Your Commands Here (examples) +### Summon armor stand at death position execute as @a [scores={is_dead=1}] at @s run summon armor_stand "Dead Player" ~~~ +### Death message in chat execute as @a [scores={is_dead=1..}] run say I died and haven't respawned yet.. ``` ![commandBlockChain4](/assets/images/commands/commandBlockChain/4.png) diff --git a/docs/commands/on-player-join.md b/docs/commands/on-player-join.md index d55ff422ac7..58518d235c6 100644 --- a/docs/commands/on-player-join.md +++ b/docs/commands/on-player-join.md @@ -24,23 +24,24 @@ If you are working with functions and prefer to have the objective added automat ## System -BP/functions/events/on_player_join.mcfunction +BP/functions/events/player/on_join.mcfunction ```yaml +## Register Players to 'joined' Objective Who Joined For First Time or Were Cleared From 'joined' Previously scoreboard players add @a joined 0 +## Your Commands Here (Example) +tp @a [scores={joined=0}] 0 65 0 -#Your Commands Here (example) -tp @a[scores={joined=0}] 0 65 0 - - +### Mark Players as Joined +### Clear 'joined' score of online and offline players scoreboard players reset * joined +### Set online players score to 1 scoreboard players set @a joined 1 ``` ![Chain Of 4 Command Blocks](/assets/images/commands/commandBlockChain/4.png) - Here, we have used a `/tp` command as an example, but you can use any command you prefer and as many as you need. Just make sure to follow the given order and properly apply the ` scores={joined=0} ` selector argument as shown for your desired commands. @@ -54,15 +55,17 @@ Immediately after the commands are run, we reset all the scores on the objective This way, since our commands only target players with a score of `0`, the commands won't repeat for the players who stayed, unless they leave and rejoin or if we run:
`/scoreboard players set joined 0` +This is because *adding* a score of 0 to a score of 1 will have no change. But adding a score of 0 to players with no score will set their score to 0. + ## Tick JSON -If you are using functions instead of command blocks, the ` on_player_join ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. +If you are using functions instead of command blocks, the ` on_join ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. BP/functions/tick.json ```json { "values": [ - "on_player_join" + "events/player/on_join" ] } ``` @@ -76,7 +79,8 @@ If using functions, your pack folder structure will be as follows: 'BP/pack_icon.png', 'BP/manifest.json', 'BP/functions/events', - 'BP/functions/events/on_player_join.mcfunction', + 'BP/functions/events/player', + 'BP/functions/events/player/on_join.mcfunction', 'BP/functions/tick.json' ]" > @@ -85,6 +89,6 @@ If using functions, your pack folder structure will be as follows: The scoreboard names (in this case: 'joined') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: - ` joined_0fe678 ` -- ` on_player_join_0fe678.mcfunction ` +- ` on_join_0fe678.mcfunction ` ::: diff --git a/docs/commands/on-player-leave.md b/docs/commands/on-player-leave.md index 9c044d60320..24359c42c59 100644 --- a/docs/commands/on-player-leave.md +++ b/docs/commands/on-player-leave.md @@ -26,19 +26,26 @@ If you are working with functions and prefer to have the objective added automat ## System -BP/functions/events/on_player_leave.mcfunction +BP/functions/events/player/on_leave.mcfunction ```yaml -scoreboard players reset newPlayerCount total -execute as @a run scoreboard players add newPlayerCount total 1 -scoreboard players operation newPlayerCount total -= playerCount total +## Entity Counter +### Reset current player count +scoreboard players reset NewPlayerCount total +### Get current player count +execute as @a run scoreboard players add NewPlayerCount total 1 +## Get Difference ( Current - Previous ) +scoreboard players operation newPlayerCount total -= playerCount total -#Your Commands Here (example) +## Your Commands Here (Example) +### Message if there is a difference of -1 or less execute if score newPlayerCount total matches ..-1 run say a player has left the world - +## Entity Counter +### Reset current player count scoreboard players reset playerCount total +### Get current player count (to check difference next game tick) execute as @a run scoreboard players add playerCount total 1 ``` @@ -50,24 +57,26 @@ Just make sure to follow the given order and properly apply the `/execute if sco ## Explanation -- **` newPlayerCount `** this fake-player-name means the total number of players on the world in the current game-tick. -- **` playerCount `** this fake-player-name means the total number of players that were on the world in the previous game-tick, but also saves the total count to be used in the *next* game-tick. +- **` NewPlayerCount `** total number of players on the world in the current game-tick (at start of command loop). +- **` PlayerCount `** total number of players on the world in the current game-tick (by the end of command loop). + +Since `PlayerCount` is only updated at the end of the command loop, it can be used at the start of the command loop in the next game-tick to check difference with `NewPlayerCount`. -The count is obtained using the [Entity Counter](/commands/entity-counter) system. It may be beneficial to refer to that page to better understand this one. +The count is obtained using the [Entity Counter](/commands/entity-counter) system. It may be beneficial to refer to that page to better understand this one. When referring to that page, you will notice that we have used the objective name `total` instead of `count`. This is to prevent collision between the two systems. -By subtracting 'playerCount' total from 'newPlayerCount' total, we will be able to identify if the player count has: +By subtracting 'PlayerCount' total from 'NewPlayerCount' total, we will be able to identify if the player count has: - decreased ` ..-1 ` - increased ` 1.. ` - or if it's unchanged ` 0 ` If it has decreased, we know that 1 or more players have left the game. Using this knowledge, we can run our desired commands from 'newPlayerCount' if it's score is `-1` or less. -- ie, if there were 10 players and someone leaves: - - that is ` newPlayerCount - playerCount ` +- i.e., if there were 10 players and someone leaves: + - that is ` NewPlayerCount - PlayerCount ` - which results ` 9 - 10 = -1 ` - hence, we will detect by ` ..-1 ` -- The 'newPlayerCount' total is obtained first, subtraction is performed after that to run your desired commands, and lastly, the 'playerCount' total is obtained to be used in the next game-tick. +- The 'NewPlayerCount' total is obtained first, subtraction is performed after that to run your desired commands, and lastly, the 'PlayerCount' total is obtained to be used in the next game-tick. :::tip All commands involved in a command-block-chain or function will only run in a sequence one after the other but it all still happens in the same tick regardless of the number of commands involved. We are able to achieve this system due to the fact that commands run along the end of a game tick after all events such as player log in, log out, death, etc.. occur. @@ -77,13 +86,13 @@ All commands involved in a command-block-chain or function will only run in a se ## Tick JSON -If you are using functions instead of command blocks, the ` on_player_leave ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. +If you are using functions instead of command blocks, the ` on_leave ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. BP/functions/tick.json ```json { "values": [ - "on_player_leave" + "events/player/on_leave" ] } ``` @@ -97,7 +106,8 @@ If using functions, your pack folder structure will be as follows: 'BP/pack_icon.png', 'BP/manifest.json', 'BP/functions/events', - 'BP/functions/events/on_player_leave.mcfunction', + 'BP/functions/events/player', + 'BP/functions/events/player/on_leave.mcfunction', 'BP/functions/tick.json' ]" > @@ -106,6 +116,6 @@ If using functions, your pack folder structure will be as follows: The scoreboard names (in this case: 'total') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: - ` total_0fe678 ` -- ` on_player_leave_0fe678.mcfunction ` +- ` on_leave_0fe678.mcfunction ` ::: diff --git a/docs/commands/on-player-respawn.md b/docs/commands/on-player-respawn.md index 1c15e06f31c..91dbf12aa86 100644 --- a/docs/commands/on-player-respawn.md +++ b/docs/commands/on-player-respawn.md @@ -24,14 +24,16 @@ If you are working with functions and prefer to have the objective added automat ## System -BP/functions/events/on_player_respawn.mcfunction +BP/functions/events/player/on_respawn.mcfunction ```yaml -#Your Commands Here (example) +## Your Commands Here (Example) execute as @e [scores={respawn=1}] run say I died and respawned. - +## Set Player States +### Currently respawning scoreboard players set @a respawn 1 +### Currently not respawning scoreboard players set @e [type=player] respawn 0 ``` ![Chain of 3 Command Blocks](/assets/images/commands/commandBlockChain/3.png) @@ -43,12 +45,12 @@ Just make sure to follow the given order and properly apply the ` @e [scores={re ## Explanation -- **` respawn=0 `** player is alive / had already respawned. -- **` respawn=1 `** player is dead / just respawned in the current game-tick. +- **` respawn=0 `** player is alive or had already respawned. +- **` respawn=1 `** player is dead or has just respawned (in the current game-tick). - **` @a `** selector will target all players alive/dead. Hence, we will use it to mark players as `1` 'respawning' - **` @e `** selector on the other hand will only target players who are alive, so we can use this to mark all alive players 0 'respawned' -Now that *respawning* players are `1` and *respawned* players are `0`, we can use this knowledge to run our desired commands when the players with score `1` respawn from death state (can be targeted with `@e` selector). +Now that *respawning* players are `1` and *respawned* players are `0`, we can use this knowledge to run our desired commands when the players with score `1` respawn from death state. They are targeted with `@e` selector. In the system, your desired commands must come before the other 2 commands because players change from death state to alive state along the start of the game-tick, before commands are run. @@ -56,13 +58,13 @@ Hence, if we were to put them at the end, the other 2 commands would set respawn ## Tick JSON -If you are using functions instead of command blocks, the ` on_player_respawn ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. +If you are using functions instead of command blocks, the ` on_respawn ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. BP/functions/tick.json ```json { "values": [ - "on_player_respawn" + "events/player/on_respawn" ] } ``` @@ -76,7 +78,8 @@ If using functions, your pack folder structure will be as follows: 'BP/pack_icon.png', 'BP/manifest.json', 'BP/functions/events', - 'BP/functions/events/on_player_respawn.mcfunction', + 'BP/functions/events/player', + 'BP/functions/events/player/on_respawn.mcfunction', 'BP/functions/tick.json' ]" > @@ -85,6 +88,6 @@ If using functions, your pack folder structure will be as follows: The scoreboard names (in this case: 'respawn') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: - ` respawn_0fe678 ` -- ` on_player_respawn_0fe678.mcfunction ` +- ` on_respawn_0fe678.mcfunction ` ::: diff --git a/docs/commands/orbital-camera.md b/docs/commands/orbital-camera.md index ffc212ea3ee..22d6cfb808d 100644 --- a/docs/commands/orbital-camera.md +++ b/docs/commands/orbital-camera.md @@ -21,12 +21,12 @@ This technique allows you to confine your camera rotations to an orbit around th ## Command -BP/functions/orbital_camera.mcfunction +BP/functions/cameras/orbital.mcfunction ```yaml execute as @p at @s anchored eyes rotated ~ 0 positioned ^^1^-2 run camera @s set minecraft:free ease 0.1 linear pos ~~~ facing @s ``` -![commandBlockChain1](/assets/images/commands/commandBlockChain/1.png) +![One Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) **2D Visualisation:** @@ -63,18 +63,18 @@ execute as @p at @s anchored eyes rotated ~ 0 positioned ^^1^-2 run camera @s se **Similar Examples:** -BP/functions/orbital_camera.mcfunction +BP/functions/cameras/orbital.mcfunction ```yaml -#To orbit camera around entity tagged with 'orbit_center' +# To orbit camera around entity tagged with 'orbit_center' execute as @p at @e [tag=orbit_center] anchored eyes rotated as @s rotated ~ 0 positioned ^^1^-5 run camera @s set minecraft:free ease 0.1 linear pos ~~~ facing @e [tag=orbit_center] ``` -![A Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) +![One Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) -BP/functions/orbital_camera.mcfunction +BP/functions/cameras/orbital.mcfunction ```yaml -#To orbit camera around position 6 7 8 +# To orbit camera around position 6 7 8 execute as @p positioned 6 7 8 rotated as @s rotated ~ 0 positioned ^^1^-5 run camera @s set minecraft:free ease 0.1 linear pos ~~~ facing 6 7 8 ``` -![A Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) +![One Repeating Command Block](/assets/images/commands/commandBlockChain/1.png) diff --git a/docs/commands/playsound.md b/docs/commands/playsound.md index fb0d603c1ec..95e68b6548d 100644 --- a/docs/commands/playsound.md +++ b/docs/commands/playsound.md @@ -64,10 +64,10 @@ You can use the `/playsound` command to play sound effects to players present an ## Examples ```yaml -#Play a random explosion sound effect to closest player. +# Play a random explosion sound effect to closest player /playsound random.explode @p -#Play a random orb sound effect to all players at their position with a volume of 10000 +# Play a random orb sound effect to all players at their position with a volume of 10000 /execute as @a at @s playsound random.orb @s ~ ~ ~ 10000 ``` @@ -76,4 +76,3 @@ Note: Since the `/playsound` command is positonal, it is helpful to play the sou **(Recommended) Read Next: [Sounds](/concepts/sounds)** - diff --git a/docs/commands/rearrange-positions.md b/docs/commands/rearrange-positions.md new file mode 100644 index 00000000000..4eaa234f108 --- /dev/null +++ b/docs/commands/rearrange-positions.md @@ -0,0 +1,221 @@ +--- +title: Multiplayer Position Rearrangement +category: Functions +mention: + - BedrockCommands + - zheaEvyline + - jeanmajid +description: Randomly relocate all selected targets among each other, ensuring none remain in their original position. +--- + +## Introduction + +[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) + +Multiplayer Position Rearrangement function, or more accurately Multiplayer Position Derangement function, created by @ZheaEvyline, allows you to randomly relocate all selected targets among each other, ensuring no target remains in its original position. + +A derangement is a permutation of 'N' elements where no element appears in its original position. + +For example, if Player1 was at `(0, 0, 1)`, Player2 at `(0, 0, 2)`, and Player3 at `(0, 0, 3)`, Player1 can only be relocated to `(0, 0, 2)`, or `(0, 0, 3)`. The same rule applies to all other players. + +
+ +**Key Features of this Function Pack:** + +1. Guaranteed derangement in a single game-tick. +2. Minimal number of iterations (repetitions/loops). + +To derange the positions of 100 targets, this function pack requires only 4-6 iterations, executing a total of 7 commands for the initiation, and 7 per iteration. + +
+ +The number of iterations increases proportionally with the number of elements. + +For reference, here is the number of derangements possible for elements ranging from 1 to 10: + +| Number of Elements (N) | Number of Derangements Possible (D(N)) | +|------------------------|------------------------------| +| 1 | 0 | +| 2 | 1 | +| 3 | 2 | +| 4 | 9 | +| 5 | 44 | +| 6 | 265 | +| 7 | 1,854 | +| 8 | 14,833 | +| 9 | 133,496 | +| 10 | 1,334,961 | + +The number of derangement possibilities increases rapidly as the number of elements grows. + +## Steps Involved in This Method + +1. Relocate each target to the position of a random one (other than its original position). +2. If multiple targets are relocated to the same position, assign it to one of them and repeat the process for the remaining targets. +3. If final target is left with no available position except its original, relocate the target in it's current position to it's original position, assigning the now freed position to the final target. + +**Example Visualization:** + +![Position of Five Players Being Deranged](/assets/images/commands/rearrange-positions/MPDVisualRep.gif) + +## Functions + +An ID system is required to index the position of all targets from 1 to N, allowing us to track the original position of each target. We will run this file in the `tick.json` to automatically assign the IDs. + +BP/functions/scoreboards/player/id.mcfunction + +```yaml +## Register New Players to the ID Objective +scoreboard players add @e [name="Fake Player"] id 0 + +## Create New ID +execute if entity @e [name="Fake Player", scores={id=0}] run scoreboard players add Total id 1 + +## Assign the New ID +scoreboard players operation @r [type=armor_stand, name="Fake Player", scores={id=0}] id = Total id +``` + +
+ +This is the function you run (once) each time you need to derange the positions of all targets: + +- `/function events/player/derange_position/initiate` + +BP/functions/events/player/derange_position/initiate.mcfunction + +```yaml +## Summon Position Marker +execute at @a run summon armor_stand "Position Marker" ~~~ + +## Save Original Position to Ignore +execute as @a at @s run scoreboard players operation @e [type=armor_stand, name="Position Marker", r=0.01, c=1] id = @s id + +## Initiate Position Derangement Process +function events/player/derange_position/process + +## Run Process One Last Time if Final Player Has a Valid Position Available +execute if score NonAllocatedPlayers count matches 1 unless score @a [tag=!posAllocated, c=1] id = @e [type=armor_stand, name="Position Marker", c=1] id run function events/player/derange_position/process + +## Resolve Collision if Final Player Has No Valid Position Available +### Relocate the allocated player to their colliding player's original position to free their position for the colliding player +execute as @a [tag=!posAllocated] at @s run tp @r [tag=posAllocated, r=0.01] @e [type=armor_stand, name="Position Marker", c=1] +### Remove colliding player's position marker and tag +kill @e [type=armor_stand, name="Position Marker"] +tag @a remove posAllocated +``` + +In case a single target is left with no available position except its original, the final 3 commands will resolve the collision. We call it a collision because when this occurs, the target will be at the allocated position of another target. + +
+ +The actual randomized derangement process will be performed by this function below: + +BP/functions/events/player/derange_position/process.mcfunction + +```yaml +## Move to a Different Position +execute as @a [tag=!posAllocated] at @s run tp @s @r [type=armor_stand, name="Position Marker", rm=0.01] + +## Move Again if Returned to Original Position +execute as @a [tag=!posAllocated] at @s if score @s id = @e [type=armor_stand, name="Position Marker", r=0.01, c=1] id run tp @s @r [type=armor_stand, name="Position Marker", rm=0.01] + +## Add Tag to Ignore Players with a Position Allocated +execute as @e [type=armor_stand, name="Position Marker"] at @s run tag @a [tag=!posAllocated, r=0.01, c=1] add posAllocated + +## Remove Allocated Position Markers +execute as @a [tag=posAllocated] at @s run kill @e [type=armor_stand, name="Position Marker", r=0.01, c=1] + + +# ENTITY COUNTER + +## Get Player Count of Players Without a Position Allocated +scoreboard players set * count 0 +execute as @a [tag=!posAllocated] run scoreboard players add NonAllocatedPlayers count 1 + +## Loop Function if 2+ Players Are Not Allocated a Position +execute if score NonAllocatedPlayers count matches 2.. run function events/player/derange_position/process +``` + +
+ +Now, for our functions to actually work, we will need to add the following objectives on our world: + +BP/functions/scoreboards/objective/add_all.mcfunction + +```yaml +scoreboard objectives add id dummy +scoreboard objectives add count dummy +``` + +
+ +If you wish to add the objectives automatically as soon as you load the world, you may create the function file below: + +BP/functions/events/world/on_initialise.mcfunction + +```yaml +## Initialisation +### Add objective +scoreboard objectives add world dummy +### Register to objective +scoreboard players add initialised world 0 + +## Commands to Execute +execute if score initialised world matches 0 run function scoreboards/objective/add_all + +## Mark as Initialised +scoreboard players set initialised world 1 +``` + +## Tick JSON + +Finally, create your `tick.json` file: + +BP/functions/tick.json + +```json +{ + "values": [ + "events/world/on_initialise", + "scoreboards/player/id" + ] +} +``` + +## Folder Structure + + + +## Download Function Pack + +For convenience, you can download the `.mcpack` for the Function Pack here: + + + + + +Simply activate the pack on your world and run once (each time you need) the following command in multiplayer: + +```yaml +/function events/player/derange_position/initiate +``` diff --git a/docs/commands/scoreboard-timers.md b/docs/commands/scoreboard-timers.md index d4f5f134fa4..70b0d0797b2 100644 --- a/docs/commands/scoreboard-timers.md +++ b/docs/commands/scoreboard-timers.md @@ -5,27 +5,29 @@ mentions: - BedrockCommands - zheaEvyline nav_order: 5 -description: Create timers using scoreboards. +description: Create world timers or entity timers using scoreboards. --- ## Introduction [Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) -This system allows you to run your desired commands at specific intervals with any amount of delay that you wish to add. +This system allows you to run your desired commands at precise intervals, allowing for customizable delays as per your requirements. -- **Some Examples:** - - Sending a message in chat every 2 hours. - - Running a 'lag clear' function every 10 minutes. - - Effecting players with 'speed' every 30 seconds. +**Some Examples:** -This system is especially useful when you need to set up multiple timers on your world. When working with command blocks, you may use the [Tick Delay](/commands/intro-to-command-blocks#command-block-tick-delay) option to delay the time taken for your commands to run. However, when working with functions, you will need to use a system like this. +- Sending a message in chat every 2 hours. +- Running a 'lag clear' function every 10 minutes. +- Effecting players with 'speed' every 30 seconds. -It is recommended to use this system while working with command blocks, as well if you wish to run all your world-timers in sync with one another, ie. with the same start time. +This system is particularly useful for managing multiple timers in your world. When working with command blocks, you may use the [Tick Delay](/commands/intro-to-command-blocks#command-block-tick-delay) option to delay the time taken for your commands to run. However, when working with functions, you will need to use a system like this. + +It is recommended to use this system while working with command blocks, as well if you wish to run all your world-timers in sync with one another, i.e., with the same start time. ## Setup *To be typed in chat:* + ```yaml @@ -33,7 +35,7 @@ It is recommended to use this system while working with command blocks, as well /scoreboard objectives add events dummy ``` -Once you have created these two objectives, you will need to define the interval for each repeating event you need on your world in the `ticks` objective. +After creating these objectives, the next step is to define the interval for each repeating event using the `ticks` objective. To do that, first, you must know that 1 second is approximately 20 game-ticks in Minecraft. Based on this knowledge, you will need to do some basic calculations to obtain the equivalent ticks for each interval you want to define. @@ -49,28 +51,30 @@ To do that, first, you must know that 1 second is approximately 20 game-ticks in # 30s = 20(t) × 30(s) = 600t /scoreboard players set 30s ticks 600 ``` -We will now use this scoreboard data to make our timers function. +With the scoreboard data set, we can now operate our timers based on the intervals defined. ## System -BP/functions/world_timer.mcfunction +BP/functions/scoreboards/world_timer.mcfunction ```yaml -# World Timer/Clock -scoreboard players add timer ticks 1 -scoreboard players operation * events = timer ticks - -# Chat Message (every 2h) -scoreboard players operation chatMessage events %= 2h ticks -execute if score chatMessage events matches 0 run say Technoblade never dies! - -# Lag Clear (every 10m) -scoreboard players operation lagClear events %= 10m ticks -execute if score lagClear events matches 0 run function clear_lag - -# Speed Effect (every 30s) -scoreboard players operation speedEffect events %= 30s ticks -execute if score speedEffect events matches 0 run effect @a speed 10 2 true +## World Timer/Clock +### Increment +1 tick +scoreboard players add Timer ticks 1 +### Apply current ticks passed to all events +scoreboard players operation * events = Timer ticks + +## Chat Message (every 2h) +scoreboard players operation ChatMessage events %= 2h ticks +execute if score ChatMessage events matches 0 run say Technoblade never dies! + +## Lag Clear (every 10m) +scoreboard players operation LagClear events %= 10m ticks +execute if score LagClear events matches 0 run function clear_lag + +## Speed Effect (every 30s) +scoreboard players operation SpeedEffect events %= 30s ticks +execute if score SpeedEffect events matches 0 run effect @a speed 10 2 true ``` ![Chain Of 8 Command Blocks](/assets/images/commands/commandBlockChain/8.png) @@ -80,45 +84,50 @@ Just make sure to follow the given order and properly apply the `/execute if sco ## Explanation -- **` events `** on this objective we label all the repeating events we want on our world. - - `chatMessage` - - `lagClear` - - `speedEffect` - - *Note: All 3 are fake-player-names in the objective.* -- **` ticks `** on this objective we define all the intervals for our events and also run our scoreboard timer. - - ` 2h` interval (static score: 144000) - - `10m` interval (static score: 12000) - - `30s` interval (static score: 600) - - `timer` clock (variable score: n+1) - - *Note: All 4 are fake-player-names in the objective* - -1. **Command 1:** This command adds +1 score every tick to the fake-player-name 'timer' indicating a tick has passed in the game. This is basically our scoreboard timer/clock which we will use for all the repeating events on our world. - - -2. **Command 2:** Here, we copy 'timer' score to all our events using the ` * ` wildcard selector. This will allow us to perform operations to determine if the interval has been reached to run the commands for that particular event. Example: - - If `timer` score is 1200, it means 1200 game-ticks have passed. - - And this command makes it so all our events fake-player-names 'chatMessage', 'lagClear', 'speedEffect' scores are also 1200. - - -3. **Command 3:** We will use the ` %= ` modulo operation to check if our events scores are divisible by their corresponding interval. ie., if the remainder is equal 0. - - Chat Message: `1200/144000` - - Q=0, R=1200 - - *hence, interval not reached.* - - Lag Clear: `1200/12000` - - Q=0, R=1200 - - *hence, interval not reached.* - - Speed Effect: `1200/600` - - Q=2, R=0 - - *hence, interval reached and event commands can be executed.* - - Here, we can note that the first 2 events are yet to happen, but the 3rd event is happening for the second time. -:::tip +**` events `** — On this objective, we label all the repeating events we want on our world: + +- `ChatMessage` +- `LagClear` +- `SpeedEffect` + +*Note: All 3 are fake-player-names in the objective.* + +**` ticks `** — On this objective, we define all the intervals for our events and also run our scoreboard timer: + +- ` 2h` interval (static score: 144000) +- `10m` interval (static score: 12000) +- `30s` interval (static score: 600) +- `Timer` clock (variable score: n+1) + +*Note: All 4 are fake-player-names in the objective.* + +**Command 1:** This command adds +1 score every tick to the fake-player-name 'Timer' indicating a tick has passed in the game. This is basically our scoreboard timer/clock which we will use for all the repeating events on our world. + +**Command 2:** Here, we copy 'Timer' score to all our events using the ` * ` wildcard selector. This will allow us to perform operations to determine if the interval has been reached to run the commands for that particular event. Example: + +- If `Timer` score is 1200, it means 1200 game-ticks have passed. +- This command makes it so all our events fake-player-names ('ChatMessage', 'LagClear', 'SpeedEffect') scores are also 1200. + +**Command 3:** We will use the ` %= ` modulo operation to check if our events scores are divisible by their corresponding interval. i.e., if the remainder is equal to 0. + +- Chat Message: `1200/144000` + - Q=0, R=1200 — *interval not reached.* +- Lag Clear: `1200/12000` + - Q=0, R=1200 — *interval not reached.* +- Speed Effect: `1200/600` + - Q=2, R=0 — *interval reached.* + - Hence, commands for this event can be executed. + +Here, we can note that the first two events are yet to happen, but the third event is happening for the second time. + +:::info NOTE: In Minecraft, scoreboard division is only calculated up to whole numbers and decimal values are ignored. ![](/assets/images/commands/longDivision.png) ::: -- **Command 4:** the remainder obtained from the calculation is applied to the corresponding event's fake-player-name. Based on this knowledge, we can run our commands if the it's score is equal to `0`. +**Command 4:** the remainder obtained from the calculation is applied to the corresponding event's fake-player-name. Based on this knowledge, we can run our commands if it's score is equal to `0`. -The rest of the commands are identical in structure and only the event labels and interval durations are changed. +The remaining commands follow the same structure, with only the event labels and interval durations adjusted. ## Defining Events With Limited Intervals @@ -127,45 +136,49 @@ To limit how many times an event occurs, you need to create a new objective call ```yaml -/scoreboard objectives set chatMessage intervals 5 -/scoreboard objectives set speedEffect intervals 10 +/scoreboard objectives add intervals dummy +/scoreboard players set ChatMessage intervals 5 +/scoreboard players set SpeedEffect intervals 10 ``` Once you have done that, modify your system as shown below. -BP/functions/world_timer.mcfunction +BP/functions/scoreboards/world_timer.mcfunction ```yaml -scoreboard players add timer ticks 1 -scoreboard players operation * events = timer ticks - -# Chat Message (every 10m) -scoreboard players operation chatMessage events %= 2h ticks -execute if score chatMessage events matches 0 if score chatMessage intervals matches 1.. run say Technoblade never dies! -execute if score chatMessage events matches 0 if score chatMessage intervals matches 1.. run scoreboard players remove chatMessage intervals 1 - -# Speed Effect (every 30s) -scoreboard players operation speedEffect events %= 30s ticks -execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run effect @a speed 10 2 true -execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run scoreboard players remove speedEffect intervals 1 +## World Timer/Clock +### Increment +1 tick +scoreboard players add Timer ticks 1 +### Apply current time to all events +scoreboard players operation * events = Timer ticks + +## Chat Message (every 10m) +scoreboard players operation ChatMessage events %= 2h ticks +execute if score chatMessage events matches 0 if score ChatMessage intervals matches 1.. run say Technoblade never dies! +execute if score chatMessage events matches 0 if score ChatMessage intervals matches 1.. run scoreboard players remove ChatMessage intervals 1 + +## Speed Effect (every 30s) +scoreboard players operation SpeedEffect events %= 30s ticks +execute if score SpeedEffect events matches 0 if score SpeedEffect intervals matches 1.. run effect @a speed 10 2 true +execute if score SpeedEffect events matches 0 if score SpeedEffect intervals matches 1.. run scoreboard players remove SpeedEffect intervals 1 ``` ![Chain Of 8 Command Blocks](/assets/images/commands/commandBlockChain/8.png) ## Executing Commands During Timeframe -To run commands during the timeframe between intervals for a particular system, you may employ the technique shown below. +To run commands continuously between the intervals of an event, you may use the technique shown below. ```yaml -# Speed Effect (every 30s) + Particle (every tick) -scoreboard players operation speedEffect events %= 30s ticks -execute if score speedEffect intervals matches 1.. as @a at @s run particle minecraft:shulker_bullet ~~~ -execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run effect @a speed 10 2 true -execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run scoreboard players remove speedEffect intervals 1 +## Speed Effect (every 30s) + Particle (every tick) +scoreboard players operation SpeedEffect events %= 30s ticks +execute if score SpeedEffect intervals matches 1.. as @a at @s run particle minecraft:shulker_bullet ~~~ +execute if score SpeedEffect events matches 0 if score SpeedEffect intervals matches 1.. run effect @a speed 10 2 true +execute if score SpeedEffect events matches 0 if score SpeedEffect intervals matches 1.. run scoreboard players remove SpeedEffect intervals 1 ``` -As shown in line 3, to run commands while the timer is running, all you need to do is remove the "if score" testing if the interval has been reached. And instead, only test if *any* interval remains to run our commands. +As shown in line 3, to run commands while the timer is running, all you need to do is remove the "if score" testing if the interval has been reached. And instead, only test if any interval remains to run our commands. Let's say we had set the `intervals` for this event to `10`. Then players would also have had particle trails for 300 seconds as repeating a 30s event 10 times will total 300 seconds. @@ -181,29 +194,29 @@ Let's say we want to perform the following actions: 5. stop the timer if a passive mob is nearby. 6. loop the timer if a hostile mob is nearby. -BP/functions/entity_timer.mcfunction +BP/functions/scoreboards/entity_timer.mcfunction ```yaml -# Clock +## Running The Timer scoreboard players add @e [name=station, scores={ticks=0..}] ticks 1 -# Executing Commands while timer is running +# Executing Commands While Timer is Running execute as @e [name=station, scores={ticks=0..}] at @s run particle minecraft:shulker_bullet ~~~ -# Executing commands within a timeframe +# Executing Commands Within a Timeframe execute as @e [name=station, scores={ticks=0..200}] at @s run particle minecraft:basic_flame_particle ~~~ -# Executing commands at specific intervals +# Executing Commands at Precise Intervals execute as @e [name=station, scores={ticks=3600}] at @s run playsound note.pling @a [r=10] -# Stopping the timer +# Stopping The Timer execute as @e [name=station] at @s if entity @e [family=pacified, r=10, c=1] run scoreboard players set @s ticks -1 -# Looping the timer +# Looping The Timer execute as @e [name=station, scores={ticks=6000}] at @s if entity @e [family=monster, r=10, c=1] run scoreboard players set @s ticks 0 -# End -/kill @e [name=station, scores={ticks=6000}] +# End of Timer +kill @e [name=station, scores={ticks=6000}] ``` ![Chain Of 7 Command Blocks](/assets/images/commands/commandBlockChain/7.png) diff --git a/docs/commands/selectors.md b/docs/commands/selectors.md index b72dc0425c3..235b55eff15 100644 --- a/docs/commands/selectors.md +++ b/docs/commands/selectors.md @@ -36,7 +36,7 @@ Limits the selection of targets by their identifier. Negating the argument selec - `type=`—Include only entities with the given identifier. - `type=!`—Exclude any entities with the given identifier. -Examples: +**Examples:** Affect all pigs with levitation: - `/effect @e[type=pig] levitation` @@ -52,7 +52,7 @@ The selectors `@a`, `@p`, and `@e` sort by increasing distance, while `@r` sorts - `c=`—Select up to `` entities. -Examples: +**Examples:** Clear stone from the closest five players: - `/clear @a[c=5] stone` @@ -68,7 +68,7 @@ Changes the position a selector starts its search at. It also modifies where the - `x=`, `y=`, and `z=`—Defines a position for the target selector. -Examples: +**Examples:** Teleport the closest player to (140, 64, -200) ten blocks up: - `/teleport @p[x=140, y=64, z=-200] ~ ~10 ~` @@ -79,7 +79,7 @@ Limits the selection of targets by their spherical distance from the selector. T - `rm=` and `r=`—Selects entities between the minimum and maximum number of blocks away, inclusive and respectively. -Examples: +**Examples:** Kill all chickens between two and six blocks away: - `/kill @e[type=chicken, rm=2, r=6]` @@ -95,7 +95,7 @@ The general formula for calculating the volume between two positions can be view - `dx=`, `dy=`, and `dz=`—Selects entities inside the given bounding box. -Examples: +**Examples:** List all entities within a 12x30x2 box: - `/say @e[dx=12, dz=30, dy=2]` @@ -116,6 +116,9 @@ In this visual representation, we can see that the horse with a larger hitbox is ::: +Considering the above note, if we want to detect players exactly at a certain Y level (e.g., Y=10) and not partially, we can use a command like this: +- `/execute as @a at @s if entity @s[y=10, r=1] unless entity @s[y=9, r=1] run say found player` + ### Scores Limits the selection of targets by their score value. This argument is represented as an object, with key-value pairs for a scoreboard objective and a value. The value can represent a range of numbers, using the range syntax. The value of a score can be negated to test if the entity does not have a score value within that range. @@ -127,7 +130,7 @@ The range syntax works as follows: - `..N` is any number less than or equal to N. - `N..M` is any number between N and M, inclusive. -Examples: +**Examples:** Set the "points" score for all players with a "points" score of ten to 0: - `/scoreboard players set @p[scores={points=10}] points 0` @@ -142,13 +145,13 @@ Limits the selection of targets by name. Negating the argument selects entities - `name=`—Include only entities with the given name. - `name=!`—Exclude any entities with the given name. -Examples: +**Examples:** List all zombies named Shadow: -- `/say @e[type=zombie, name=Shadow]` +- `/say @e[type=zombie, name="Shadow"]` Give one level to players both not named Steve and not named Alex: -- `/xp 1L @a[name=!Steve, name=!Alex]` +- `/xp 1L @a[name=!Steve, name=!"Alex"]` ### Tag @@ -157,7 +160,7 @@ Limits the selection of targets by their tags. This argument can be repeated to - `tag=`—Include only entities with the given tag. - `tag=!`—Exclude any entities with the given tag. -Examples: +**Examples:** Kill all mobs with the tag "marked", and without the tag "exempt": - `/kill @e[tag=marked, tag=!exempt]` @@ -169,7 +172,7 @@ Limits the selection of targets by type family. This argument can be repeated to - `family=`—Include only entities with the given type family. - `family=!`—Exclude any entities with the given type family. -Examples: +**Examples:** Affect all entities in the "monster" family with Regeneration: - `/effect @e[family=monster] regeneration` @@ -183,13 +186,13 @@ Limits the selection of targets by their rotation. There are two types of rotati _x-rotation diagram shared by @SpacebarNinja:_ -![x-rotation](/assets/images/commands/selectors/x-rotation.png) + _y-rotation diagram shared by @SpacebarNinja:_ -![y-rotation](/assets/images/commands/selectors/y-rotation.png) + -Examples: +**Examples:** Affect all players looking at or above the horizon with Blindness for one second: - `/effect @a[rx=0] blindness 1` (0 or less) @@ -197,16 +200,35 @@ Affect all players looking at or above the horizon with Blindness for one second Damage all players facing generally south: - `/damage @a[rym=-45, ry=45] 1` +**All Facing Directions:** + +| Facing Direction | Range (`ry`, `rym`) | +|------------------|--------------------------------| +| North | `[ry=-135, rym=135]` | +| South | `[ry=45, rym=-45]` | +| East | `[ry=-45, rym=-135]` | +| West | `[ry=135, rym=45]` | +| North West | `[ry=180, rym=90]` | +| North East | `[ry=-90, rym=-180]` | +| South West | `[ry=90, rym=0]` | +| South East | `[ry=0, rym=-90]` | + ### Level Limits the selection of targets by experience levels. Only players can have EXP, so this filters out non-player targets. - `lm=` and `l=`—Selects players whose EXP levels are between the minimum and maximum values specified, inclusive and respectively. -Examples: +**Examples:** -Give all players who have between three and eight levels a diamond: -- `/give @a[lm=3, l=8] diamond` +Give all players who have nine or less levels a gold ingot: +- `/give @a[lm=9] iron_ingot` + +Give all players who have ten or more levels a gold ingot: +- `/give @a[l=10] gold_ingot` + +Give all players who have between ten and twenty levels a diamond: +- `/give @a[lm=10, l=20] diamond` ### Game Mode @@ -214,14 +236,17 @@ Limits the selection of targets by game mode. Only players can use game mode, so - `m=`—Selects players by their game mode. -Possible values include: -* `0`, `s`, or `survival` for Survival mode -* `1`, `c`, or `creative` for Creative mode -* `2`, `a`, or `adventure` for Adventure mode -* `spectator` for Spectator mode -* `d` or `default` for the default game mode +**All Game Mode Values:** + +| Game Mode | Values | +|----------------|-----------------------------| +| Survival | `0`, `s`, `survival` | +| Creative | `1`, `c`, `creative` | +| Adventure | `2`, `a`, `adventure` | +| Spectator | `spectator` | +| Default | `d`, `default` | -Examples: +**Examples:** List all players in Creative mode: - `/say @a[m=creative]` @@ -239,7 +264,7 @@ Limits the selection of targets by what items they have in their inventory. This - `location=`—The slot the item should be located in. Accepts the same arguments as the slotType argument in the `/replaceitem` command. - `slot=`—The index of the slot used in the "location" argument, and can only be used with "location". Accepts a range for a value. This argument can be negated. -Examples: +**Examples:** Checks for players who have a netherite sword in their inventory: - `/testfor @a[hasitem={item=netherite_sword}]` diff --git a/docs/meta/style-guide.md b/docs/meta/style-guide.md index 3af35b137cd..2e384630c5c 100644 --- a/docs/meta/style-guide.md +++ b/docs/meta/style-guide.md @@ -1,10 +1,11 @@ --- title: Style Guide mentions: - - wiki + - SirLich - solvedDev - MedicalJewel105 - ChibiMango + - zheaEvyline description: Officially supported Bedrock-Wiki style guide for add-on creation. --- @@ -17,15 +18,35 @@ The style guide is a living, breathing document, which will evolve as add-on cre ## Folder Structure - No spaces in your file paths. `use_underscores`. -- No `CAPITALS` in your identifiers, file names, or folder names. +- No `CAPITALS` in your identifiers, file names, or folder names. 'BP' and 'RP' folder names may use capitals. - The total character length of any path must not exceed 80 characters (console limitation). -- Content folders should use consistent pluralization: Don't mix and match. +- Content folders should use consistent pluralization: Stick with names that are either all plural or all singular, don't mix and match. Example: + +✅️ Consistent: +``` +BP/functions/abilities/ice_blast.mcfunction +BP/functions/events/player/on_death.mcfunction +BP/functions/events/world/on_initialise.mcfunction +BP/functions/quests/jungle/1.mcfunction +``` +- All content folders `abilities`, `events`, and `quests` are consistently pluralized. +- The content folders in `events` are also consistent, as both `player` and `world` are singular. + +❌️ Inconsistent: +``` +BP/functions/ability/ice_blast.mcfunction +BP/functions/event/players/on_death.mcfunction +BP/functions/event/world/on_initialise.mcfunction +BP/functions/quests/jungle/1.mcfunction +``` +- Only `quests` content folder is pluralized while `ability`, and `event` are singular. +- Also, in the `event` folder, the `players` folder is plural while `world` is singular. ## Identifiers Do not use identifiers that begin with a number, and especially don't use an identifier that is _only_ a number. This applies to entities, component_groups, events, and anything else that takes a `namespace:name` pair. -## File and Folder names +## File and Folder Names | Concept | Example Identifier | | -------------------- | -------------------------- | @@ -34,8 +55,8 @@ Do not use identifiers that begin with a number, and especially don't use an ide | Geometry | dragon.geo.json | | Animation | dragon.animation.json | | Animation Controller | dragon.ac.json | -| RP Entity | dragon.ce.json | -| BP Entity | dragon.se.json | +| RP Entity | dragon.ce.json
*(ce: client entity)*| +| BP Entity | dragon.se.json
*(se: server entity)*| | Item 1.16.100+ | dragon_tooth.item.json | | BP Item | dragon_tooth.item.bp.json | | RP Item | dragon_tooth.item.rp.json | @@ -69,7 +90,7 @@ When not to use namespaces: - do not include your namespace in any folder path or file-name -## Sub-indexing +## Sub-Indexing Sub indexing is the use of `.` to separate chained concepts. Sub-indexing should go in descending order from big to small: @@ -86,7 +107,7 @@ When using sub-indexing, use `_` as space, not another `.`. You can use sub-indexing in your entities: `wiki:dragon.drake` -## Groups and Events should complement each other +## Groups and Events Should Complement Each Other | Group | Event | | --------- | ------------------- | @@ -95,7 +116,7 @@ You can use sub-indexing in your entities: | wiki:tame | ✔️ wiki:on_tame | | wiki:tame | ❌ wiki:tame | -## Short-Names should be Generic +## Short-Names Should Be Generic Short-names are file-specific identifiers, which are used to map between an identifier and a pretty name. They are handy because they allow us to re-use animation controllers and render controllers. For this reason, your short-names should be generic. @@ -105,15 +126,100 @@ Short-names are file-specific identifiers, which are used to map between an iden When we make short-names of this form, we can use a generic "sit" animation controller for all of them since we can use the `sit` short-name to play the sit animation. -## Functions should be nested +## Functions + +1. **Functions should be nested.** You can put functions in folders to achieve this. + - ✅️ `function teleport/zone/hell` + - ❌ `function teleport_hellzone` + +2. **Function file/folder names must follow an `action_object` structure.** Meaning verbs should always come before the subjects. + - ✅️ `add_all` + - ✅️ `shuffle_position` + - ❌️ `all_add` + - ❌️ `position_shuffle` + +### Comments in Functions -You can put functions in folders to achieve this. +- When working with functions that contain many commands, it's helpful to keep them organized by using multiple hashtags in comments to indicate different header levels. +- *Optionally*, to further distinguish these levels, you can apply different styles: + - level 1 headers - **# UPPERCASE** + - level 2 headers - **## Title Case** + - level 3 headers - **### Sentence case** +- Try to avoid the use of more than three header levels or too many headers overall, as this can make the code look cluttered. For your reference, see the example file below: -✔️ `function teleport/zone/hell` + -❌ `function teleport_hellzone` +BP/functions/abilities/fire_trail.mcfunction + +```yaml +# ON PLAYER ITEM DROP + +## Give Effects +### Fire resistance +execute at @e [type=item, name="Fire Trail Ability"] run effect @p [r=3] fire_resistance 10 255 +### Speed +execute at @e [type=item, name="Fire Trail Ability"] run effect @p [r=3] speed 10 1 true + +## Add Particle Time (10s) +execute at @e [type=item, name="Fire Trail Ability"] run scoreboard players set @p [r=3] abilities.fire_trail 200 + +## Delete Item +kill @e [type=item, name="Fire Trail Ability"] + + +# ENTITY TIMER + +## Emit Particle Trail +execute at @a [scores={abilities.fire_trail=1..}] run particle minecraft:basic_flame_particle ~~~ + +## Countdown Timer +scoreboard players remove @a [scores={abilities.fire_trail=1..}] abilities.fire_trail 1 +``` -## Group animations files when possible + + +Note the use of two lines of spacing before level 1 headers and one line of spacing before level 2 headers for improved readability. + +This practice helps create a consistent format, making it easier for everyone to follow, and maintain uniformity across your functions. + +## Scoreboards and Tags + +- Scoreboard objectives should be named using `snake_case`, while scoreboard fake-player-names should use **PascalCase**. This distinction makes it easier to differentiate between the two when typing scoreboard commands. +- Tags should use `camelCase`, as they usually represent states or conditions and align with common conventions for variable names. + +**Example Tag Names:** + +- `admin` +- `inNether` +- `isFlying` +- `abilityFireTrail` +- `abilityWallClimb` + +*Only alphanumeric characters.* + +**Example Fake Player Names:** + +- `AlivePlayer` +- `ZombieHorse` +- `OresEmerald` +- `OresDiamond` +- `OresDeepslateDiamond` + +*Only alphanumeric characters.* + +**Example Objective Names:** + +- `ticks` +- `entity_timer` +- `abilities.fire_trail` +- `abilities.wall_climb` +- `abilities.ice_blast` + +*Only **lowercase** alphanumeric characters, underscores (`_`), and dots (`.`).* + +For objectives, dot notation (`dot.notation`) may be used to represent groups or categories. However, use it sparingly to avoid clutter and maintain readability. + +## Group Animations Files when Possible Example: @@ -130,7 +236,7 @@ Example: } ``` -## Split textures by path, not name +## Split Textures by Path, Not Name ✔️ `textures/dragon/red` @@ -150,12 +256,13 @@ Comments intended for the localizer should always be in-line, in the following f Own-line comments can be used for organizational purposes but should not store localization-critical information. -## Acronyms when discussing +## Acronyms when Discussing | Acronym | Concept | | ------- | ---------------------------------- | | BP | Behavior Pack | -| RP | Resource pack | +| RP | Resource Pack | +| FP | Function Pack | | VRP | Vanilla Resource Pack | | VBP | Vanilla Behavior Pack | | AC | Animation Controller | @@ -198,3 +305,5 @@ Blocks and Items should follow the format order below. This would particularly h ## Custom Components Variable Name PascalCase should be used with BlockComponent or ItemComponent as a suffix. As an example, `MeltableBlockComponent` rather than `meltable`. This would help to differentiate what we're using in `registerCustomComponent` and what we're using as values elsewhere. + + diff --git a/docs/meta/useful-links.md b/docs/meta/useful-links.md index 0bc88ef6bfd..9fc6ab8f309 100644 --- a/docs/meta/useful-links.md +++ b/docs/meta/useful-links.md @@ -30,9 +30,9 @@ Important links have a ⭐. - ⭐ [Blockbench](http://discord.gg/fZQbxbg) - ⭐ [bridge.](https://discord.gg/NxKuWuA) - ⭐ [Minecraft Commands](https://discord.gg/QAFXFtZ) -- [Snowstorm](https://discord.gg/W9d78Z8AvM) -- [Amulet & MCEdit](https://discord.gg/dSnwqQf) +- ⭐️ [Snowstorm](https://discord.gg/W9d78Z8AvM) - [Amethyst](https://discord.gg/Cxrj9UXnDB) +- [Amulet & MCEdit](https://discord.gg/dSnwqQf) - [Artists Refuge](https://discord.gg/aVXbPCdRr3) - [BDSX](https://discord.gg/8UhbaDwFMh) - [Bedrock Commands](https://discord.gg/vV29d6rJcj) @@ -50,50 +50,51 @@ Important links have a ⭐. - ⭐ [bridge. Add-on Editor](https://bridge-core.github.io/) - ⭐ [VSCode Editor](https://code.visualstudio.com/) - ⭐ [Regolith](https://github.com/Bedrock-OSS/regolith) -- [CoreCoder [Code Editor]](https://hanprog.itch.io/core-coder) -- [Feature Rule Generator v2 (paid version)](https://machine-builder.itch.io/frg-v2) -- [Feature Rule Generator v2 (free version)](https://drive.google.com/file/d/1rwQTtzgpWiqCS9ecO_j-qcxjdQvWSXgi/view) -- [Add-on JSON Generator (paid)](https://kaifireborn.itch.io/add-on-json-generator) -- [NBT Editor](https://www.universalminecrafteditor.com/) -- [World Converter (paid)](https://www.universalminecraftconverter.com/download) +- [Add-on JSON Generator (Paid)](https://kaifireborn.itch.io/add-on-json-generator) +- [BedrockConnect (App)](https://bedrockconnect.bedrockhub.io) +- [BedrockLauncher (Bedrock Version Switcher)](https://bedrocklauncher.github.io/) - [Chunker (World Converter)](https://chunker.app/) +- [CoreCoder (Code Editor)](https://hanprog.itch.io/core-coder) +- [Feature Rule Generator v2 (Free Version)](https://drive.google.com/file/d/1rwQTtzgpWiqCS9ecO_j-qcxjdQvWSXgi/view) +- [Feature Rule Generator v2 (Paid Version)](https://machine-builder.itch.io/frg-v2) +- [NBT Editor](https://www.universalminecrafteditor.com/) - [NBT Studio](https://github.com/tryashtar/nbt-studio) -- [BedrockLauncher (Bedrock version switcher)](https://bedrocklauncher.github.io/) -- [ResourcePack Converter [App]](https://converter.bedrockhub.io) -- [BedrockConnect [App]](https://bedrockconnect.bedrockhub.io) +- [ResourcePack Converter (App)](https://converter.bedrockhub.io) +- [World Converter (Paid)](https://www.universalminecraftconverter.com/download) ## Bedrock Tools Websites - ⭐ [Snowstorm Particle Generator](https://jannisx11.github.io/snowstorm/) - ⭐ [Loot Table Generator](https://bedrock-oss.github.io/bedrock-loot-gen/) +- [Add-on Obfuscator](https://tools.pixelpoly.co/obfuscator) - [Apply Loot Tables to Structures](https://mcbe-essentials.github.io/structure-editor/loot-tabler) -- [MCBE ESSENTIALS](https://mcbe-essentials.github.io/) -- [Structure Editor](https://mcbe-essentials.github.io/structure-editor/) -- [Convert MCSTRUCTURE to MCFUNCTION](https://mcbe-essentials.github.io/structure-to-function/) +- [behavior-builder (beta)](https://stirante.com/behavior/index) +- [controller-builder (beta)](https://stirante.com/controller/index) +- [Convert .mcstructure to .mcfunction](https://mcbe-essentials.github.io/structure-to-function/) - [Crafting Recipe Generator](https://crafting.thedestruc7i0n.ca/) -- [Trade Table Generator](https://mcbe-essentials.github.io/trade-table-editor/) -- [World Packager](https://mcbe-essentials.github.io/world-packager/) -- [Manifest Generator](https://tools.pixelpoly.co/manifest-generator) +- [Dialogue Generator](https://mcbe-essentials.github.io/dialogue-editor/) - [Foxynotail Tools](https://www.foxynotail.com/tools/) +- [Glyph Tools](https://nhanaz.github.io/glyph/) - [.lang File Generator](https://solveddev.github.io/AnyLanguage/) -- [behavior-builder (beta)](https://stirante.com/behavior/index) -- [controller-builder (beta)](https://stirante.com/controller/index) -- [MCPACK Generator](https://mcbe-essentials.github.io/instant-pack/) +- [Manifest Generator](https://tools.pixelpoly.co/manifest-generator) +- [MCBE Essentials](https://mcbe-essentials.github.io/) +- [.mcpack Generator](https://mcbe-essentials.github.io/instant-pack/) - [Molang Grapher](https://jannisx11.github.io/molang-grapher/) - [Molang Playground](https://bridge-core.github.io/molang-playground/) -- [Dialogue Generator](https://mcbe-essentials.github.io/dialogue-editor/) +- [Nine Slice Visualiser (UI)](https://minato-mba.github.io/content/9slice.html) - [Selector Generator](https://mcbe-essentials.github.io/selector-generator/) -- [Add-on Obfuscator](https://tools.pixelpoly.co/obfuscator) -- [Glyph Tools](https://nhanaz.github.io/glyph/) +- [Structure Editor](https://mcbe-essentials.github.io/structure-editor/) +- [Trade Table Generator](https://mcbe-essentials.github.io/trade-table-editor/) +- [World Packager](https://mcbe-essentials.github.io/world-packager/) ## Documentation - ⭐ [bedrock.dev](https://bedrock.dev/) - ⭐ [Minecraft Creator Portal](https://docs.microsoft.com/en-us/minecraft/creator/) - ⭐ [Minecraft Community Wiki](https://minecraft.wiki) -- [Mcbehub](https://mcbehub.com/category/realmdocs) - [Bedrock Texture Pack Template](https://github.com/Brennian/BedrockTexturesTemplate) -- [Documentation Graveyard (removed components)](https://gist.github.com/destruc7i0n/ea1a6a7f97f0986d9326c58246f96fa3) +- [Documentation Graveyard (Removed Components)](https://gist.github.com/destruc7i0n/ea1a6a7f97f0986d9326c58246f96fa3) +- [Mcbehub](https://mcbehub.com/category/realmdocs) ### Getting Started With Your First Add-On @@ -118,7 +119,7 @@ These packs are published by the open-source community - [wiki-addon](https://github.com/Bedrock-OSS/wiki-addon) - [Enchantment Details](https://github.com/supercam19/EnchantmentDetails) -- [BC developer-packs](https://github.com/BedrockCommands/developer-packs) +- [Commands developer-packs](https://github.com/BedrockCommands/developer-packs) ## Scripting Resources @@ -129,32 +130,32 @@ These packs are published by the open-source community ## Raytracing Resources - ⭐ [Ray Tracing and PBR Texturing guide](https://docs.microsoft.com/en-us/minecraft/creator/documents/rtxgettingstarted) - ⭐ [Minecraft with Ray Tracing and Advanced Graphics FAQ](https://help.minecraft.net/hc/en-us/articles/4408865164173-Minecraft-with-Ray-Tracing-and-Advanced-Graphics-FAQ) +- [`.texture_set.json` Adobe Substance 3D Painter plugin](https://github.com/jasonjgardner/painter-plugin-texture-set-json) - [r/minecraftRTX Getting Started Guide](https://www.reddit.com/r/minecraftRTX/comments/iq3lkl/getting_startedhelpful_guidesresource_packs/) - [RenderBender](https://github.com/SpeedyCodes/RenderBender) - [RTX Presets](https://discord.com/channels/691547840463241267/919021996271108108) -- [`.texture_set.json` Adobe Substance 3D Painter plugin](https://github.com/jasonjgardner/painter-plugin-texture-set-json) ## Add-On Marketplaces & Links - ⭐ [Minecraft Marketplace](https://www.minecraft.net/en-us/catalog) - ⭐ [MCPEDL](http://mcpedl.com/?cookie_check=1) -- ⭐ [Bucket of Crabs (Marketplace joblist)](https://www.bucketofcrabs.net/) -- [MCDLHub](https://mcdlhub.com/) +- ⭐ [Bucket of Crabs (Marketplace Joblist)](https://www.bucketofcrabs.net/) - [CubitosMC](https://www.cubitosmc.com/) -- [Modbay](https://modbay.org/) -- [Minecraft Marketplace Stats](https://mcmarketstats.miste.fr/globalStats/) +- [MCDLHub](https://mcdlhub.com/) - [Minecraft Marketplace Partners](https://www.playthismap.com/partners) +- [Minecraft Marketplace Stats](https://mcmarketstats.miste.fr/globalStats/) +- [Modbay](https://modbay.org/) ## Other useful Links -- [UUID v4 Generator (online)](https://www.uuidgenerator.net/version4) -- [Minecraft Marketplace partner Twitter list](https://twitter.com/i/lists/1191945551853629442?s=09) -- [Minecraft.net Official Add-ons page](https://www.minecraft.net/en-us/addons) -- [Run Bedrock on Linux](https://github.com/Element-0/ElementZero) -- [Linux Packaging Scripts](https://github.com/ChristopherHX/linux-packaging-scripts) -- [Block Models](https://blockmodels.com/) - [Bedrock Add-Ons Reddit](https://www.reddit.com/r/BedrockAddons/) -- [Windows 10 Non-renderdragon install](https://support.playhive.com/windows-10-installing-non-renderdragon-clients/) - [Bedrock Edition Realm Protocol](https://github.com/NobUwU/BeRP) +- [Block Models](https://blockmodels.com/) - [Java & Bedrock Client](https://github.com/kennyvv/Alex) +- [Linux Packaging Scripts](https://github.com/ChristopherHX/linux-packaging-scripts) +- [Minecraft Marketplace Partner Twitter List](https://twitter.com/i/lists/1191945551853629442?s=09) +- [Minecraft.net Official Add-ons Page](https://www.minecraft.net/en-us/addons) +- [Run Bedrock on Linux](https://github.com/Element-0/ElementZero) - [Skin Pack Generator](https://github.com/MedicalJewel105/bedrock-skin-pack-generator) +- [UUID v4 Generator (Online)](https://www.uuidgenerator.net/version4) +- [Windows 10 Non-Renderdragon Install](https://support.playhive.com/windows-10-installing-non-renderdragon-clients/) diff --git a/docs/public/assets/images/commands/comparing-scores/GetMatchingScores.gif b/docs/public/assets/images/commands/comparing-scores/GetMatchingScores.gif new file mode 100644 index 00000000000..a66f49a9967 Binary files /dev/null and b/docs/public/assets/images/commands/comparing-scores/GetMatchingScores.gif differ diff --git a/docs/public/assets/images/commands/rearrange-positions/MPDVisualRep.gif b/docs/public/assets/images/commands/rearrange-positions/MPDVisualRep.gif new file mode 100644 index 00000000000..2d5c1087ac8 Binary files /dev/null and b/docs/public/assets/images/commands/rearrange-positions/MPDVisualRep.gif differ diff --git a/docs/public/assets/images/commands/selectors/y-rotation.png b/docs/public/assets/images/commands/selectors/y-rotation.png index 5908f949909..89875eed79d 100644 Binary files a/docs/public/assets/images/commands/selectors/y-rotation.png and b/docs/public/assets/images/commands/selectors/y-rotation.png differ