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

vehicle velocity desync #130

Open
imsteamworks opened this issue Feb 4, 2024 · 0 comments
Open

vehicle velocity desync #130

imsteamworks opened this issue Feb 4, 2024 · 0 comments

Comments

@imsteamworks
Copy link

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));
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant