#entityjs questions about spawn control
19 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
oh and is this the right way to remove completely a mob from spawning? event.removeSpawn('minecraft:zombie');
anyone
do you have probejs?
while not all methods are documented on the wiki page they are documented in probejs typings when hovering over the method
as for this you are close, you need to specify the list of biome ids/biome tags in the 2nd argument js event.removeSpawn("zombie", ["minecraft:plains", "#minecraft:overworld"])
as for the spawn rules youll need to add a spawn predicate using the startup event there is an example of the 3 types of spawning predicates you can use, i suggest going for the "or" predicate```js
//spawnPlacement Startup Script
EntityJSEvents.spawnPlacement(event => {
// Add an "and" predicate: Only allow drowned to spawn above y level 44
event.and('minecraft:drowned', (entitypredicate, levelaccessor, spawntype, blockpos, randomsource) => {
return blockpos.y > 44;
});
// Add an "or" predicate: Allow enderman to spawn outside the End dimension
event.or('minecraft:enderman', (entitypredicate, levelaccessor, spawntype, blockpos, randomsource) => {
return levelaccessor.level.dimension != 'minecraft:the_end';
});
// Replace spawn rules: Allow blaze spawns in the Overworld
event.replace('minecraft:blaze', 'no_restrictions', 'world_surface', (entitypredicate, levelaccessor, spawntype, blockpos, randomsource) => {
return levelaccessor.level.dimension == 'minecraft:overworld';
});
});```
something like this, getting the block from the levelaccessor.level and the blockpos
event.or('minecraft:zombie', (entitypredicate, levelaccessor, spawntype, blockpos, randomsource) => {
// example of allowing to spawn if the light level is over 7
return levelaccessor.level.getBlock(blockpos).light > 7
});```
can i also do that thing of defining a variable that contains entity ids and then put the variable in event.or()?
sure
Utils.getRegistryIds("entity_type").forEach(type =>{
event.or(type, () => {})
})
i suggest putting it inside the event handler like this if you want to do that
assuming this is what you mean
i meant something like let UNDEAD = [all the ids] before the event
oh, yeah you can do that too in the same way
which in that case would be js UNDEAD.forEach(id => {})
so
whats the difference between let and const
in javascript const represents a variable that cannot be reassigned where let will allow reassignment of that variable