Mob Navigation Help

Discussion in 'Plugin Development' started by iHells, Dec 20, 2019.

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

    iHells

    Hey all,

    So I have a PlayerMoveEvent listener & I am trying to make it so the giant the player is riding (I have checked it is riding a giant, it should be in this case) can be controlled by the player but am unsure on how to do this efficiently.

    This is my code:
    Code:
        @EventHandler
        public void onMove(PlayerMoveEvent e) {
         
            if (main.titan.contains(e.getPlayer())) {
                Player player = e.getPlayer();
                if (player.isInsideVehicle()) {
                 
                    if (player.getVehicle().getType().equals(EntityType.GIANT)) {
                     
                        Giant giant = (Giant) player.getVehicle();
                        giant.getHandle().getNavigation().a(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), 0.3f);
                     
                    } else {
                       System.out.println("Error: "+player+" is not on top of a giant while in titan. Removing them from titan...");
                        main.titan.remove(player);
                    }
                 
                } else {
                    System.out.println("Error: "+player+" is not on top of a giant while in titan. Removing them from titan...");
                    main.titan.remove(player);
                }
             
            }
         
        }
    However this is presenting an error:
    "The method getHandle() is undefined for the type Giant"

    I have tried casting it to ComplexLivingEntity, Entity, and none are working.

    Any help would be appreciated, if you have any questions feel free to ask and I will respond ASAP.

    Thanks.
     
  2. Offline

    KarimAKL

    @iHells Cast Giant to CraftGiant, then use getHandle() on that.
     
  3. Offline

    iHells

    Thanks so much, however, the giant still isnt moving to where the player wants them to move.
     
    Last edited: Dec 21, 2019
  4. Offline

    KarimAKL

    @iHells I haven't worked with this part of NMS before so i can't help you there. Hopefully someone else can help you.
     
Thread Status:
Not open for further replies.

Share This Page