Control the direction monsters look

Discussion in 'Plugin Development' started by Phiwa, Nov 20, 2011.

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

    Phiwa

    Hey guys,

    in my plugin DragonTravel I got the problem that I somehow can control the direction the dragon moves but if he moved into a different direction before he simply flies backwards and that looks weird.
    Does anyone have an idea how to "turn" the dragon around?
     
  2. Offline

    Nitnelave

    Maybe change the target block, or setting the velocity? How do you control the dragon's direction?
     
  3. Offline

    ThePageXL

    Assuming you are using something like entity.EnderDragon for your dragon you could try spawning an entity, then use the function damage(int amout, Entity source) source being the dummy entity you spawned in the direction your dragon is supposed to look, hopefully gaining his attention and turning him there, then removing the entity.

    Does setVelocity(Vector velocity) not change the direction an entity is facing? One would assume it does.
     
  4. Offline

    Phiwa

    At the moment the setVelocity-Version to give the dragon the direction he has to move to, but the dragon always tries to get to the position where all dragons want to go (don't know why) and because of that turn there when spawned.
     
  5. Offline

    bleachisback

    Use Pitch and Yaw in the Location constructor.
     
  6. Offline

    Phiwa

    @bleachisback : And how does this influence the movement of the dragon?
     
  7. Offline

    ThePageXL

    Edit: Just get the location from your entity, then change its pitch and yaw (setPitch(float pitch) and setYaw(float yaw)) then teleport your entity to the location.
     
  8. Offline

    bleachisback

    Borch likes this.
  9. Offline

    Phiwa

    I know what pitch and yaw mean, but the dragon will turn around after about 0,001 seconds because he wants to get to this strange location all dragons fly to...

    EDIT: Tried it and it really is the way I thought it would be. The dragon is turned once, but immediately turns around and tries to get to this strange location.
    The only way to prevent him from that would be to teleport him to his current position two/three tiems per second and I won't do that...
     
  10. Offline

    bleachisback

    Hmmmm... that really is weird. It may be because you haven't changed his velocity and he wants to keep going. Try setting his velocity to 0,0,0 or wherever you want him to go.
     
  11. Offline

    Phiwa

    Basically that is what I'm doing. As soon as I right-click with a stick his velocity is set to make the dragon fly to the target-position and he really does, but backwards because he still wants to go to the strange location (don't know why).
    All dragons which aren't controlled by me go there and simply fly around the position. :confused:
     
  12. Offline

    bleachisback

    ...
    I blame Notch


    However this could make for some fun plugins XD


    EDIT: Perhaps you could ask the Spout team if they could fix that for you. That would make it a spout-only plugin tho...
     
  13. Offline

    Borch

    I think this is a special case then and you'll have to wait for the bukkit team to add some support for that behavior.
    Like .setTargetLocation(Location)
     
  14. Offline

    bleachisback

    I think it's a client thing
     
  15. Offline

    ZNickq

    Code:java
    1.  
    2. void DragonMoveTo(EnderDragon wolf, int x, int y, int z) {
    3. CraftEnderDragon a=(org.bukkit.craftbukkit.entity.CraftEnderDragon) wolf;
    4. EntityEnderDragon b=a.getHandle();
    5. b.setPathEntity(new net.minecraft.server.PathEntity(new net.minecraft.server.PathPoint[] {new net.minecraft.server.PathPoint(x, y, z)}));
    6. }
    7.  


    Bukkit is missing the setPathEntity right now (they'll add it for sure :p) but this is how it will look like!
    P.S: you need craftbukkit to compile this!
     
  16. Offline

    Phiwa

    Yes, there is really missing a Path-method!
    I might release an early Alpha with dragons flying backwards during the next days, simply to have something... :p

    As soon as there is a better way to do this I will recode it, thanks to all of you and nag me if I don't recognize the implantation of the path-method. ;)
    I wil finally mage to create this plugin!
     
  17. Offline

    ZNickq

    Code:java
    1.  
    2. void DragonMoveTo(EnderDragon wolf, int x, int y, int z) {
    3. CraftEnderDragon a=(org.bukkit.craftbukkit.entity.CraftEnderDragon) wolf;
    4. EntityEnderDragon b=a.getHandle();
    5. b.setPathEntity(new net.minecraft.server.PathEntity(new net.minecraft.server.PathPoint[] {new net.minecraft.server.PathPoint(x, y, z)}));
    6. }
    7.  
    :D
     
  18. Offline

    Phiwa

    Would be great if it worked that way... ;)
     
  19. Offline

    ZNickq

    it WILL work that way once bukkit updates completely!
     
  20. Offline

    Phiwa

    Really?! GREAT!
    Then gogogo, I'm really looking forward to it!
     
Thread Status:
Not open for further replies.

Share This Page