How Chunk's X's and Z's work?

Discussion in 'Plugin Development' started by TheWolfBadger, Aug 11, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    TheWolfBadger

    Hello Bukkit Community!
    It's TheWolfBadger here! I am currently making a mini map which displays players per chunk using the scoreboard. It works awesomely, however that where the players are on the grid is actually messed up big time. I know it has to do with messing with the X's and Z's, but I can't figure out how to fix it. Thanks.
    Here it my code:
    http://hastebin.com/rasahurevo.avrasm

    Anyone know why? Please help! It's greatly appreciated! :D

    http://hastebin.com/waletahuti.avrasm <--- Updated Code.
    I think the real problem is the negative X's and Z's and the Positive ones. Not really sure though. Please help. Thanks. - Jack Badger

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  2. Offline

    TheWolfBadger

    bwfcwalshy What do you mean new picture? My avatar?

    Any help? Thanks. - Jack

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  3. Offline

    _Filip

    Chunk's position = block position >> 4
     
  4. Offline

    TheWolfBadger

    TheSpherret I am not very fond of what the >> symbol means. Mind explaining? Much appreciated. Thanks. - Jack
     
  5. Offline

    ChipDev

    Google.com
    Stackoverflow.com
    :D
     
  6. Offline

    TheWolfBadger

    ChipDev Found +=, but not >>...
     
  7. Offline

    mythbusterma

    TheWolfBadger

    >> is the bitshift right operator, it shifts bits to the right.
     
  8. Offline

    TheWolfBadger

    mythbusterma Okay, but that doesn't answer my question. My question is how would I make my Minimap work correctly based on the Chunks a player is on? Thanks. - Jack Badger
     
  9. Offline

    mythbusterma

    TheWolfBadger

    The coordinates of a chunk, given x and z of a block are:

    chunkX = blockX >> 4;
    chunkZ = blockZ >> 4;

    This is effectively dividing by 16, by moving the bits down 4 places.
     
  10. Offline

    TheWolfBadger

    mythbusterma Do all of you understand the question? I am trying to figure out why the Minimap positions of where the players are on their chunk are messed up...
     
  11. Offline

    mythbusterma

    TheWolfBadger

    We told you how to do it to the best of our knowledge, you didn't explain what the problem is so when can't help you.
     
  12. Offline

    Skye

    TheWolfBadger Chunk X, Y coordinates are on a separate grid. So since chunk dimensions are 16x16, every 16 blocks in a cardinal direction will modify chunk coordinates by 1.
     
  13. Offline

    TheWolfBadger

    Bump. I am trying to figure out like when a player is up and to the left 4 chunks that they will show up on the mini map like down 4 chunks and to the right 4 chunks. Any ideas on how to fix this and what the problem is with my code? Thank you. - Jack Badger
     
Thread Status:
Not open for further replies.

Share This Page