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

MPFac Chunk bounds

Comments in 'Plugin Development' started by MinePocket Servers, Apr 22, 2016.

  1. MinePocket Servers
    Offline

    MinePocket Servers Active Member

    Joined:
    Mar 6, 2014
    Posts:
    69
    Minecraft User:
    MinePocket
    Hello, I am porting pc factions (by massive core) over to pe. Not a crappy featureless port. I mean the whole deal.

    I need help with:
    Getting chunk coords at current player location (like return chunk number ex: 2,5)


    This is for claiming and /f map

    This plugins source will eventually be released to the community.
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    You can get an chunk with this:
    PHP:
    Level::getChunk($x >> 4$z >> 4true);
    And your chunk numbers would be:
    PHP:
    $ChunkIDp1 $x >> 4
    $ChunkIDp2 
    $z >> 4
    //(so for example
    $ChunkNumber $ChunkIDp1.",".$ChunkIDp2 = ;
    //)
    MinePocket Servers likes this.
  3. MinePocket Servers
    Offline

    MinePocket Servers Active Member

    Joined:
    Mar 6, 2014
    Posts:
    69
    Minecraft User:
    MinePocket
    Thanks for the reply,

    but how do I get ChunkNumber from player position like at coords x and y
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    In that code $x is player x and $z is player z
    MinePocket Servers likes this.
  5. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Some code:
    PHP:
    $x //PLAYER x
    $y //PLAYER y
    $ChunkIDp1 $x >> 4;
    $ChunkIDp2 $z >> 4;
    //(so for example
    $ChunkNumber $ChunkIDp1.",".$ChunkIDp2;
    echo(
    $ChunkNumber); //outputs for example 3,4
    //)
    //So you can do the following to save chunk reservations:
    $ChunkIDp1 $x >> 4;
    $ChunkIDp2 $z >> 4;
    $ReservedChunks[$id] = [$ChunkIDp1,$ChunkIDp2];
    You can also get an chunk with this:
    PHP:
    Level::getChunk($x >> 4$z >> 4true);
    MinePocket Servers likes this.
  6. MinePocket Servers
    Offline

    MinePocket Servers Active Member

    Joined:
    Mar 6, 2014
    Posts:
    69
    Minecraft User:
    MinePocket
    Thanks, I thought in the api x and y were chunk coords not player coords. Thanks for your help.
  7. MinePocket Servers
    Offline

    MinePocket Servers Active Member

    Joined:
    Mar 6, 2014
    Posts:
    69
    Minecraft User:
    MinePocket
    Also whats the point of the 4 like $x >> 4
  8. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Because of chunks having a 2^4(16) bit memory
    MinePocket Servers likes this.
  9. MinePocket Servers
    Offline

    MinePocket Servers Active Member

    Joined:
    Mar 6, 2014
    Posts:
    69
    Minecraft User:
    MinePocket
    Awesome thanks

Share This Page

Advertisement