Jumper251 / AdvancedReplay

Minecraft plugin to record players on your server
GNU General Public License v3.0
141 stars 62 forks source link

Entity speed movement #180

Open PedroMPagani opened 1 month ago

PedroMPagani commented 1 month ago

Any ideas on how to properly kind of adjust the entity movement? I was testing with pearls, and I noticed that the client seem to follow the velocity movement mainly, so even if you don't send a teleport or a relative move, it seems that the client processes the movement fully entirely based on the Velocity, but the client ticks per second.. so the velocity acts that way, if you don't set a velocity, the pearl stands still, but then it will also not move, I wonder if there's a way to implement a relative movement here, I assume the velocity determines the adjustment of the entity position every tick or so, and then kind of "relative move" or so, any ideas?

Jumper251 commented 1 month ago

I'm not sure I understand, are you trying to spawn and move pearls with packets and that's not working?

PedroMPagani commented 1 month ago

The 0.5x speeds < for entities , or higher as well, anything else than the default

Jumper251 commented 1 month ago

Not sure if there is a good way to do this, it looks really bugged on hypixel replay. Teleporting is the only thing I can think of.

PedroMPagani commented 1 month ago

what I thoguht about was we can split the target movement into pieces for example, a normal tick speed for the lcient-side velocity is 20, and the consuming of this will be done in a 20 tick basis, if we can have the entity move in lets say, 40 ticks(25ms), but move slower, that means the entity will take "2x" longer to get to the destination.

Jumper251 commented 1 month ago

How would you split the movement into pieces, by sending multiple teleports or velocity updates?

PedroMPagani commented 1 month ago

NO velocity because the client uses velocity to generate movement, you'd need to have the moving part totally server-side handled really

PedroMPagani commented 1 month ago

According to the docs, the entity movement is related to 1/8000th:

Velocity is in units of 1/8000 of a block per server tick (50ms); for example, -1343 would move (-1343 / 8000) = −0.167875 blocks per tick (or −3.3575 blocks per second).

Basically, the idea is to not share any velocity packets, and also when slwoing down, to not play normal entity movements (meaning we don't share the packets - for one single reason - they're on a 20 tick basis) Basically, what you'd have instead is a entity tracker kind of class that will add up to the entity location the velocity increase as if the entity is moving, for example, speed 1x, the entity would move -0.167875 blocks per tick, but if you want let's say 0.5x speed, the same entity movement would act in a 40 tick basis instead of normal 20 TPS, and the movement that the entity does, per tick, is "half", now the 0.25x obviously, same attitude on the velocity as well.

This is the basic idea, so for example, if the player is at the block x=1, z=1, on tick 20, but he was at x=0,z=0, on tick 0, for example, per tick basis (not saying this is exactly what happened), he would've moved 1/20th of the next location target, basically, thats the basic concept of slowing down entity movement, you get the next step and you split it yk. basically int steps = 1/speed; 1/0.25 = 4 1/0.5 = 2, and then you have to "half" the movements basically

Jumper251 commented 1 month ago

There's definitely a chance to get something like this to work, but I'm still a bit skeptical about how good it would look on the client side.