How do I make the player teleport like a chorus fruit would make them.

Started by phoenix_wb on

Topic category: Help with modding (Java Edition)

Last seen on 09:38, 31. Mar 2020
Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I make the player teleport like a chorus fruit would make them.

The title is pretty self explanatory, but I just want to make the player teleport when right clicked on an item like a chorus fruit would make it. 

Last seen on 14:00, 14. Nov 2023
Joined Jun 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can generate a random…
Wed, 03/25/2020 - 14:43

You can generate a random number, and then, you teleport the player to his coordinates plus (or minus) the random nubers
This teleports randomly the player at 5 blocks from his location, max
if (random(0,1) < 0,5):  <--- This is a random number to determine if the random range will be minus or plus current x
    if (random(0,1) < 0,5):    <--- This is a random number to determine if the random range will be minus or plus current z
        set (local nx) to random(0,5)
        set (local nz) to random(0,5)
        move player to x=x+nx, y=y, z=z+nz
    else:
        set (local nx) to random(0,5)
        set (local nz) to random(0,5)
        move player to x=x+nx, y=yn z=z-nz
else:
    if (random(0,1) < 0,5):
        set (local nx) to random(0,5)
        set (local nz) to random(0,5)
        move player to x=x-nx, y=y, z=z+nz
    else:
        set (local nx) to random(0,5)
        set (local nz) to random(0,5)
        move player to x=x-nx, y=yn z=z-nz