Solved Damage 'vehicle' entity

Discussion in 'Plugin Development' started by xDeeKay, Aug 5, 2015.

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

    xDeeKay

    I'm using an EntityDamageByEntityEvent and I have a slime riding a creeper. Is there a way I can take the damage dealt to the slime and apply it to the creeper? I've been looking around and can't seem to find a way to do so.

    Cheers.
     
  2. Offline

    mine-care

    @xDeeKay
    In the body of your listener, check if the vehicle of the slime is a creeper and if it is damage the creeper and cancel the event.
     
  3. Offline

    xDeeKay

    @mine-care I've already done this, but I don't know how to transfer the damage over to the vehicle. I'm either blind or there isn't a way to do so. Any idea?
     
  4. Offline

    Googlelover1234

    @xDeeKay
    #getVehicle() returns an entity, so after you check if it's a creeper, you can do
    Code:
    Creeper creeper = (Creeper) event.getVehicle();
    creeper.damage(event.getDamage());
    #getDamage() returns a double, and it should damage the creeper. If you are making the slime immune to hits, and just want to hurt the creeper, you can cancel the event after you damage the vehicle.
     
    xDeeKay likes this.
  5. Offline

    mine-care

    @xDeeKay @Googlelover1234 or instead of casting to creeper, you can cast to living entity :p that is to make it work with not just creeper as passenger
     
Thread Status:
Not open for further replies.

Share This Page