Solved Getting nearby entities (players & mobs) and damaging them

Discussion in 'Plugin Development' started by TerraVale, Jan 30, 2013.

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

    TerraVale

    I've been working on a plugin that introduces new PvP/PvE skills into minecraft.
    Thus far, I have a double jump skill, an impale skill, and a feint skill.
    I've decided to also add in combo-based attacks, and currently have it so you can only use impale within a certain time threshold of using your double jump (and also only while travelling downwards in your jump). It's become a very fun and fluid system, but ironically enough I can't figure out how to get entities nearby your player's location and damage them!

    All help is, as always, appreciated :)

    tl;dr version: I need to get all entities within my player's location and damage them.
     
  2. Offline

    Cjreek

    Use player.getNearbyEntities()
     
  3. Offline

    TerraVale

    I got this far, but how do I damage those entities?

    For example:
    Entity nearby = (Entitity) p.getNearbyEntities(5,5,5);
    How do I damage the nearby entities, exactly?
     
  4. Offline

    Cjreek

    Well you should look better at what this method returns. It's actually a list of entities:

    Code:java
    1. List<Entity> nearby = p.getNearbyEntities(5,5,5);
    2. for (Entity tmp: nearby)
    3. if (tmp instanceof Damageable)
    4. tmp.damage(2);
     
  5. Offline

    TerraVale

    Ah, I understand now. It's late, I really can't think properly; thanks for the help :)
     
Thread Status:
Not open for further replies.

Share This Page