Getting block under the cursor/getting highest block

Discussion in 'Plugin Development' started by LuaMilkshake, Feb 11, 2011.

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

    LuaMilkshake

    There was some functionality in hMod for this, and I want to port over a plugin that I had made for my server. How can I get the block under the client's cursor (and I'm not talking about the outlined blocks, I want ones that are far away as well). I also want to be able to get the highest block.
     
  2. Offline

    Plague

    For the highest block you can just iterate from 128 height downward till you get to a block that's not AIR.
     
  3. Offline

    darknesschaos

    Your question is terribly unclear, pick what you want it to do exactly and reword your question please.
     
  4. Offline

    fullwall

    For getting blocks far away, try asking Nijikokun for his iStick targeting code.
     
  5. Offline

    Raphfrk

    You probably want:

    Code:
    int height = getServer().getWorlds().get(worldNumber).getHighestBlockYAt(int x, int z);
    
    This info is used for light calculations and is pre-calculated and stored with the chunk data on the disk.

    You can also use it for determining where to put snow.

    It is probable that it ignores glass blocks, which is good or bad depending on what you want to use it for.
     
  6. Offline

    Plague

    So that's where the world.e() went?
     
  7. Offline

    Raphfrk

    Yeah probably :).
     
Thread Status:
Not open for further replies.

Share This Page