Jump to content

Recommended Posts

Posted

I made a packet which send the "Y" velocity to the server.

public boolean handle(Supplier<Context> ctx) {
        ctx.get().enqueueWork(() -> {
            ServerPlayer player = ctx.get().getSender();

            if (player != null) {

                //player.sendSystemMessage(Component.literal(String.valueOf(player.getDeltaMovement())));

                player.getAbilities().flying = false;


                Vec3 vec3 = player.getDeltaMovement();


                player.setDeltaMovement(vec3.x, dy, vec3.z);

                player.hasImpulse = true;

                //player.sendSystemMessage(Component.literal(String.valueOf(player.getDeltaMovement())));
            }

        });
        return true;
    }

Where I trying to set new movement vector (setDeltaMovement) but it is not works.

But the "sendSystemMessage" works perfectly here

Posted (edited)

setDeltaMovement only works on the client. this makes the animations smoother. The reason sendSystemMessage works is because you don’t have to constantly send messages from the server to the client, and a little bit of lag is ok. This is a core minecraft mechanism, but you can send custom packets over to the client to set its deltaMovement. The client has to have a way to receive the packets too.

Edited by Xoroshio

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.