Need some entity help.

Discussion in 'Plugin Development' started by ScottieD, Mar 1, 2012.

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

    ScottieD

    How would I be able to know what an entity is from getNearbyEntities? Like for a slime? .getName()? Also how could i set the given entity on fire?

    Any help would be appreciated.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  2. Offline

    Feed_Dante

    Entity.getType() returns EntityType

    http://jd.bukkit.org/apidocs/org/bukkit/entity/Entity.html#getType()
    http://jd.bukkit.org/apidocs/org/bukkit/entity/EntityType.html
    Code:
    for (Entity e : getNearbyEntities())
    {
        if (e.getType() == EntityType.SLIME)
        {
            //stuff
        }
     
    OR
     
        switch (e.getType())
        {
            case SLIME:
                //stuff
                break;
            case CREEPER:
                //stuff
                break;
        }
    }

    For setting it on fire just use setFireTicks()

    http://jd.bukkit.org/apidocs/org/bukkit/entity/Entity.html#setFireTicks(int)
    "Sets the entity's current fire ticks (ticks before the entity stops being on fire)."
     
  3. Offline

    ScottieD

    I had code similar to that, just iterated by for loop. When the command is entered in the server, It said an internal error had occurred. Even your code does not work for some odd reason,

    EDIT:
    After trial and error, this code seems to break the plugin:
    Code:
    for (Entity e : player.getNearbyEntities(50d,50d,50d)) {
                    //if (e.getType() == EntityType.SLIME) {
                    if(true){
                        e.setFireTicks(1000);
                    }
                }
    
    It works fine without the code. Lol

    .getType() Doesnt seem to work at all...

    Im going to create a new thread for the new problem.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
Thread Status:
Not open for further replies.

Share This Page