Fake Player knockback on death is applied at respawn
James103 opened this issue · 2 comments
As of Carpet mod 1.4.45, when you kill a fake player using an attack that deals knockback, the knockback is applied when the fake player respawns. This causes /player ... spawn at x y z
to end up positioning the fake player 2-6 blocks away, depending on the knockback dealt.
I would suggest that either:
- The fake player stays online for 20 ticks after death (same as real players), during which the knockback is applied.
/player ... spawn at x y z
should cancel the fake player's momentum on respawn.
This is caused by the Motion tag saved into the fake player's data being the motion vector with the knockback applied instead of without, for example [0.7, 0.4, 0.0] with knockback, [0.0, ~-0.1, 0.0] without knockback.
Modlist (MC 1.17.1):
Mods:
[✔️] advancementinfo-1.17.1-fabric0.36.1-1.2.1
[✔️] carpet-extra-1.17.1-1.4.43
[✔️] fabric-api-0.37.2+1.17
[✔️] fabric-carpet-1.17.1-1.4.45+v210811
[✔️] itemscroller-fabric-1.17.1-0.15.0-dev.20210707.005506
[✔️] litematica-fabric-1.17.1-0.0.0-dev.20210713.103711
[✔️] malilib-fabric-1.17.1-0.10.0-dev.24
[✔️] minihud-fabric-1.17.1-0.19.0-dev.20210707.150016
[✔️] notenoughcrashes-3.4.0+1.17-fabric
[✔️] tweakeroo-fabric-1.17.1-0.10.0-dev.20210710.155746
It would be instructive to find out what happens in the following cases:
- Real player logging in, then being killed, then logging back in (as control to check that it's not just vanilla bug)
- Real player logging in, then being killed, then spawned back in using /player
- Fake player spawned using /player, then being killed, then really logging in
I will do these tests and then report results.
Results:
Bug only occurs when fake player is killed with knockback, and then spawned back in as a fake player. In any other case, presumable client anti-cheat or smth kicks in and tells server the previous motion, and the player doesn't experience weirdness.
I can think of 2 solutions:
- Just delete all the fake player's momentum when spawning in
- Figure out some way to make death last 20 ticks longer like James said to mitigate issue.
IMO first solution sounds easier to implement, tho second sounds less intrusive.
Edit:
I somehow didn't notice that these two were the solutions which James proposed in the title of the issue, and I now feel more than a little silly for restating what has already been said. However, I think there are more potential solutions, and do not know which of them is better.