getHighestBlockAt() is returning air

Discussion in 'Plugin Development' started by dibujaron, Jan 13, 2013.

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

    dibujaron

    Code:
    if (event.getEntity().getType().equals(EntityType.SQUID)){
                Block block = event.getEntity().getWorld().getHighestBlockAt(event.getLocation());
                System.out.println(block.getType());
    the above code is within an event handler for creatureSpawnEvent. Every time I test this code, it outputs AIR to the console. the definition of getHighestBlockAt() is that it returns the hightest non-air block at a given location, so this has me a little stumped. Any thoughts/suggestions? Thank you!
     
  2. Offline

    jorisk322

    Maybe it isn't finding any blocks at all, and it decides to return air. Try running the code on a fixed location, that you know for sure should return something else.
     
  3. Offline

    dibujaron

    Code:
    @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event){
            Location location = event.getClickedBlock().getLocation();
            Block block = event.getPlayer().getWorld().getHighestBlockAt(location);
            System.out.println(block.getType());
        }
    this code prints AIR every time, too. now i'm really, really confused.

    as far as the squid code goes, if I spawn the squid into a block like snow or a sign, it prints SNOW or WALL_SIGN. however, if I do it in water it still prints AIR.
     
Thread Status:
Not open for further replies.

Share This Page