Water and torches

Discussion in 'Plugin Development' started by RingOfStorms, Aug 13, 2012.

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

    RingOfStorms

    I was wondering how you could disable water from being able to break blocks like torches, red stone, and the sort. Simple question, hope there is an easy answer. Thanks!
     
  2. Offline

    WarmakerT

    @EventHandler
    public void onWaterPassThrough(BlockFromToEvent event){

    if(event.getToBlock().getType() == Material.SUGAR_CANE_BLOCK){
    event.getToBlock().breakNaturally();
    }
    }
     
  3. Offline

    VoidWhisperer

    That's doing the exact opposite of what he wanted. Also, please put the code into a codeblock, thanks. This should do it:
    Code:
    @EventHandler
     
    public void onWaterPassThrough(BlockFromToEvent event){
     
    if(event.getToBlock().getType() == Material.SUGAR_CANE_BLOCK){
     
    //event.getToBlock().breakNaturally(); THIS WOULD BREAK IT!!!!
    event.setCancelled(true);
     
    }
     
    }
    This should make it so that it will flow around the block, but cancel it from flowing ONTO the breakable block. Just add more checks to the if statement to check for other blocks.
     
  4. Offline

    RingOfStorms

    Ok now with that, is there a way to see what source block of water is the one doing the damage. So only lets say a source block of water a player places would use this, but normal water would be normal.
     
  5. Offline

    WarmakerT

    event.getFromBlock()
     
  6. Offline

    RingOfStorms

    WarmakerT getFromBlock() doesn't exist

    And getBlock doesnt work either. I'm guessing it returns the block that would have broken the torch, so not the source, but one of the moving water pieces from the source.

    So is there a way to get the source block of a moving water block.

    Any ideas?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  7. Offline

    Courier

    What do you mean normal water? You can't tell which source block the water came from, because it might have come from multiple source blocks. If you want to see if it is next to a source block, you'd have to check all adjacent blocks.
     
  8. Offline

    RingOfStorms

    That was the question, if you could get it's source. Since I don't want to disable the water breaking things all the time, just for certain water sources and the water that comes off of that source. Which is sounding impossible?
     
  9. Offline

    Limeth

    Two words: Pathfinding loops :)
     
Thread Status:
Not open for further replies.

Share This Page