setTarget() to Block

Discussion in 'Plugin Development' started by spoothie, Jul 26, 2011.

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


    I wanted to make a wolf running to a specific block in the world. Then I figured out, that setTarget() only works with entites. So is it possible (in any way) to set the target of a wolf to a block instead of an entity? Or is there another possibility of doing this?

  2. Offline


    I have no idea whether this would work or not, but maybe you could spawn an entity, set the target, then immediatly remove the entity. I'm not sure if it would still 'target' the entity after it was removed, however.
  3. Offline


    Possibly create a new Entity object and set it's location to the block you want it to target?
  4. Offline


    Okay, thank you. I'm still a noob at coding, would it be something like this?
    Entity arrow = new Entity(args);
    I think one of the arguments would be the location of the entity, right?
    Can I replace Entity with any possible entity, like Arrow?
    Or do I have to use somethink like spawnArrow() ?
  5. Offline


    1. void wolfMoveTo(Wolf wolf, int x, int y, int z) {
    2. ((org.bukkit.craftbukkit.entity.CraftWolf)wolf).getHandle().setPathEntity(new net.minecraft.server.PathEntity(new net.minecraft.server.PathPoint[] {new net.minecraft.server.PathPoint(x, y, z)}));
    3. }

    Needs craftbukkit.jar.
  6. Offline


    you could set yaw in location
  7. Offline


    Thank you guys, but now I have another problem:
    I want a user to be able to ride a wolf by rightclicking it with a saddle, that already works. Then I want to make it possible to (kind of) controle the wolf. I want to get the user's vehicle (wolf) with following code:
    net.minecraft.server.Entity wolf = ((CraftPlayer)player).getHandle().vehicle;
    But of course, I can't cast net.minecraft.server.Entity to org.bukkit.entity.Wolf. Does anyone have an idea how I can access the user's wolf?
  8. Offline


    another set of brackets is required like so:
    net.minecraft.server.Entity wolf = ((CraftPlayer)player).getHandle().vehicle;
    CraftWolf craftWolf = (CraftWolf)wolf; 
  9. Offline


    net.minecraft.server.Entity wolf = ((CraftPlayer)player).getHandle().vehicle;
    CraftWolf craftWolf = (CraftWolf)wolf.getBukkitEntity();
Thread Status:
Not open for further replies.

Share This Page