#i need to make Vehicle Using a horse system

1 messages · Page 1 of 1 (latest)

fathom solar
#

in my event i add

@EventHandler(priority = EventPriority.NORMAL)
    public void onDataPacketReceiveEvent(DataPacketReceiveEvent event) {
        Player player = event.getPlayer();
        DataPacket packet = event.getPacket();
        float playerBaseOffset = 1.62f;
        if (player instanceof Player && player.isConnected()) {
            PlayerSession session = PlayerSession.getSession(player);
            if (packet instanceof PlayerAuthInputPacket pk) {
                if (player.getRiding() != null) {
                    System.out.println(pk.motion);
                    if (player.riding instanceof VehicleBase vehicle) {
                        Vector3 clientPosition = pk.position.asVector3().subtract(0, playerBaseOffset + vehicle.getHeight(), 0);
                        float yaw = pk.yaw % 360;
                        float pitch = pk.pitch % 360;
                        float headYaw = pk.headYaw % 360;
                        if (headYaw < 0) {
                            headYaw += 360;
                        }
                        if (yaw < 0) {
                            yaw += 360;
                        }
                        Location clientLoc = Location.fromObject(clientPosition, player.level, yaw, pitch, headYaw);
                        if (check(clientLoc, player)) {
                            System.out.println("run");
                            vehicle.onInput(clientLoc.add(0, vehicle.getHeight(), 0));
                            Location playerLoc = clientLoc.add(0, playerBaseOffset + vehicle.getHeight(), 0);
                            session.playerHandle.handleMovement(playerLoc);
                        }
                    }
                }
            }
        }
    }
#

this my VehicleBase