KubeJS (Old)

KubeJS (Old)

3M Downloads

player's DeltaMovement has changed but will not work.

YumisLink opened this issue ยท 3 comments

commented

Minecraft Version

1.20.1

KubeJS Version

kubejs-forge-2001.6.4-build.138

Rhino Version

rhino-forge-2001.2.2-build.18

Architectury Version

architectury-9.2.14-forge

Forge/Fabric Version

forge47.2.32

Describe your issue

i use this code and i can found that delta movement was changed but player has no any speed change.
but in the same code to other entity who isnot player ,the entity will change it's speed.

    player.tell(player.getDeltaMovement());
    player.setDeltaMovement(player.getDeltaMovement().multiply(2,5,2))
    player.tell(player.getDeltaMovement());

image

Crash report/logs

No response

commented

Player delta movement is controlled entirely client side, whilst other entities use server side.
If you wish to force particular motion onto the player you need to make sure to to do player.markHurt() to force the movement to sync.

However if all you are after is a movement speed multiplier/addition you can use the helper methods provided by KubeJS to add attribute modifiers.
player.setMovementSpeedAddition(2), player.setTotalMovementSpeedMultplier(2), player.setDefaultMovementSpeedMultiplier(2). The difference between total an default multipliers is that total is applied on top of existing effects like speed, whereas default is just a set percent of the default speed of the player.

commented

thanks, now i write the code in client_script the player movement are changed.

commented

i think u need this:


let ClientboundSetEntityMotionPacket = Java.loadClass('net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket');
....
if(entity.isPlayer()){
            entity.connection.send(new ClientboundSetEntityMotionPacket(entity));
       }