Listening to Fire

Hello guys,

I couldn’t find how to listen to fire. Of course I mean being able to cancel (or not) a “fire spreading” event.

I assume it must be done by listening to the ChangeBlockEvent but I can’t get how to be sure it’s due to fire spreading and how to get location of block that’s going to be on fire.

Do you guys know how I could do that ?

This might do it:

@Listener
public void onChange(ChangeBlockEvent event) {
    event.getTransactions().stream().filter(trans->trans.getFinal()
        .getState().getType() == BlockTypes.FIRE).forEach(trans->trans.setValid(false));
}

Haven’t tested it yet, but I think this will work. Although it most likely will not allow players to place fire as well.

2 Likes

That seems to be what I was looking for !

Thanks a lot !