Files
FearFactory/1.20.1-FearFactoryTest/minecraft/kubejs/server_scripts/spawnrestrict.js

56 lines
1.7 KiB
JavaScript
Raw Normal View History

// priority: 0
/*
// Visit the wiki for more info - https://kubejs.com/
EntityEvents.entityCheckSpawn(event => {
const { entity, level, pos, spawnReason } = event;
// Only apply restrictions to natural spawns
if (spawnReason !== 'natural') return;
const spawnRules = {
'minecraft:creeper': {
dimensions: ['minecraft:the_nether'],
blockWhitelist: ['minecraft:netherrack'],
minLight: 0,
maxLight: 14,
timeRange: [0, 24000] // Night
},
'minecraft:enderman': {
dimensions: ['minecraft:overworld'],
blockWhitelist: ['minecraft:grass_block'],
minLight: 0,
maxLight: 7,
timeRange: [12000, 24000] // Late dusk/night
}
};
const rule = spawnRules[entity.type];
if (!rule) return; // No restrictions
const dimMatch = rule.dimensions.includes(level.dimension);
const blockBelow = level.getBlock(pos.down()).id;
const blockMatch = rule.blockWhitelist.includes(blockBelow);
const light = level.getRawBrightness(pos);
const lightMatch = light >= rule.minLight && light <= rule.maxLight;
const timeOfDay = level.dayTime % 24000;
const timeMatch = timeOfDay >= rule.timeRange[0] && timeOfDay <= rule.timeRange[1];
if (!(dimMatch && blockMatch && lightMatch && timeMatch)) {
event.cancel();
}
});
EntityEvents.removeSpawn(event => {
event.remove('minecraft:overworld', 'minecraft:creeper');
event.remove('minecraft:the_end', 'minecraft:enderman');
}); GPT GARBAGE
*/
/*
@silytonta
Is there a way for me to make mobs spawn in a dimension/biome that they usually dont?
@dob3a
yea, u can use "entity.block.biomeId" to get their current biome, and u can use "entity.level.name" to get their current dimension.
sry for late reply i didnt see the notify*/