You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently developing a Simulated Players BP using the @minecraft/server-gametest module. I've run into this issue trying to use them in conjunction with my other addons.
Whenever the Script API gets a list of the online players, any SimulatedPlayers will be included but undefined. This includes any event that might have a player or entity object. This results in lots of TypeErrors due to the Script API trying to get properties on undefined.
TypeError: cannot not read property 'foo' of undefined
or
Function doesn't exist on object. Etc.
Expected behaviour
The fix for this is not too difficult, just adding a simple undefined check to each getPlayers(), getAllPlayers(), and events where the event has an entity property will do the trick.
Add WorldEdit-BE, Canopy, and Understudy to a world.
Give yourself the worldedit tag & CanopyAdmin tag.
Run ./canopy commandPlayer true to enable the ./player command for spawning SimulatedPlayers.
Run ./player <name> join to spawn a new SimulatedPlayer.
Content logs
[2024-08-20 11:53:13:348 ERROR] [Scripting] TypeError: cannot read property 'dimension' of undefined at isHotbarStashed (server/modules/player_util.js:114)
at (server/index.is: 38)
at (library/classes/eventEmitter. js:60)
at forEach (native)
at emit (library/classes/eventEmitter. js:59)
at (library/Minecraft. js:148)
Minecraft version
1.21.21
Device and operating system
Windows 10
Additional info
No response
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Current behaviour
I'm currently developing a Simulated Players BP using the @minecraft/server-gametest module. I've run into this issue trying to use them in conjunction with my other addons.
Whenever the Script API gets a list of the online players, any SimulatedPlayers will be included but undefined. This includes any event that might have a player or entity object. This results in lots of TypeErrors due to the Script API trying to get properties on undefined.
TypeError: cannot not read property 'foo' of undefined
or
Function doesn't exist on object. Etc.
Expected behaviour
The fix for this is not too difficult, just adding a simple undefined check to each getPlayers(), getAllPlayers(), and events where the event has an entity property will do the trick.
if (!event.entity) return;
Steps to reproduce
worldedit
tag &CanopyAdmin
tag../canopy commandPlayer true
to enable the./player
command for spawning SimulatedPlayers../player <name> join
to spawn a new SimulatedPlayer.Content logs
[2024-08-20 11:53:13:348 ERROR] [Scripting] TypeError: cannot read property 'dimension' of undefined at isHotbarStashed (server/modules/player_util.js:114)
at (server/index.is: 38)
at (library/classes/eventEmitter. js:60)
at forEach (native)
at emit (library/classes/eventEmitter. js:59)
at (library/Minecraft. js:148)
Minecraft version
1.21.21
Device and operating system
Windows 10
Additional info
No response
The text was updated successfully, but these errors were encountered: