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

checking coordinates

Comments in 'Plugin Development' started by Creeperface, Aug 4, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    hi i check coordinates using this:
    PHP:
    if($x === $x1 && $y === $y1 && $z === $1)
    is there any better way how to check it?
  2. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    e.g. i want to check if coordinates of chest are same like another coordinates so is any better way how to check it?
  4. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    when i have more coordinates and i want to check if custom coordinates are same like one of them
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is already the fastest method.
    Creeperface likes this.
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    maby using '==' will be any nano seconds faster? :D
  7. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It will be subnano faster. Which makes it pointless :p
  9. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    And your post a lie :p
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    == doesn't work sometimes. It only works when two objects are of the same type and all their fields are identical, which is very unstable and very discouraged for plugins. (We never assume that a Vector3 is exactly a Vector3 but not a Position when we code)
    === only works when they are the same object. It is faster than == if you are using it correctly.
  11. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    $obj = new Vector3(345);
    if(
    $obj === $obj) return true// 1.
    if($obj == $obj) return true// 2.
    Ik that first one checks if it is identical and it is.
    But what does '==' check on second? if $obj is instance of other class?
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    $a = new Vector3(0,0,0);
    $b = new Vector3(0,0,0);
    $c = new Position(0,0,0,$level);
    $a === $b // false
    $a == $b // true
    $a == $c // false
    Creeperface and jojoe77777 like this.

Share This Page

Advertisement