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

34 lines
1.1 KiB
JavaScript
Raw Normal View History

// priority: 0
// Visit the wiki for more info - https://kubejs.com/
const dimrule = [
['man:managgresive','the_deep_void:deep_void'],
['man:manfromthefog','the_deep_void:deep_void'],
['man:manfromthefogback','the_deep_void:deep_void'],
['man:mftfhang','the_deep_void:deep_void']
];
EntityEvents.spawned(event => {
const { entity } = event;
let type = entity.type;
if (!dimrule.includes(type)) {return;};
const t = findRowWithValue(dimrule, entity.type);
let d = dimrule[t][1];
if(entity.level.name != d) {event.cancel();};
});
function findRowWithValue(matrix, value) {
for (let i = 0; i < matrix.length; i++) {
if (matrix[i].includes(value)) {
return i; // Return the row index if the value is found
};
};
return -1; // Return -1 if the value is not found in any row
};
/*
@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*/