Detecting Lava / Water changing in to Obsidian

Discussion in 'Plugin Development' started by EcMiner, Sep 24, 2014.

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

    EcMiner

    Hey guys, I have already googled how to detect lava / water changing to obsidian, but the answers given in these posts did not work for me for some reason.

    I am trying to use the BlockFromToEvent but when I do this, nothing happens:

    Code:java
    1. Material original = evt.getBlock().getType();
    2. Material newtype = evt.getToBlock().getType();
    3.  
    4. if((original == Material.WATER || original == Material.STATIONARY_WATER || original == Material.LAVA || original == Material.STATIONARY_LAVA) && (newtype == Material.OBSIDIAN)) {
    5. // Water / Lava changed to obsidian...
    6. evt.setCancelled(true);
    7. }


    But lava / water still changes in obsidian...

    Can anyone help me?

    Kind regards, EcMiner.
     
  2. Offline

    Nateb1121

    Try putting a print statement in your event listener. So something like,

    Code:
    public void change(BlockFromToEvent){
    Bukkit.getLogger().info("I work!");
    }
    Just to be sure the listener is listening and then we'll go from there.
     
  3. Offline

    EcMiner



    ... Ok I just want to clear up, I am not a noob, ofcourse I have registered the listeners.
     
  4. Offline

    CraftCreeper6

    EcMiner
    You don't have to be a "noob" to not register your Listener. Sometimes, people just forget. :p
     
    dsouzamatt likes this.
  5. Offline

    EcMiner

    That's true, but it's also true that a lot of less experienced developers forget to check these kind of things before they ask it on Bukkit
     
  6. Offline

    Nateb1121

    Hm, could you post your whole listener method? I can't see any issues in the snippet you've shown.
     
  7. Offline

    FabeGabeMC

    EcMiner
    You can use
    Code:java
    1.  
    2. newtype.setType(original.getType());
    3. newtype.getState().update();
    4.  
     
  8. Offline

    fireblast709

    EcMiner could it be BlockFormEvent? (I don't have the source with me right now, but FromTo only manages the flow afaik)
     
  9. Offline

    FabeGabeMC

    fireblast709
    Yea, it would be BlockFromToEvent.
     
  10. Offline

    fireblast709

    Lol missed the examples xD

    EcMiner now reporting with the source in front of me. There is no event that fires when the block turns to obsidian. Try to cancel the flow from water to stationary lava (iirc that was the only way to create obsidian)
     
  11. Offline

    Techy4198

    Fyi water cannot turn into obsidian, you only need to check for lava.
     
Thread Status:
Not open for further replies.

Share This Page