Block type calls returning 0?

Discussion in 'Plugin Development' started by Schirf, Jan 30, 2011.

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

    Schirf

    The simplest investigation of block type seems to fail for me...

    Code:
        private void performAction(Player player) {
            World world = player.getWorld();
            Location l = player.getLocation();
    
            int x = l.getBlockX();
            int y = l.getBlockY();
            int z = l.getBlockZ();
    
            int typeaccordingtoworld = world.getBlockTypeIdAt(x, y, z);
    
            Block block = world.getBlockAt(x,y,z);
    
            int typeaccordingtoblock = block.getTypeId();
    
            Material material = block.getType();
    
            int typeaccordingtomaterial = material.getId();
    
            player.sendMessage("World says type at x:" + Integer.toString(x) + " y:" + Integer.toString(y) + " z:" + Integer.toString(y) + " = " + Integer.toString(typeaccordingtoworld));
            player.sendMessage("Block says type at x:" + Integer.toString(x) + " y:" + Integer.toString(y) + " z:" + Integer.toString(y) + " = " + Integer.toString(typeaccordingtoblock));
            player.sendMessage("Block material type id = " + Integer.toString(typeaccordingtomaterial));
    
        }
    [​IMG]
    --- merged: Jan 30, 2011 4:20 PM ---
    Bah, Air!!! Nevermind.
    --- merged: Jan 30, 2011 4:24 PM ---
    Ok, it was an idiot programmer error. I assumed location was the block the player was standing ON... not the block the player was standing IN! Ha!
     
  2. Offline

    DerpinLlama

    Your player's location has to be in air. Players can't move through other blocks.

    Your code is esentially getting the block type where the player stands instead of below where he's standing. I think.
     
Thread Status:
Not open for further replies.

Share This Page