Spawn entities at server start


Hi i try to spawn “shop keeper” entities at server start.
The problem is they dont get spawned, or despawn immediately. i cant see them.
If i spawn them with a command it works.
If i spawn them with the ClientConnectionEvent.Join it also works.

My code looks like this:


Well if I had to guess, I would recommend trying on world load, it game started or something. Have you checked if the world is actually fully loaded at that stage?


The entity doesnt spawn. If i try to get the UUID of the entity in the world, right after i spawned it, its return Empty


Again, I believe that the world had not yet loaded, therefore the entire can’t spawn… try using the SERVER_STARTED event. That event guarantees that the server is fully initialized and that all worlds are loaded.


Im already using GameStartedServerEvent if we speak of the same one.


Its solved, i had to load the chunk before spawning the Entity


Sorry, my bad… I was running on way to little sleep, and somehow totally misread your post.