ponderjs icon indicating copy to clipboard operation
ponderjs copied to clipboard

[Bug] Cannot invoke "net.minecraft.world.level.Level.getLevelData()" because "level" is null when launching

Open BadPig03 opened this issue 5 months ago • 7 comments

Minecraft Version

1.21.1

Mod Version

2.1.1, 2.1.2, 2.1.3

Describe the bug!

If I add any Ponder.registry() calls in client_scripts, Minecraft will crash on startup with the error shown in the image. Image

The client log says "[ERROR] ! java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.Level.getLevelData()" because "level" is null [java.lang.NullPointerException]"

I tried version 2.1.x – only 2.1.0 launches successfully, while ​versions 2.1.1 and later​ crash with the error shown before.

Crash Report

No response

Log

https://pastebin.com/hij8CrLx

Additions and Modifications

Yes

Additions and Modifications Description

No response

Did the issue happen in singleplayer or on a server?

Singleplayer

BadPig03 avatar Jul 25 '25 06:07 BadPig03

Can you test following two things for me.

Scenario A:

  1. Close your instance
  2. Dont use Ponder.registry()
  3. Create a ponder with text
  4. Start your instance so that the lang file is generated
  5. Close your instance
  6. Add Ponder.registry() but don't add anything text related
  7. Start instance, no new lang file should be generated

Does this still crash?

Scenario B:

  1. Close your instance
  2. Only have Ponder.registry() in your scene, nothing about text
  3. Start your instance

Does this crash too?

LLytho avatar Jul 25 '25 08:07 LLytho

I'm happy to help with testing. However, I'm having trouble understanding how to implement the instruction to 'Create a ponder with text without using Ponder.registry()', so I proceeded to test Scenario B first.

I tested Scenario B using the following code: Ponder.registry(event => { event.create('kubejs:bamboo_leaves') }) This implementation does not produce any errors, and Minecraft ​launches and enters the world properly. Additionally, I noticed that an en_us.json file containing only {} was generated under assets\ponderjs_generated\lang.

BadPig03 avatar Jul 25 '25 08:07 BadPig03

Lol im dumb.

Ponder.registry() is the event, yeah then ofc you cannot do A without 😬 oops. I was thinking about scene.world.registry. Okay, can you give me the code you used which triggered the error in first place? As you mentioned it only crashes on startup, so when you add your script while ingame and reload everything, nothing crashed?

LLytho avatar Jul 25 '25 08:07 LLytho

Understood. Here is the original code I used initially:

Ponder.registry(event => { event.create('kubejs:bamboo_leaves').scene('bamboo_leaves', 'Bamboo Leaves', 'kubejs:bamboo_leaves_scene', scene => {
scene.showBasePlate()

    scene.world.setBlocks([2, 1, 2, 2, 5, 2], 'minecraft:bamboo')
    scene.world.modifyBlocks([2, 1, 2, 2, 5, 2], state => state.with('age', '1'), false)
    scene.world.modifyBlock([2, 3, 2], state => state.with('leaves', 'small'), false)
    scene.world.modifyBlocks([2, 4, 2, 2, 5, 2], state => state.with('leaves', 'large'), false)
    scene.world.showSection([2, 1, 2, 2, 5, 2], Direction.DOWN)

    scene.idle(20)
})

})

If I first ​comment out this code, launch the game, then ​uncomment it​ and reload using /kubejs reload client-scripts plus F3+T: ·​The game does not crash​ ·​Ponder content loads normally​ and can be refreshed ​However, after closing the game completely, the solution fails - even though the en_us.json file has already been generated. I have to comment out the code again​ just to get the game to start.

BadPig03 avatar Jul 25 '25 08:07 BadPig03

Can you give me the startup code for your bamboo_leaves too? Or is it just a normal item with a block?

LLytho avatar Jul 25 '25 09:07 LLytho

Here it is. StartupEvents.registry('item', event => { event.create('kubejs:bamboo_leaves').burnTime(50) })

BadPig03 avatar Jul 25 '25 09:07 BadPig03

Yeah it seems to be a problem with the lang generation which getting triggered to early now. Need to find a way around this.

LLytho avatar Aug 01 '25 10:08 LLytho