satoshinm / WebSandboxMC

Bukkit plugin providing a web-based interface with an interactive WebGL 3D preview or glimpse of your server 🕷⏳📦 ⛺
https://www.spigotmc.org/resources/websandboxmc.39415/
MIT License
19 stars 5 forks source link

Human entities or NPCs (such as GlowNPC on Glowstone or human on Sponge) #13

Open satoshinm opened 7 years ago

satoshinm commented 7 years ago

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

Momo - Today at 4:16 AM For NPC's, you can refer to this plugin: https://github.com/DenAbr/GlowNPC. We have a custom entity registry for such cases, but you will have to use Glowstone as your dependency (not Glowkit/Spigot/Bukkit API)

...

Momo - Today at 6:00 AM Thats what GlowNPC does iirc But its much simpler to do with Glowstone Than with NMS

but this may cause incompatibilities with other Bukkit implementations, since it isn't Bukkit API? So maybe not worth it.

mastercoms commented 7 years ago

You can use reflection. Or, we can add player spawn functionality to world.spawn to automatically fake players.

satoshinm commented 7 years ago

Glowstone allowing spawning fake players (or at least HumanEntity) with world.spawn would be great 👍

satoshinm commented 7 years ago

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).

satoshinm commented 7 years ago

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

satoshinm commented 7 years ago

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.

mastercoms commented 7 years ago

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.