Creation setTarget() - How?

Discussion in 'Plugin Development' started by Raz, Mar 19, 2011.

Thread Status:
Not open for further replies.
  1. So... I'm totally new to JAVA programming so i figured making some small plugins för bukkit is a good way to start. And as I program PHP etc, Programming isn't all new for me. I managed to get a basic plugin up and what im trying to do is:i

    I've got a command:
    /boom [name]

    When i write /boom Raz (For example)
    I wan't a Creeper to spawn next to "Raz" and then set him as target.
    What iv'e got so far is:

    Code:
    int victim = plugin.getServer().getPlayer(sects[1]).getEntityId();
                        Location location = plugin.getServer().getPlayer(sects[1]).getLocation();
                        plugin.getServer().getPlayer(sects[1]).getWorld().spawnCreature(location, CreatureType.CREEPER);                
    So i've got the EntityID of the player (I think)
    I've got the creeper spawned.
    Soo. I need Creature.setTarget(); and i didn't quite figure out exactly how to..
    I was figuring i might need
    Code:
    int creep = plugin.getServer().getPlayer(sects[1]).getWorld().spawnCreature(location, CreatureType.CREEPER).getEntityID();
    But what to do then to actually get him to attack that player is still unknown to me :p

    Would be greatfull for any help!

    Cheers, Raz
     
  2. Offline

    Plague

    First of all, save the player into a variable and do not call plugin.getServer().getPlayer(sects[1]).
    Second of all, I don't really think you need entityid, the object reference should be anough.
    Now as for targetting, I am not on my computer with eclipse, but I think there is a method setTarget() or something in Entity class, search for it in the online javadocs.
     
  3. Offline

    SamOnline

    look out for org.bukkit.entity.Monster.setTarget(LivingEntity)
     
Thread Status:
Not open for further replies.

Share This Page