Make player explode like creeper

Discussion in 'Plugin Development' started by perwin, Mar 31, 2013.

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

    perwin

    Hello,
    I need help with developing plugin, where I need a player to explode, but exactly like creeper.
    I tried to use World.createExplosion() method, but it isn't what I am looking for, because it doesn't throw any event. I need to explode player with throwing DamageCause.ENTITY_EXPLODE, where the entity will be the player and in ExplosionPrimeEvent will be the entity type EntityType.PLAYER, containing again the player who exploded. So it has to be possible to cancel the exploding of the player etc.
    Thanks for replies.
     
  2. Offline

    kreashenz

    Somewhere at the bottom, I think..
     
  3. Offline

    perwin

    No, there is also the createExplosion() method. I need something else. And I am also curious why they didn't create some Explosion class which would be interface of entity. It would be very useful, if the createExplosion() method would return the Explosion entity and the same Explosion entity would be thrown on some explosion event...
     
  4. Offline

    TheUpdater

    try this dont know if works
    Code:
    @EventHandler
    public void tnt(EntityExplodeEvent event) {
    EntityType creeper = EntityType.CREEPER;
    EntityType tnt = EntityType.PRIMED_TNT;
    EntityType fireball = EntityType.FIREBALL;
    EntityType type = event.getEntityType();
    if(event.getEntity() != null) {
    if(event.getEntityType() != null) {
    if(type == creeper || type == tnt || type == fireball) {
    createExplosionSound(event.getLocation());
    event.setCancelled(true);
    }
    }
    }
    }
     
  5. Offline

    perwin

    Hmm, I fixed it by creating my own event thrown when is createExplosion() used.
     
  6. Offline

    the_merciless

    I made this recently, here you go (even has the hiss.):

    Code:
    final Double x = p.getLocation().getX();
                final Double y = p.getLocation().getY();
                final Double z = p.getLocation().getZ();
                p.getWorld().playSound(p.getLocation(), Sound.FUSE, 3F, 1F);
                Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
                    public void run(){
                        p.getWorld().createExplosion(x,y,z, 4F, true, false);
                        plugin.awardplayerexplosionkills(p);
                        plugin.sb.updatescoreboard(p, p.getName());
                    }
                },60L);
            }
    Edit: Oh just read your post fully, still this may help though.
     
Thread Status:
Not open for further replies.

Share This Page