Setting new direction for creatures to go in?

Discussion in 'Plugin Development' started by Flash619, May 6, 2012.

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

    Flash619

    I was tinkering with the idea of a plugin today, and was wondering if anyone knew of a javadoc that lead to setting a new target position for creatures/mobs in mine craft. Preferably through a x/y/z coordinate.

    I'm not sure if it was even possible but I spent a while looking through documentation on the bukkit api and was wondering if anyone else knew of a way, or maybe another rout to go through getting the desired result.

    Many thanks in advance!

    ~Flash619
     
  2. Offline

    Iron_Crystal

    There has been several recent threads with long discussions about how to do it, and I would suggest taking a look at those.
     
  3. Offline

    CorrieKay

    as a reference, here is my thread, and the other thread i was a part of!

    as a quick and dirty,

    Code:
    Mob mob; //"Mob" needs to be the type of creature you wish to control
    Location location; //set your location
    EntityCreature ec = ((CraftCreature)mob).getHandle();
    Navigation nav = ec.al();
    nav.a(location.getX(),location.getY(),location.getZ(),float);
    
    float is their speed. 0.3f-0.4f is a decent speed for wolves, for reference, lest you get stupidly fast mobs

    Note, that some mobs dont use this method. If they dont work, (for instance, spiders, cave spiders, and zombie pigmen wont use this method) try this:

    Code:
    Mob mob; //again, "Mob" needs to be a type of creature you wish to control
    Block to = yourLocation.getBlock(); //block location they need to travel to.
    EntityCreature ec = ((CraftCreature)mob).getHandle();
    PathEntity pf = ((CraftWorld)to.getWorld()).getHandle().a(ec, to.getX(), to.getY(), to.getZ(), 16.0f, true, false, false, true);
    ec.setPathEntity(pf);
    
    This is what ive found out myself so far, with the help of the other guys in these threads :3
     
    hammale, Borch and Iron_Crystal like this.
  4. Offline

    Flash619

    Thank you for your tremendous help! :)

    Will do.
     
  5. Offline

    Splated

    I'm trying to use this code to ride a Sheep like a pig with the carrot on a stick.




    Code:
       @EventHandler (priority = EventPriority.LOW)
     
            public void onPlayerInteract(PlayerInteractEvent e){ 
             
              if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
                  Player player = e.getPlayer();
                 
                  if(player.getItemInHand().getType()==Material.CARROT_STICK){
                     
                 
                      Entity car = player.getVehicle();
                     
                      if (car == null) return;
           
     
                          Entity mob = car; //again, "Mob" needs to be a type of creature you wish to control
                          Block to = e.getClickedBlock(); //block location they need to travel to.
                          EntityCreature ec = ((CraftCreature)mob).getHandle();
                          PathEntity pf = ((CraftWorld)to.getWorld()).getHandle().a(ec, to.getX(), to.getY(), to.getZ(), 16.0f, true, false, false, true);
                          ec.setPathEntity(pf);
                         
     
                         
                      }                     
                  }                 
                }
            }
       
        

    Eclipse is giving me errors on
    CraftCreature
    CraftWorld

    im not sure how to fix it or make it work.

    is there a better way to ride a sheep and steer it with a carrot on a stick?
     
  6. Offline

    Milkywayz

    You need to import the CraftBukkit jar when working with CB code. The same goes for working with net.minecraft.server (NMS) code, you need to import the jar.
     
  7. Offline

    Splated

    I think I found it
     
Thread Status:
Not open for further replies.

Share This Page