Setting player position to NaN causes a crash/hang and corrupts world
bcodegard opened this issue ยท 1 comments
Minecraft Version
1.18.2
KubeJS Version
1802.5.2-build.405
Rhino Version
1802.1.10-build.147
Architectury Version
4.4.59
Forge/Fabric Version
Forge 40.1.0
Describe your issue
NaN is allowed to be passed to functions which expect floats, including player data such as position and health. I have tested PlayerJS.setPositionAndRotation, EntityJS.setX, EntityJS.setY, EntityJS.setZ
When any player position (x y or z) is set to NaN, the game crashes/hangs/disconnects and the world cannot be reopened without editing the save data externally.
NaN is caught when passed to rotation (pitch, yaw) values, however. It also doesn't appear to cause crashes or corruption for motion data. Additionally, other bad behavior results when passing NaN to other functions. Setting a player's health to NaN will lock them in a state where they cannot die but also cannot perform most interactions.
I have recreated the issue with only Forge, KubeJS, Rhino, and Architectury installed.
The following script will corrupt the world when the player holds an arrow in their mainhand. I have not been able to consistently get it to crash the game, but it does consistently either crash, hang, or disconnect. The world is then not loadable, with "invalid player data" being reported.
console.info("Warning: this script will crash and corrupt your world if you hold an arrow in your mainhand");
onEvent('player.tick', event => {
if (!event.server) {
return;
}
var player = event.player;
var main_hand_id = player.getMainHandItem().getId();
if (main_hand_id == "minecraft:arrow") {
// this causes a hang and corrupts the world
player.setPositionAndRotation(NaN,NaN,NaN,NaN,NaN);
// this does not cause corruption
player.setMotion(NaN,0.0,0.0);
// this does not cause corruption
player.setPositionAndRotation(0,128,0,NaN,NaN);
}
})
The attached log results from making a new world, activating the bug (which kicked me out to the server list), then attempting to load the world again.
Crash report/logs
No response