Element-0 / ElementZero

Run windows version of BDS in linux with Mod support
GNU General Public License v3.0
273 stars 51 forks source link

Random crash when spawning mobs #153

Open tomrhollis opened 3 years ago

tomrhollis commented 3 years ago

Environment: Windows Server 2019 Official EZ release based on 1.16.20.03

The crash (screenshot below) has been happening rarely and randomly for a few versions now. It only seems to happen in my spawn area, where I have a script running which removes hostile mobs from existence as soon as they spawn. I'm guessing this is relevant based on the crash dump including something about spawning.

This is the crash message: image

And the part of the script that might be triggering the crash, if it's relevant:

const spawnArea = {xnw: -318, znw: -286, xse: -124, zse: -67, ylo: 63, yhi: 255}; 
const hitList = ["minecraft:creeper", "minecraft:drowned", "minecraft:evocation_illager", "minecraft:husk",
               "minecraft:phantom", "minecraft:pillager", "minecraft:ravager", "minecraft:silverfish",
               "minecraft:slime", "minecraft:stray", "minecraft:vex", "minecraft:vindictor", "minecraft:witch", 
               "minecraft:zombie", "minecraft:zombie_villager", "minecraft:cave_spider", "minecraft:spider", "minecraft:zombie_villager_v2"];

system.listenForEvent("minecraft:entity_created", (eventData) => applyMonsterRules(eventData.data.entity));

function applyMonsterRules(entity) {
    //if the new mob is a monster on the list and is inside the spawn area, remove it from existence
    let loc = (system.getComponent(entity, "minecraft:position")).data;

    if(hitList.includes(entity.__identifier__) && loc.x > spawnArea.xnw && loc.y > spawnArea.ylo && loc.z > spawnArea.znw &&
            loc.x < spawnArea.xse && loc.y < spawnArea.yhi && loc.z < spawnArea.zse) {

        system.destroyEntity(entity);
        return;
    }
}