Zombie on pressure plate, kill it?

Discussion in 'Plugin Development' started by HGPDev, Aug 23, 2014.

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

    HGPDev

    Is it possible to kill a Zombie when they walk over a stone pressure plate? If so. How?
    Im thinking about 15 min now, but I cant find an solution. Anyone?
     
  2. Offline

    gabizou

    From what I understand, LivingEntities that are not Players do not throw EntityMoveEvent. However, what you can try to achieve is listening to BlockRedstoneEvent and get the block and possibly the entities nearby the block location and if it happens to be a zombie, kill it :).
     
  3. Offline

    stormneo7

    Code:java
    1. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    2. public void run(){
    3. for(World w : Bukkit.getWorlds()) for(Entity e : w.getEntities()){
    4. if(e instanceof Zombie){
    5. final Zombie z = (Zombie) e;
    6. if(z.getLocation().getBlock() != null && z.getLocation().getBlock().getType() == Material.STONE_PLATE){
    7. z.remove();
    8. }
    9. }
    10. }
    11. }
    12. }, 0L, 1L);
     
  4. Offline

    HGPDev


    I tried EntityInteractEvent, but didnt came to a solution. Is it possible with EntityInteractEvent?


    Thats fast! Ill test it. But i asume it works :D Thanks!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  5. Offline

    gabizou

    Not sure.
     
  6. Offline

    mythbusterma

    HGPDev

    That's extremely slow actually, and will put a huge load on any reasonably sized server.
     
  7. Offline

    stormneo7

    Well that method works and I'm not 100% sure that EntityInteractEvent will trigger from physical interactions; but it's worth a shot.
     
  8. Offline

    mythbusterma

    stormneo7

    Your best bet would definitely be the BlockRedstoneEvent, and then checking if the changing block is under a pressure plate, and then checking if it's a Zombie.
     
Thread Status:
Not open for further replies.

Share This Page