[Bug] Cannot invoke "net.minecraft.world.level.Level.getLevelData()" because "level" is null when launching
BadPig03 opened this issue · 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.

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
Additions and Modifications
Yes
Additions and Modifications Description
No response
Did the issue happen in singleplayer or on a server?
Singleplayer
Can you test following two things for me.
Scenario A:
- Close your instance
- Dont use
Ponder.registry() - Create a ponder with text
- Start your instance so that the lang file is generated
- Close your instance
- Add
Ponder.registry()but don't add anything text related - Start instance, no new lang file should be generated
Does this still crash?
Scenario B:
- Close your instance
- Only have
Ponder.registry()in your scene, nothing about text - Start your instance
Does this crash too?
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.
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?
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.
Can you give me the startup code for your bamboo_leaves too? Or is it just a normal item with a block?
Here it is.
StartupEvents.registry('item', event => { event.create('kubejs:bamboo_leaves').burnTime(50) })