Control mob speed and direction?

Discussion in 'Plugin Development' started by JBoss925, Apr 17, 2014.

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

    JBoss925

    Hey guys, JBoss925 here. I've been playing around with riding entities. I want to make a plugin that will move a sheep you are riding in the direction you are looking when you right click with bread in your hand. Basically, I want to just have the sheep move in the direction a player is looking which is what I'm having trouble with. Here's my code I'm using to try to control the sheep:
    Code:java
    1. public void onPlayerInteract(PlayerInteractEvent e){
    2. if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR){
    3. if(e.getPlayer().getVehicle().getType() == EntityType.SHEEP){
    4. Sheep en = (Sheep) e.getPlayer().getVehicle();
    5. Player p = e.getPlayer();
    6. if(p.getItemInHand().getType() == Material.BREAD){
    7. Vector v = p.getLocation().getDirection().multiply(5);
    8. en.setVelocity(v);
    9. }
    10. }
    11. }
    12. }
     
  2. Offline

    Garris0n

    And the problem is...?
     
Thread Status:
Not open for further replies.

Share This Page