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

2 Questions..

Comments in 'Plugin Development' started by mamayadesu, Apr 9, 2015.

  1. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
    1. How get chunk on which you stand?
    2. How to realize: Player came to spawn territory (or other chunk) and he get message: "Welcome to spawn"?
  2. Blubbll
    Offline

    Blubbll Active Member

    Joined:
    Oct 3, 2013
    Posts:
    325
    Minecraft User:
    Blubbll
    idk how to, but i know it's possible.

    for the second thing: eg look at factionspro, it has areas & notifications on enter
  3. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
    Thank you!
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. It is $player->getLevel()->getChunk($player->getFloorX() >> 4, $player->getFloorZ() >> 4)
  5. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
    Thank you. And how I can get chunk id? Example: 89,25
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Isn't that the chunk ID?
  7. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
    Sorry. I didn't know one thing. I looked at the WorldEdit (CraftBukkit) code - I learned as they get that "ID" of chunks.
    PHP:
    $x 500// Player's X position
    $z = -120// Player's Z position
    $chunk_x = (int) round($x 16);
    $chunk_z = (int) round($z 16);
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    That's wrong. You should use >> 4 not / 16, because bit shifting is much faster than division. Also, it should be floor not round. And what do you think happens if the $x and/or $z is/are -1? If you use bit shifting, you need to neither call functions (thus prevent some overhead that is fixed in PHP 5.7), nor to do rounding and division. I am not sure if it works well for extreme coordinates like those in the farlands, though.
  9. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    -1 >> 4 is still -1 which is what you want. If you want to reduce stuff you can skip the round or floor. $x >> 4 is an int operation only so an int stays an int (no need to floor or cast to (int).
    PEMapModder likes this.

Share This Page

Advertisement