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

Vector3/XYZ/Position/Location? What's difference?

Comments in 'Plugin Development' started by Kvetinac97, Jul 30, 2015.

  1. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Hi.

    Why I should write:
    PHP:
    $lv->dropItem(new Vector3($x,$y,$z));
    $lv->setBlock(new Vector3($x,$y,$z));
    //Why I don't use Vector3 here?
    $id $lv->getBlockIdAt($x,$y,$z);
    //+ Why I'm using Position here?
     
    $p->teleport(new Position($x+0.5,$y,$z+0.5), $lv); //I know why should I use +0.5
    And what is Location used for?
    PianoPlayer38 likes this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    For whether to use Vector3, it depends on the API function declaration. #readthedocs

    For Position, you are using it wrongly. You should pass $lv inside the constructor of Position, not outside as the second parameter to teleport().
    Position is an extension (a.k.a. subclass) of Vector3. It holds an extra property - apart from the x y z in Vector3, the level object is also contained in a Position.
    Minecrafter9203 and Legoboy0215 like this.

Share This Page

Advertisement