JS Map behaves weirdly with stringified entity UUID
juh9870 opened this issue ยท 1 comments
Minecraft Version
1.18.2
KubeJS Version
kubejs-forge-1802.5.4-build.524.jar
Rhino Version
rhino-forge-1802.1.14-build.204.jar
Architectury Version
architectury-4.5.76-forge.jar
Forge/Fabric Version
40.1.67
Describe your issue
When I try to use stringified entity UUID into a Map and then extract by the very same id, extraction fails. It looks like Map doesn't think that two strings got from the same UUID are the same.
var map = new Map();
// get some entity
var id = entity.id.toString();
console.log(id);
map.set(id, entity);
console.log("Extraction by the same string instance works");
console.log(map.get(id));
console.log("But not by stringifying the same UUID");
console.log(map.get(entity.id.toString()));
console.log("Note how first id string is STRICTLY equals to the new stringified ID");
console.log(entity.id.toString() === id);
I get
[11:43:30] [INFO ] server_scripts:rotation_script.js:22: a6c60018-535b-4b84-a3a6-8bf559ded49c
[11:43:30] [INFO ] server_scripts:rotation_script.js:24: Extraction by the same string instance works
[11:43:30] [INFO ] server_scripts:rotation_script.js:25: Minecart-a6c60018-535b-4b84-a3a6-8bf559ded49c
[11:43:30] [INFO ] server_scripts:rotation_script.js:26: But not by stringifying the same UUID
[11:43:30] [INFO ] server_scripts:rotation_script.js:27: undefined
[11:43:30] [INFO ] server_scripts:rotation_script.js:28: Note how first id string is STRICTLY equals to the new stringified ID
[11:43:30] [INFO ] server_scripts:rotation_script.js:29: true
Crash report/logs
No response