Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.4 kB
3
Indexable
Never
    public void onPlayerMove(PlayerMoveEvent event) {
        // 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());

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

        // 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();

        // Log the player's movement variables
        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 + " vertical speed: " + verticalSpeed);
        getLogger().info(playerName + " vertical acceleration: " + verticalAcceleration);
        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);
    }
}