Server/Game Crash, something related to kubejs maybe
TophC7 opened this issue ยท 5 comments
Hi, my server is crashing with some mobs, I'm unsure why. The crash log mentions a ticking entity (spider) and the crash seems to happen when kubejs does something. To me it happened after attacking a bunch of mobs but it might have just happened when the spider spawned. Sorry i know not a lot of info to go on.
Here's the logs:
2025-02-10-1.log.gz
kubejs-server.log
[crash-2025-02-10_04.53.04-server.txt](https://github.com/user-attachments/files/18728373/crash-2025-02-10_04.53.04-server.txt
Try spawning a Desert Cave Spider with a spawn egg or via command and see if that recreates the crash
Yes and no, eventually a spawned spider will crash when it attacks me or I attack it.
But i found WHERE its happening, still no idea why.
I have a startup script with a custom effect, the effects uses pehkui to make you small and change some attributes.
Here is the script:
//credit: based on scripts by Beubeu and Uncandango
//Import Pehkui API
const SCALE_TYPES = Java.loadClass("virtuoel.pehkui.api.ScaleTypes");
StartupEvents.registry("mob_effect", (event) => {
event
.create("copper_fever")
.effectTick((entity, level) => global.shrink(entity, level))
.color(Color.YELLOW)
.beneficial()
.displayName("Copper Fever");
});
global.shrink = (/** @type {Internal.LivingEntity} */ entity, /** @type {number} */ lvl) => {
if (entity.isPlayer()) {
// If effect is active, shrink
let scale = entity.hasEffect("kubejs:copper_fever") ? 0.5 : 1.0;
let jump = entity.hasEffect("kubejs:copper_fever") ? 1.4 : 1.0;
let motion = jump;
let falling = entity.hasEffect("kubejs:copper_fever") ? 0.8 : 1.0;
SCALE_TYPES.BASE.getScaleData(entity).setScale(scale);
SCALE_TYPES.JUMP_HEIGHT.getScaleData(entity).setScale(jump);
SCALE_TYPES.MOTION.getScaleData(entity).setScale(motion);
SCALE_TYPES.FALLING.getScaleData(entity).setScale(falling);
}
};
ForgeEvents.onEvent("net.minecraftforge.event.entity.living.MobEffectEvent$Remove", (event) => {
global.clearEffects(event.entity, event.effectInstance);
});
ForgeEvents.onEvent("net.minecraftforge.event.entity.living.MobEffectEvent$Expired", (event) => {
global.clearEffects(event.entity, event.effectInstance);
});
global.clearEffects = (/** @type {Internal.LivingEntity} */ entity, /** @type {Internal.MobEffectInstance} */ effectInstance) => {
if (effectInstance.effect.descriptionId == "effect.kubejs.copper_fever") {
if (entity.isPlayer()) {
entity.mergeNbt({
"pehkui:scale_data_types": {
"pehkui:base": {
scale: 1.0,
},
"pehkui:jump_height": {
scale: 1.0,
},
"pehkui:motion": {
scale: 1.0,
},
"pehkui:falling": {
scale: 1.0,
},
},
});
}
}
};In line 37 specifically a null error happens, but its only happening with special mob spiders as far as i can tell
and here is the last crash-log
crash-2025-02-10_21.35.34-server.txt
As far as I can tell the problem lies in the script. What happens here is that the desert spider variants tries to remove night vision from the player when it lands a melee attack, and that fires the Forge event for removing a mob effect instance. The mob effect instance parsed in MobEffectEvent.Remove can be null, so a null check in the script should solve this
ForgeEvents.onEvent("net.minecraftforge.event.entity.living.MobEffectEvent$Remove", (event) => {
if (event.effectInstance != null) {
global.clearEffects(event.entity, event.effectInstance);
}
});
something like that