#EntityJS - Custom entity fails to spawn

57 messages · Page 1 of 1 (latest)

lean oar
#

It's my first real attempt at making one, and I followed the wiki's example scripts pretty closely
yet doing /summon in game nets nothing

Startup script:

StartupEvents.registry("entity_type", event => {

    event.create("kubejs:boulder", "entityjs:mob")
    .isInvulnerableTo(context => global.isInvulnerableTo(context))
    .setMoveControl(entity => global.setMoveControl(entity))
    .createNavigation(context => global.createNavigation(context))
    .sized(2.5, 2.5)
    .modelSize(1, 1)
    .isPushable(true)
    .fireImmune(true)
    .mobCategory("misc")
    .mobType("undefined")
    .setRenderType("solid")
    .canBreatheUnderwater(true)
    .setWaterSlowDown(0.95)
    .saves(true)
    .setSoundVolume(0.5)
    .setSummonable(true)
    .animationResource(entity =>{
        return "kubejs:animations/entity/boulder.animation.json"
    })
    .addAnimationController("boulderAnimationController", 1, event =>{
        if (event.entity.isMoving()) {
            event.thenLoop("boulder_roll");
        }
        else{
            event.thenLoop("boulder_idle");
        }
        return true;
    })
})

EntityJSEvents.createAttributes(event => {

    event.create("kubejs:boulder", attribute => {
        attribute.add("minecraft:generic.max_health", 8)
        attribute.add("minecraft:generic.knockback_resistance", 0.8)
        attribute.add("minecraft:generic.follow_range", 32)
    })
})
placid steppeBOT
#

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

lean oar
#
/**
 * 
 * @param {Internal.ContextUtils$DamageContext} context 
 * @returns 
 */
global.isInvulnerableTo = context => {
    return context.damageSource.getType() == 'fall';
}

let MoveControl = Java.loadClass("net.minecraft.world.entity.ai.control.MoveControl")
/**
 * 
 * @param {Internal.LivingEntity} entity 
 * @returns 
 */
global.setMoveControl = entity => {
    return new MoveControl(entity, 20, true)
}

/**
 * 
 * @param {Internal.ContextUtils$EntityLevelContext} context 
 * @returns 
 */
global.createNavigation = context => {
    let nav = EntityJSUtils.createAmphibiousPathNavigation(context.entity, context.level)
    nav.setCanFloat(false)
    return nav;
}
#

I've already tried looking for errors or any type of warning but the game boots up just fine, it's just the entity doesn't work
All file paths are set up correctly too afaik

fair trellisBOT
#

Please send your KubeJS startup log. It can be found at /minecraft/logs/kubejs/startup.log.
If you are on 1.18 or 1.16 it will be called startup.txt.
Please send the file directly, without links or snippets.

fierce dawn
#

also give your mc logs

fair trellisBOT
#

Please send your Minecraft log. It can be found at ./logs/latest.log.
Note! Minecraft and KubeJS logs differ. Please send the latest.log, not a KubeJS log.
Please send the file directly, without links or snippets.

lean oar
#

ok

#

lemme get on my pc

fair trellisBOT
#

Paste version of startup.log from @lean oar

lean oar
#

just noticed you're the dev
I'm on 0.6.4 btw

fair trellisBOT
#

Paste version of latest.log from @lean oar

lean oar
#
[23out.2025 01:29:11.775] [modloading-worker-0/INFO] [KubeJS Startup/]: Loaded script startup_scripts:blocks.js in 0.235 s
[23out.2025 01:29:11.817] [modloading-worker-0/INFO] [KubeJS Startup/]: entity_boulder.js#51: Loaded Java class 'net.minecraft.world.entity.ai.control.MoveControl'
[23out.2025 01:29:11.821] [modloading-worker-0/INFO] [KubeJS Startup/]: Loaded script startup_scripts:entity_boulder.js in 0.045 s
[23out.2025 01:29:11.860] [modloading-worker-0/INFO] [KubeJS Startup/]: items_and_mob_effects.js#3: Loaded Java class 'net.minecraft.world.entity.MobCategory'
[23out.2025 01:29:11.860] [modloading-worker-0/INFO] [KubeJS Startup/]: Loaded script startup_scripts:items_and_mob_effects.js in 0.038 s
[23out.2025 01:29:11.864] [modloading-worker-0/INFO] [KubeJS Startup/]: Loaded script startup_scripts:metals.js in 0.002 s
[23out.2025 01:29:11.905] [modloading-worker-0/INFO] [KubeJS Startup/]: Loaded script startup_scripts:new_tool_heads.js in 0.041 s
[23out.2025 01:29:11.913] [modloading-worker-0/INFO] [KubeJS Startup/]: Loaded 5/5 KubeJS startup scripts in 2.274 s with 0 errors and 0 warnings
#

