Started by
artician
on
Topic category: Help with Minecraft modding (Java Edition)
Hi, I just picked up this editor and have watched a couple tutorial videos. The objective I have is really simple but I can't see a way to implement it. I just want to spawn mobs on the surface, but only at night.
I think I can assign the Mob Spawning Type attribute to "creature" to have it spawn on the surface, but I see no way to check for the time of day _before_ the mob spawns.
I can't use the regular "Mob" for Mob Spawning Type because I don't want this mob to spawn underground.
I don't want to have the mob check for the time of day in one of its own behaviors because this would be bad for performance.
Can anyone recommend a solution?
Thank you in advance!
Edited by artician on Sat, 08/08/2020 - 01:30
This can be done using a procedure inside of the living entity creator. Under the spawning section, you can choose to create a procedure for entity spawning condition. Just enter what times you want them to spawn, and you should be good!
Thank you so much for the reply.
I'm trying to implement this now using an If statement with isDayInTheProvidedWorld. My intent is to have it spawn when that returns False, but I don't know what to call in order to have the procedure complete successfully or cancel without spawning anything.
Thank you again for your advice! It was just as simple a solution as I was hoping for.
I'm so close! I can't find my answer in any of the tutorials I've watched. Any advice?
For now I've used "Despawn Entity" in that procedure, but this suggests a really non-performant approach, as I'd not want entities to be spawning en masse just to check the time of day, and then despawning when it returned false.
Going to test it but still hoping for some experienced input.
I got it. Everything is working, but I have one question which I'll pose at the bottom.
For the solution, I wasn't able to use creature spawning rules as I started out to, as they must have a hardcoded rule not to spawn at night, even when their spawn rules say otherwise.
Similar to what Argus had recommended, I just did a bool check on IsDayInTheProvidedWorld, and despawned if true.
I also needed them to only spawn above ground, which was the original inclination for using the Creature spawn rules. To get around this I just followed up the daytime check with another elseIf to check Y spawn position value, and despawning the entity if it were <0. They'll still be able to spawn within mountains, but it's a tradeoff I'm not unhappy with.
My last question: Is there any cleaner way of not spawning an entity than using the Despawn block on its spawn procedure? Or did I do this the right way?
Thanks for the help from the community.