Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to write code?

Comments in 'Plugin Development' started by korado531m7, Jan 22, 2016.

  1. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    Hi. I'm creating a plugin.
    And i wanna know the code that using PlayerMoveEvent. Get player position and if player moved from x+2 , z+2, event cancelled.
    How to write this? Thanks for teaching.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    First of all, player wouldn't move exactly two blocks diagonally.l That situation is basically impossible to reproduce. Maybe you meant within that range?

    Also, your title...
    Legoboy0215 and AndrewBit like this.
  3. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    In other words, i want a code that like "LifeBoat" server.
    In lifeboat, player joined a match, player move a little.
    I want to code this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You first need to know the central position of the player, then use Vector3->distanceSquared() to check player distance from central position to see if it is greater than 4 (2²), if true, teleport back to central position. You don't need to use PlayerMoveEvent; just use a scheduled task to check at a lower frequency.
  5. korado531m7
    Offline

    korado531m7 Active Member

    Joined:
    Apr 4, 2015
    Posts:
    158
    Minecraft User:
    korado531m7
    Thank you. I'll try it!

Share This Page

Advertisement