Ender dragon stop from destroying non-ender blocks?

Discussion in 'Plugin Development' started by RjSowden, Jun 12, 2012.

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

    RjSowden

    So I'm working on an aspect of my plugin that will spawn an ender dragon above ground. What I want it to do though, is treat all blocks as if they were enderstone i.e: not be destroyed when the dragon comes into contact with them.

    So for this I need some event that will fire when an ender dragon destroys any block in the landscape, so I can replace it once the dragon has passed through, or find some way for the dragon entity (and only the dragon entity) to treat a block (say dirt) as obsidian or ender stone.

    Anyone have any knowledge in this field?

    Thanks very much!
     
  2. Something like this should do the trick:
    Code:java
    1. @EventHandler
    2. public void stopDragonDamage(EntityExplodeEvent event) // Listen for the event...
    3. {
    4. Entity e = event.getEntity();
    5. if(e instanceof EntityComplexPart) // it it's a part of a dragon...
    6. e = ((EntityComplexPart)e).getParent(); // ... get the dragon...
    7. if(e instanceof EnderDragon) // if it's a dragon...
    8. event.getBlocks().clear(); // ...clear the list of destroyed blocks. A event.setCancelled(true); should work, too, just have a look what you like more. ;)
    9. }
     
    RjSowden likes this.
  3. Offline

    RjSowden

    So THATS what a "complex part" is! I was wondering. Also didn't realize that the blocks we're destroyed by an "Entity Explode" event. Thanks!
     
  4. Well, a dragon is more complex than other entities. It has parts.
    Np. :)
     
Thread Status:
Not open for further replies.

Share This Page