From b826a4afe3697245f5226958e2186e776a20dd62 Mon Sep 17 00:00:00 2001 From: Zhea Evyline <99989764+zheaEvyline@users.noreply.github.com> Date: Sun, 15 Sep 2024 05:13:01 +0400 Subject: [PATCH] Update derangement-function.md --- docs/commands/derangement-function.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/commands/derangement-function.md b/docs/commands/derangement-function.md index e74835e5a0..37cdf08bd3 100644 --- a/docs/commands/derangement-function.md +++ b/docs/commands/derangement-function.md @@ -18,7 +18,7 @@ A derangement is a permutation of 'N' elements where no element appears in its o 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:** @@ -27,7 +27,7 @@ For example, if Player1 was at `0,0,1`, Player2 at `0,0,2`, and Player3 at `0,0, 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. @@ -74,7 +74,8 @@ execute if entity @e [name="Fake Player", scores={id=0}] run scoreboard players ## 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: @@ -105,7 +106,8 @@ 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 @@ -133,7 +135,9 @@ execute as @a [tag=!posAllocated] run scoreboard players add NonAllocatedPlayers ## 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 @@ -142,7 +146,9 @@ Now, for our functions to actually work, we will need to add the following objec 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