PlayEffect not working for me... (And how to set entity health too?)

Discussion in 'Plugin Development' started by MOMOTHEREAL, Oct 7, 2013.

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

    MOMOTHEREAL

    Hello,
    what I am trying to do here is that when an entity gets damaged, it creates Redstone Block break particles. Using older posts, I found that:

    Code:java
    1. @EventHandler
    2. public void onEntityDamaged(EntityDamageByEntityEvent event){
    3. Entity ent = event.getEntity();
    4. ent.getWorld().playEffect(ent.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK.getId());
    5. }


    Which doesn't play any effect on my server...
    Any help? :)
     
  2. Offline

    chasechocolate

    Is the event registered and being fired? Add a debug line.
     
  3. Offline

    MOMOTHEREAL

    Heh, simply forgot to register my events :3
    What about if I want to change the health of an entity?
     
  4. Offline

    Sam Falls

    entity.setHealth(health);

    Health is a Double.
     
  5. Offline

    Mathias Eklund

    I'd say this should be marked as solved?
     
  6. Offline

    MOMOTHEREAL

    Actually, setHealth is not part of the Entity class for some reason... it only works on Player class!
    I think that's the case because Boats, PrimedTnt, etc. don't have "health".
     
  7. Offline

    MrSnare

    Boats have health don't they?
     
  8. Offline

    BungeeTheCookie

    MrSnare
    They have durability, I don't think they would have health
    Can't you just give them potions of regeneration with whatever your doings.
     
  9. Offline

    MrSnare

    Oh cool. I always assumed it was health and they lost health from hitting things. Durability makes more sense though
     
  10. Offline

    BungeeTheCookie

    MrSnare
    True, I don't know if it would be set as durability for living entities though.
    Entities count as mobs or primed tnt, boats, etc. so they all have to have the same method for setting entity health or durability
    MOMOTHEREAL
    Try looking through all of the methods and see if you find a solution
     
  11. Offline

    Bammerbom

Thread Status:
Not open for further replies.

Share This Page