Solved EntityDamageByEntityEvent

Discussion in 'Plugin Development' started by Tdarnell, Jun 8, 2013.

Thread Status:
Not open for further replies.
  1. My problem is that my code is doing nothing once enabled, and I'm fairly sure its all right, but just incase I missed something stupid I'll post it here.

    [​IMG]

    The main is in the right place, and all of that code is in the main class. nothing is happening when I damage a wither though, not even my debug messages send. any help is appreciated. :)

    Edit: Image didn't work :p

    Code:
        @EventHandler
        public void onEntityDamage(EntityDamageByEntityEvent event) {
            if (!(event.getDamager() instanceof Player)) return;
            Player p = (Player)event.getDamager();
            Entity entity = event.getEntity();
            p.sendMessage("test");
            if (!(entity instanceof LivingEntity)) return;
            if ((entity instanceof Wither)){
                p.sendMessage("test2");
                if(event.getDamager() instanceof Player){
                    p.sendMessage("test3");
                    int health = ((Damageable) entity).getHealth();
                    if (health > 0){
                        //Entity health = entity.getHealth();
     
                        p.sendMessage("test4");
                        p.setLevel(health);
                    }
                }
            }
        }
    }
    
     
  2. Offline

    chasechocolate

    Did you register your events?
     
  3. I'm pretty sure I did, I'll double check, but I usually copy and paste my onEnable and other common bits from older projects, so I imagine I did :L
    I'll make sure anyway.

    Edit: Ok I'll go shoot myself, I forgot to register my events -.- Thanks for pointing out my dumbness xD
     
Thread Status:
Not open for further replies.

Share This Page