I get no errors, it's weird
In my latest idk if you can tell but I try spawning it in with a spawn egg and it does nothing

#

wait actually

fair trellisBOT
#

Paste version of message.txt from @lean oar

lean oar
#

is this from me using the spawn egg?

fierce dawn
#

this is not on EntityJS, this is actually a Synitra connector issue, Synitra connector allows for using fabric mods in a Forge environment but is very buggy with kubejs, and with EntityJS. What i suggest is to try the script without connector and all those fabric mods and see if it works properly, if it does then this would be something to report to Connector's mod compat github page

#

and if you do make a Connector github ticket then I would link it here so others who may also be trying to use it with kubejs/entityjs see its progress

lean oar
#

I see

#

I'll try

fierce dawn
#

another thing to test is if it will do this with just Connector installed alongside your kubejs mods, because if Connector itself doesnt cause the error then you may be able to do a binary check to find out if it's some other fabric mod causing this. If this is the case then i may or may not be able to take a deeper look into it on my end

lean oar
#

alright, finished removing all the fabric stuff
wml

#

nope, still nothing

fierce dawn
#

is this with just entityjs/kubejs or do you still have your other mods installed

lean oar
#

yeah I have a medium-sized modpack

fierce dawn
#

if you removed synitra connector and it still errors then this is a good sign (means i can possibly fix it on my end)

#

ok good

#

so now test with just entityjs/kubejs and see if it still errors

#

if it doesnt error then do a binary check

fair trellisBOT
#

A binary search is a way of finding a faulty mods/scripts when you have a lot of them, but without having to remove them one-by-one.

The procedure is simple:

  • Take half of the existing mods/scripts and move them out, into another folder.
  • Run the game.
  • Does the issue still exist?
    If YES: Repeat from step 1 with the current things.
    IF NO: Swap out the current things with the ones you moved out, and repeat from step 1.
  • Repeat this process until the problematic mod(s)/script(s) have been found.
fierce dawn
#

and find the culprit conflicting mod

lean oar
#

ok I just checked the latest file again out of curiosity and I think the canChangeDimensionerror is still happening

#

though it might have to do with the Additional Enchantments mod? I'll have to check

lean oar
fair trellisBOT
#

Paste version of message.txt from @lean oar

lean oar
#

yeah I was kind of expecting it'd be something in the scripts themselves that somehow wasn't getting flagged as an error

#

why did it freak out over not being able to get the superclass for the changing dimensions stuff earlier?

fierce dawn
#

ah that explains it, yeah this happens often when it errors and theres some mod trying to catch it themselves and they have no idea whats happening, i suggest using EntityJSUtils.createMoveControl instead of that constructor

return EntityJSUtils.createMoveControl(entity, moveControl => { })```
#

here you even have builder options like moveControl.tick() overrides ect if you need that

lean oar
#

there it is

fierce dawn
#

epic

lean oar
#

thank you for your help so far, this had me stumped for a while lol

lean oar
fierce dawn
#

this function returns a new MoveControl object so you would replace your js return new MoveControl() with this inside of your setMoveControl method in the entity builder

#

it also gives you the builder with some useful overrides if you want to customize the move control, though its not necessary

#

if you dont plan on customizing the move control then just stick with the new MoveControl, its the same thing

lean oar
#

aah

fierce dawn
#

if you're curious why you'd need a custom move control then you can look at this ticket here where we build a custom flying move control to sync with animations ect

#

anyways, besides that if that fixed your issue then you can probably close this

#

and feel free to @ ping me in the future if you need help with anything else

lean oar
#

yeah i'm just gonna do a bit more testing just to be sure, and then close it
thanks again