Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gametest Simulated Players cause many TypeErrors #286

Open
1 task done
ForestOfLight opened this issue Aug 20, 2024 · 0 comments
Open
1 task done

Gametest Simulated Players cause many TypeErrors #286

ForestOfLight opened this issue Aug 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ForestOfLight
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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

  1. Download Canopy & Understudy (both packs work together): https://github.com/ForestOfLight/Canopy, https://github.com/ForestOfLight/Understudy
  2. Add WorldEdit-BE, Canopy, and Understudy to a world.
  3. Give yourself the worldedit tag & CanopyAdmin tag.
  4. Run ./canopy commandPlayer true to enable the ./player command for spawning SimulatedPlayers.
  5. 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

@ForestOfLight ForestOfLight added the bug Something isn't working label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant