Navigation with EntityPlayer?

Discussion in 'Plugin Development' started by Firefly, Jul 30, 2012.

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

    Firefly

    Hey, I was just playing around with packets and EntityPlayer to get to know some stuff and I was curious as to how I could spawn a new named entity (I did that), but make it move as well.

    I did something of the sort where newPlayer is a global variable.

    Code:
    @EventHandler
    public void onMove(PlayerMoveEvent event) {
        Player p = event.getPlayer();
        Location l = event.getTo();
     
        newPlayer.al().a(l.getX(), l.getY(), l.getZ(), 0.5F);
    }
    This did not move the newly spawned EntityPlayer as expected. On further speculation I think this is because the EntityPlayer doesn't actually "exist" and was spoofed to the player through packets (as how it was spawned).

    So if that's the case (Fairly certain it is), is there a different way of actually spawning a real EntityPlayer that's not packet-spoofed? This would allow to actually move it and control it. Maybe there isn't a way, I don't know. This was all for testing purposes to get to know the methods and limitations of packet sending, native minecraft server stuff.

    Thanks for any insight!

    -Firefly
     
  2. Offline

    r0306

    Firefly
    If it was spawned with packet, the entity doesn't actually exist as a player and cannot be stored as an EntityPlayer (it can but nothing will happen). However, you can still make it move by sending movement look packets (the entity id is needed so you will be better off storing the entity with its unique id).
     
  3. Offline

    Firefly

    That's what I suspected. Do you know of an arm-swing/attack packet as well?
     
  4. Offline

    r0306

  5. Offline

    Deathmarine

    https://github.com/Top-Cat/NPCLib/
    Absolute wealth of knowledge.
     
Thread Status:
Not open for further replies.

Share This Page