KubeJS-Mods / KubeJS

https://kubejs.com
GNU Lesser General Public License v3.0
307 stars 90 forks source link

player's DeltaMovement has changed but will not work. #854

Closed YumisLink closed 3 months ago

YumisLink commented 3 months ago

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

ChiefArug commented 3 months ago

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.

YumisLink commented 3 months ago

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

SGSxingchen commented 3 months ago

i think u need this:


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