OH MY GOD MASSIVE ERROR! (NEW PROBLEM!)

Discussion in 'Plugin Development' started by Jnorr44, Jun 22, 2012.

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

    Jnorr44

    I have this now, but I need to figure out a way to check if a stream has 2 sources next to it, and if so, use the stream.setType(Material.STATIONARY_WATER) /lava to change the stream into a source.
     
  2. Offline

    MucTweezer

    Well I've just thrown this quickly together (in Notepad, so there may be some errors, but you get the idea):

    Code:
    private boolean hasTwoAdjacentBlocks(Block myBlock, int myTypeID) {
     
        int counter;
     
        for (BlockFace f : new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}) {
            if (myBlock.getRelative(f, 1).getTypeID == myTypeID) {
                counter++;
            }
        }
     
        if (counter >= 2) {
            return true;
        } else {
            return false;
        }
     
    }
    
    Then, for water, you could call this method using:

    Code:
    hasTwoAdjacentBlocks(event.getBlock(), 9);
    And for lava it would be:

    Code:
    hasTwoAdjacentBlocks(event.getBlock(), 11);
    The method would return true if there were two adjacent blocks of type 9 (or 11, depending on what argument you send it), and false if not.
     
    Firefly likes this.
  3. Offline

    monster860

    Here is your "looping" error problem:
    Code:
    Bukkit.getServer().getPluginManager().callEvent(event);
    That was inside the event handler. Basically, the event handler calls itself. :p
     
Thread Status:
Not open for further replies.

Share This Page