Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.4 kB
3
Indexable
Never
        // Get the player's information
        String playerName = event.getPlayer().getName();
        double x = event.getTo().getX();
        double y = event.getTo().getY();
        double z = event.getTo().getZ();
        Vector velocity = event.getPlayer().getVelocity();

        // Calculate speed
        double speed = velocity.length();

        // Calculate friction (negative acceleration)
        double friction = -0.98 * speed;

        // Calculate jump height (vertical movement)
        double jumpHeight = Math.abs(event.getFrom().getY() - event.getTo().getY());

        // Check if the player is swimming in lava
        boolean swimmingInLava = event.getPlayer().getLocation().getBlock().getType().name().contains("LAVA");

        // Check if the player is falling
        boolean falling = !event.getPlayer().isOnGround();

        // Check if the player is flying with an elytra
        boolean elytraFlying = event.getPlayer().isGliding();

        // Check if the player is using elytra rockets
        boolean elytraRocketBoost = event.getPlayer().isGliding() && event.getPlayer().isSprinting();

        // Get player's viewing direction (pitch and yaw)
        float pitch = event.getPlayer().getLocation().getPitch();
        float yaw = event.getPlayer().getLocation().getYaw();

        // Calculate vertical speed and acceleration
        double verticalSpeed = velocity.getY();
        double verticalAcceleration = (verticalSpeed - event.getPlayer().getVelocity().getY()) / event.getPlayer().getFallDistance();

        // Calculate horizontal speed
        double horizontalSpeed = Math.sqrt(velocity.getX() * velocity.getX() + velocity.getZ() * velocity.getZ());

        // Calculate horizontal acceleration
        long currentTimestamp = System.currentTimeMillis();
        long timeInterval = currentTimestamp - lastTimestamp;
        if (timeInterval > 0) {
            double horizontalAcceleration = (horizontalSpeed - lastHorizontalSpeed) / (double) timeInterval;
            getLogger().info(playerName + " horizontal acceleration: " + horizontalAcceleration);
        }
        lastHorizontalSpeed = horizontalSpeed;
        lastTimestamp = currentTimestamp;


        getLogger().info(playerName + " moved to X:" + x + " Y:" + y + " Z:" + z);
        getLogger().info(playerName + " velocity X:" + velocity.getX() + " Y:" + velocity.getY() + " Z:" + velocity.getZ());
        getLogger().info(playerName + " speed: " + speed);
        getLogger().info(playerName + " friction: " + friction);
        getLogger().info(playerName + " jump height: " + jumpHeight);
        getLogger().info(playerName + " pitch (looking up or down): " + pitch);
        getLogger().info(playerName + " yaw (looking left or right): " + yaw);
        getLogger().info(playerName + " swimming in lava: " + swimmingInLava);
        getLogger().info(playerName + " falling: " + falling);
        getLogger().info(playerName + " elytra flying: " + elytraFlying);
        getLogger().info(playerName + " elytra rocket boost: " + elytraRocketBoost);
        getLogger().info(playerName + " vertical speed: " + verticalSpeed);
        getLogger().info(playerName + " vertical acceleration: " + verticalAcceleration);
        getLogger().info(playerName + " horizontal speed: " + horizontalSpeed);