#EntityJS: How to keep mobs from spawning in water
68 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
@slate apex uwu
what spawn conditions do you have setup if any?
there’s even spawn placements. are you using them?
and note a restart is required to update anything you change after
My script is just
event.addSpawn('eanimod:enhanced_mooshroom', ['minecraft:dark_forest', 'biomesoplenty:mystic_grove', 'biomesoplenty:muskeg', 'biomesoplenty:fungal_jungle', 'regions_unexplored:blackwood_taiga', 'regions_unexplored:fungal_fen'], 12, 2, 6);
})```

I did see there was spawn placements listed on the wiki, but it doesn't mention what any of the things mean
And I didn't know what exactly would prevent water spawns
vanilla placement features for world gen but also works with mobs
a quick solution is removing those placements for ocean and river
after you addSpawn
event.removeSpawn('eanimod:enhanced_mooshroom', ['#minecraft:is_ocean', '#minecraft:is_river']);
i should check if bop still uses these tags for biomes, 1 sec
also note bop has a crashing issue with bop trees growing
and yea bop has updated vanilla tags with it biomes so that will work!
if you have issues with that, consult with owner. i never used entityjs 😅
aware of datapacks though and thought i can try assisting with my experience
like eazy said you might want to try adding a spawn predicate to prevent that,
Startup Script: js EntityJSEvents.spawnPlacement(event => { event.and('eanimod:enhanced_mooshroom', (entitypredicate, levelaccessor, spawntype, blockpos, randomsource) => { return !levelaccessor.level.getBlock(blockpos).down.blockState.liquid(); }); });
keep in mind im assuming the blockstate we want to check is js .getBlock(blockpos).down
but it might just be the actual block at the blockpos so if that doesnt work then do js .getBlock(blockpos)
is that just second case if not working or does removeSpawn not work the way I expected?
it works basically like an &&, there's also an event.or which will work as an || operand basically
so this must be true as well as their default spawn predicate for them to spawn
theres also event.replace but it'd be a pain probably to replicate their whole thing (which you could technically ig)
Thank you for your help, everyone! I fell asleep but will try this all out when I have some free time later today 🙏
So I tried adding this to another mob (because this one especially loves spawning in water, thought it would make testing easier), but its saying I require a nonnull placement type. I tried it with both the suggestions from Liopyu but the error was the same both times. I'm just confused what it means by "nonull"
The startup script currently:
event.and('eanimod:enhanced_moobloom', (entitypredicate, levelaccessor, spawntype, blockpos, randomsource) => {
return !levelaccessor.level.getBlock(blockpos).blockState.liquid();
});
});```
Paste version of startup.log from @tender laurel
My guess is its throwing an error because this mob doesn't have its own spawn placement normally, so I need to possibly register it as if it was a new mob 
alright so you'll have to do event.replace to register one js event.replace('eanimod:enhanced_moobloom', 'no_restrictions', 'world_surface', (entitypredicate, levelaccessor, spawntype, blockpos, randomsource) => { return !levelaccessor.level.getBlock(blockpos).blockState.liquid(); });
Oh excellent, I was on the right track then, but even with your script my game locks up whenever a moobloom would spawn. It doesn't crash, the world just stops loading and if I try to quit it gets stuck on saving. 
Very strange as they were spawning fine before with just AddSpawn server script, they just liked swimming lol
Double checked by removing the startup script entirely and returning to the area that caused the lock up, and it all loads fine again
odd
i mean you can try the generic checkSpawned event and see if that works js EntityEvents.checkSpawn('eanimod:enhanced_moobloom', event => { const {entity} = event if (event.type == "NATURAL" && event.block.down.blockState.liquid()) { event.success(false) } })
Thank you, does this need to be before or after the biomeSpawn script for the mooblooms? Or does it replace it entirely? Looks like there isn't a wiki page for checkSpawn yet so I'm unsure what it does
theres no specific order as long as it's in your server scripts, its supposed to work alongside your biome spawn script to replace the spawnplacement startup script
this basically runs on any entity spawn and you can cancel it with event.success(false)
we can also check the type of spawn with event.type, we're only affecting natural spawns (biome spawns) so spawn types like eggs or spawners wont be affected
and then we just have it detecting if the block below is a liquid or not
this still applies, if they're still spawning then just do entity.block.blockstate instead of entity.block.down
Ahh ok, thank you for explaining. I placed it after the biomeSpawn script just to test it out, and there weren't any lockups or crashes, but I still have some swimmers. The water below them was considered the correct biome at least (lavender fields) 😆 . They are like some tenacious weeds. I will definitely try your suggestion!
Ok, I have tried this one as well as
const {entity} = event
if (event.type == "NATURAL" && event.block.blockState.liquid()) {
event.success(false)
}
})```
But they refuse to stop getting their hooves wet 
they're spawning in water still?
Yuppers
console.log(event.block) for me
also console.log(event.type) for me
EntityEvents.checkSpawn('eanimod:enhanced_moobloom', event => {
const { entity } = event
console.log(event.type)
console.log(event.block)
if (event.type == "NATURAL" && event.block.blockState.liquid()) {
event.success(false)
}
})```
If its not giving any log in the latest.log, should I swap the block.blockState to a block.down.blockState and see if that makes a difference?
I mean to say, it is giving a log, but its not saying anything related to the spawn script
Just a bunch of unrelated render errors 
Please send your KubeJS server log. It can be found at /minecraft/logs/kubejs/server.log.
If you are on 1.18 or 1.16 it will be called server.txt.
Please send the file directly, without links or snippets.
Oh oops
I assumed latest.log because the server.log had barely anything
Paste version of server.log from @tender laurel
Tried both variants now, the server log doesn't change
did you save your file and do /kubejs reload server_scripts?
and did you wait for a new entity to spawn? this only triggers on entity spawning
I closed the game, made the change to the script and saved it, restarted the game. Flew around until I saw a moobloom spawn in water (which is what took me so long), and then sent you the log.
It doesn't seem to be logging at all though
you dont need to restart the game for server scripts, /kubejs reload server_scripts should do
if its still not logging then send the script
is it this word for word?
Sure thing 🫡 Here is the script in its entirety
event.addSpawn('eanimod:enhanced_mooshroom', ['minecraft:dark_forest', 'biomesoplenty:mystic_grove', 'biomesoplenty:muskeg', 'biomesoplenty:fungal_jungle', 'regions_unexplored:blackwood_taiga', 'regions_unexplored:fungal_fen'], 12, 2, 6);
event.addSpawn('eanimod:enhanced_moobloom', ['minecraft:flower_forest', 'minecraft:sunflower_plains', 'minecraft:cherry_grove', 'minecraft:meadow', 'biomesoplenty:field', 'biomesoplenty:lavender_field', 'biomesoplenty:snowblossom_grove', 'biomesoplenty:lush_savanna', 'regions_unexplored:flower_fields', 'regions_unexplored:poppy_fields', 'regions_unexplored:highland_fields', 'regions_unexplored:rocky_meadow'], 12, 2, 6);
})
EntityEvents.checkSpawn('eanimod:enhanced_moobloom', event => {
const { entity } = event
console.log(event.type)
console.log(event.block)
if (event.type == "NATURAL" && event.block.down.blockState.liquid()) {
event.success(false)
}
})```

is it the mooshroom thats spawning or the moobloom because the event is only detecting moobloom rn
mooblooms are the ones spawning in water