Open satoshinm opened 7 years ago
You can use reflection. Or, we can add player spawn functionality to world.spawn to automatically fake players.
Glowstone allowing spawning fake players (or at least HumanEntity) with world.spawn would be great 👍
I'm thinking now it may be preferable to have "true" fake players, that is, players which are real for most purposes of the server (show up in chat, have a player entity, etc. - to seamlessly integrate web players with other plugins, such as for chat as suggested in comment https://www.spigotmc.org/threads/websandboxmc.232807/#post-2359661), except without the TCP network connection.
It is an interesting consequence of the current design of WebSandboxMC. If I had instead interfaced web players through the MC protocol, then no player faking would be necessary because they would be real as can be. However, by interfacing through the Bukkit API instead, connection/player management has to be handled explicitly. The major upside of Bukkit is it seems to be the most popular and well-supported API of its kind, working on all different versions of different server implementations. not true if built on the protocol instead; WebSandboxMC wouldn't be able to get to its current functional state on top of raw protocol packets without significant engineering effort, and wouldn't be as compatible. Yet, there may be further limitations this plugin hits up against as it progresses further. For example: sound https://github.com/satoshinm/WebSandboxMC/issues/22 - there is a World#playSound API, but no event I could find to receive sound (Bukkit plugin listening for when a sound effect is played, not possible currently? unlike listening to sound effect packets).
Found this, Sponge implemented spawning "human entities" in their API, maybe useful for how Bukkit/Glowkit API could do it: https://github.com/SpongePowered/SpongeAPI/issues/502
Looks like Sponge has finished implementing human entities: https://forums.spongepowered.org/t/how-do-i-make-a-npc-human-entity-face-a-player/19186 - and it supports rotation, probably would be practical to implement in WebSandboxMC, but need https://github.com/satoshinm/WebSandboxMC/issues/51 Sponge support.
https://www.spigotmc.org/threads/lib-npclib-create-fake-players-1-8-1-7-10-1-7-9.48010/
We will be adding something similar to this in a future Glowstone release.
From Glowstone chat, investigate this plugin which shows how to create non-player characters, since world.spawn cannot be used to spawn Player or HumanEntity directly (error: https://gist.github.com/satoshinm/ebc87cdf1d782ba91b893fe24cd8ffd2):
https://github.com/DenAbr/GlowNPC
...
but this may cause incompatibilities with other Bukkit implementations, since it isn't Bukkit API? So maybe not worth it.