Skip to content
This repository was archived by the owner on Feb 24, 2024. It is now read-only.
This repository was archived by the owner on Feb 24, 2024. It is now read-only.

vehicle velocity desync #130

Description

@imsteamworks

Ran into a issue when a entity is moving it's x/z velocity is not being updated properly to show that they are actually moving in said direction.

How to reproduce:
Listen to a vehicle moving (my example was using a task to run every 10 ticks to set the vehicle velocity to a constant by multiplying it), the issue with my example is that my X/Z is equal to 0 regardless of me moving on not.

        MinecraftServer.getSchedulerManager().scheduleTask(() -> {
            for (Player player : MinecraftServer.getConnectionManager().getOnlinePlayers()) {
                Entity vehicle = player.getVehicle();
                if (vehicle == null || !vehicle.getEntityType().equals(EntityType.BOAT))
                    continue;

                Vec boatVec = vehicle.getVelocity();
                System.out.println("ogVec " + boatVec + " (has velocity? " + vehicle.hasVelocity() + ")"); 
                // Velocity (0, yGrav, 0), vehicle velocity state is false aswell.

                Vec multipliedVec = boatVec.withY(0).mul(20);
                vehicle.setVelocity(multipliedVec);
            }
        }, TaskSchedule.immediate(), TaskSchedule.tick(10));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions