Delayed Teleport Towards Saved Location

This should give you basic understanding on how to utilize variables for good combinations

Tutorial:

Ok for starters, we will create an item that once right clicked, it will teleport as back to that very location.

1) Create an ei item

This is important as usual. Because how would you make the item without the item itself?

2) Go to the variables editor

3) Create a new variable

4) Set up the variable

For this part, we will set the variable name's to "x" to make things simple

5) Set the variable type to STRING

6) Don't mind too much about the value

We will be dealing with the value later.

7) Save the variable. Do not forget or else you might have to go back to the top

8) Go back to the main item editor by pressing the back button

9) Go to the activator editor

10) Create a new activator

11) Create a PLAYER_RIGHT_CLICK_ACTIVATOR

12) Go to the variables editor of the activator

Ok so here's the explanation. First, we will create a variable update which will save our coordinates. Further explanation ahead.

13) Click this icon

14) Click this icon to go to the chat editor and type the name of the variable we created at step 4)

You see, the default value for this is "var" and we are editing a variable under the name of "x". Back then in pre 5.0, we get to just click the icon to scroll through the list of variables under this item but now, we have to manually type it.

15) Set the type to "SET"

16) Type "%x% %y% %z%" in this icon

In the string update option, the placeholders in it is parsed before it gets displayed or used somewhere else.

17) Press the save button

18) Go back to the activator editor and save

19) Create a 2nd activator

20) Create another activator with the same kind

You might be curious, why the heck did we create another right click activator? Because the first activator's task is to save our coordinates via variable update.

You might say, "Can't we just do everything in one activator?" Nope. Commands run first then the variables. Try doing it in one activator and it will not produce the wanted results.

21) Go to the commands editor

22) Add the following commands in the chat editor

Ok. Here's the explanation. DELAY 30 will delay the command for 30 seconds. When it comes to variables, the activator order matters A LOT. Reversing the order of the 2 activators will break the item.

As said in the placeholders page, placeholders from the plugin will be parsed immediately meaning that any changes that are bound to happen will not affect the values. With the variable update in step 16, %var_x% will transform into the xyz coordinates of where you used the item so after 30 seconds, you will be teleported back to the exact location properly (unless you changed worlds but that's not the goal here.)

After typing the commands, of course press the exit button.

23) Save the item and try it out

Save the item and try it out!

Last updated