Is there a way to protect certain blocks from an explosion?

Discussion in 'Plugin Development' started by Olof Larsson, Jun 24, 2011.

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

    Olof Larsson

    Hello :)
    I'm coding on Creative Gates right now. I need to protect the gates from explosions. So if a creeper would explode close to the gate I would like to cancel certain blocks from beeing destroyed. Note that I do NOT want to stop the explosion. The creeper should explode and all blocks should be destoryed as usually EXCEPT for the blocks in the gate.

    The onBlockBreak event does not seem to get triggered and this approach does not seem to work either:

    Code:
    // Gates can not be destroyed by explosions
        @Override
        public void onEntityExplode(EntityExplodeEvent event) {
            Iterator<Block> iter = event.blockList().iterator();
            while (iter.hasNext()) {
                Block block = iter.next();
                Gate gate = p.getGateFromBlock(block);
                if (gate != null) {
                    P.log("Removed: "+block);
                    iter.remove();
                }
            }
        }
    Anyone know how?
     
Thread Status:
Not open for further replies.

Share This Page