How do I make this fake player move?

Discussion in 'Plugin Development' started by TheMrGong, Jul 8, 2014.

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

    TheMrGong

    Please help with this:

    Main class:
    Code:java
    1. package com.gong.main;
    2.  
    3. import java.lang.reflect.InvocationTargetException;
    4. import java.util.UUID;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.PluginManager;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12. import org.bukkit.util.Vector;
    13.  
    14. import com.comphenix.protocol.ProtocolLibrary;
    15. import com.comphenix.protocol.ProtocolManager;
    16. import com.comphenix.protocol.wrappers.WrappedDataWatcher;
    17.  
    18. public class Main extends JavaPlugin {
    19. public static PluginManager pm = Bukkit.getPluginManager();
    20. @Override
    21. public void onEnable()
    22. {
    23.  
    24. }
    25.  
    26. @Override
    27. public void onDisable()
    28. {
    29.  
    30. }
    31.  
    32. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
    33. {
    34. if(label.equalsIgnoreCase("test"))
    35. {
    36. Player player = (Player) sender;
    37. ProtocolManager manager = ProtocolLibrary.getProtocolManager();
    38. WrapperPlayServerNamedEntitySpawn spawned = new WrapperPlayServerNamedEntitySpawn();
    39.  
    40. spawned.setEntityID(4507022);
    41. spawned.setPosition(player.getLocation().toVector());
    42. spawned.setPlayerName("andy316619");
    43. spawned.setPlayerUUID(UUID.randomUUID().toString());
    44.  
    45. spawned.setYaw(player.getLocation().getYaw());
    46. Bukkit.broadcastMessage("Yaw: "+spawned.getYaw());
    47. spawned.setPitch(player.getLocation().getPitch());
    48. Bukkit.broadcastMessage("Pitch: "+spawned.getPitch());
    49.  
    50. WrappedDataWatcher watcher = new WrappedDataWatcher();
    51. watcher.setObject(0, (byte) 0);
    52. watcher.setObject(1, (short) 300);
    53. watcher.setObject(8, (byte) 6);
    54. spawned.setMetadata(watcher);
    55.  
    56. try {
    57. manager.sendServerPacket(player, spawned.getHandle());
    58. }
    59. return true;
    60. }
    61. return true;
    62. }
    63. }
    64.  

    I want to move the player around but I want it to move to the location smoothly with a walking animation and such. Also how would I give it armor?
    And for some reason the head doesn't want to turn left/right it just looks into a direction when spawns and wont change its yaw.
     
  2. Offline

    intronate67

    You should run a for loop until the npcs location is at the targets location and if it has moved make it run again.
     
  3. Offline

    TheMrGong

    How would I make an AI to get to the target location? Has anyone made a public AI for doing that such as:
    public void moveTo(WrapperPlayServerNamedEntitySpawn p, Location to);

    intronate67 ?

    Bump! Someone help

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. Offline

    LordVakar

    TheMrGong
    Well instead of your own classes, you could always use NPCFactory.
    Otherwise, hm, I'll have to research it a bit.
     
  5. Offline

    TheMrGong

  6. Offline

    intronate67

    TheMrGong Go into the resources in the plugin development section on the forums, there is a post by the developer explaining it.
     
Thread Status:
Not open for further replies.

Share This Page