[UnSolved] Friendly EnderDragon

Discussion in 'Plugin Development' started by Casier, Jan 19, 2013.

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

    Casier

    Hi guys !

    Here's is my problem: I want to make the EnderDragon nice but "angry" when a player hit him.
    I've try with the folowing code:

    PHP:
    @EventHandler(ignoreCancelled truepriority EventPriority.HIGHEST)
    public 
    void onEntityTarget(EntityTargetLivingEntityEvent e) {
        if(
    e.getEntityType() == EntityType.ENDER_DRAGON) {
            if(
    e.getEntity().getWorld().getName().equalsIgnoreCase("world")){
                if(
    e.getReason() == TargetReason.CLOSEST_PLAYER){
                    
    e.setTarget(null);
                    
    e.setCancelled(true);
                }
            }
        }
    }
    But it's not working.

    So the question is: What's wrong with this code ? And if this is the bad way, which is the right one ?
     
  2. Offline

    Deckerz

    Well did you register the event and use @eventhandler ?
     
  3. Offline

    Casier

    Yep', that wasn't indicated but yes, i registered event with @eventhandler

    Edit: I had it on the first post
     
  4. Offline

    Craftiii4

    Does this work?

    Code:java
    1.  
    2. public void onEntityTarget(EntityTargetLivingEntityEvent e) {
    3.  
    4. if (e.getEntity() instanceof EnderDragon) {
    5.  
    6. if (e.getReason().toString().equals("TARGET_ATTACKED_ENTITY")) {
    7.  
    8. } else {
    9. e.setCancelled(false);
    10. }
    11.  
    12. }
    13.  
    14. }
     
  5. Offline

    Casier

    Not ?
    Code:java
    1. e.setCancelled(true);
     
  6. Offline

    Craftiii4

    oops :p, yep true ^^
     
  7. Offline

    Casier

    It doesn't work :(
    But with the remotte debugging, i saw that the EnderDragon doesn't call the Event (and all the mob). The event was called when experience orb target me. Is the event only for non-living entity ?

    Edit: Only the EnderDragon doesn't call the event.
     
  8. Offline

    ftbastler

    Maybe because the EnderDragon is made out of multiple parts?
     
  9. Offline

    Casier

    So the only possibility is to make enderDragon travel from Point A to a Point B all the time ?

    Edit: Or a fictitious entity ?
     
Thread Status:
Not open for further replies.

Share This Page