#entityjs questions about spawn control

19 messages · Page 1 of 1 (latest)

strange herald
#

event.addSpawn('kubejs:sasuke', ['#minecraft:is_overworld'], 20, 3, 5);
in this wiki example, what do those three numbers mean?
and how do i add spawn rules based on light levels?

young cosmosBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

strange herald
#

oh and is this the right way to remove completely a mob from spawning? event.removeSpawn('minecraft:zombie');

strange herald
#

anyone

tepid dagger
#

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

tepid dagger
#

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
});```
strange herald
tepid dagger
#

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

strange herald
tepid dagger
#

oh, yeah you can do that too in the same way

#

which in that case would be js UNDEAD.forEach(id => {})

#

so

fickle trailBOT
strange herald
#

whats the difference between let and const

tepid dagger
#

in javascript const represents a variable that cannot be reassigned where let will allow reassignment of that variable