One Time Loop

There are many things that can be done using this, if you are on need of it, this is the correct place to know how it works.

In this case we are going to make an item that will add a value on scoreboard if in hand and will remove it when deselect it

A first idea would be working with SELECT_THE_EI and DESELECT_THE_EI but it has problems related to what we want to do, because the player can move the item instead of deselecting it.

Let's create the item + method

  • First let's create the item with /ei create <id>

  • Set the material, name, and everything

  • Now, let's take a look at the method, it will consist on 2 loop activators, one in mainhand and the another one in all slots except mainhand, and, variables, that will disable the loop once it works one time + a PLAYER_DROP_THE_EI to also reduce the scoreboard value when the player drops the item, so it would look like this:

First, we will create a variable
Variable -> "scoreboard" - String

#First loop that will add the value to the player
Activator 1: LOOP 
Slot: MAINHAND
Commands: scoreboard players add %player% <scoreboardname> <value>
#Now the placeholder condition that will make this loop to work ONLY 1 time
Condition: PlaceholderCondition "%var_scoreboard" EQUALS "no"
variable update: "scoreboard" SET "yes"

#second loop that will remove the value to the player
Activator 2: LOOP
Slot: EVERYSLOT EXCEPT MAINHAND
Commands: scoreboard players remove %player% <scoreboardname> <value>
#Now the placeholder condition that will make this loop to work ONLY 1 time
Condition: 
- PlaceholderCondition "%var_scoreboard" EQUALS "yes"
- IfNotHasExecutableItem -> the EI itself + mainhand
variable update: "scoreboard" SET "no"

#activator that will remove the value to the player if he drops it
Activator 3: PLAYER_DROP_THE_EI
Commands: scoreboard players remove %player% <scoreboardname> <value>
#Now the placeholder condition that will make this loop to work ONLY 1 time
Condition: PlaceholderCondition "%var_scoreboard" EQUALS "yes"
variable update: "scoreboard" SET "no"

With this explanation should be enough, anyways, if you don't understand, we will make everything step by step

Long explanation

Create the variable

  • Variable name: scoreboard

  • Type: STRING

  • String value: "no"

  • Then save and let's go to the next step

First Activator

  • detailedSlots only mainhand

  • Variable update

  • And this will only work if the variable is "no", so let's create a placeholder condition

  • And the last thing the command to add a scoreboard value to the player, in this case I will only add a command "say ADDED" as a debug command.

Second activator

Its the same idea, so this will be faster than the previous one.

  • Working on every slot except mainhand

  • Variable update

  • Placeholder condition:

  • The second placeholder, that is a playerCondition (and the condition is on the 2nd page)

  • In this case the name of my item is asd

  • Then save and delete the error message, it is annoying

  • And the command

Drop activator

  • Add another activator

  • Placeholder condition to make it only work if the value is already added

  • The command

  • And the variable update

And that's it, save everything and test

Testing the item

Last updated