`/reload` fails when a not-existing-variable is imported from a library and then printed during app load
James103 opened this issue ยท 0 comments
As of Carpet mod 1.4.66 for Minecraft 1.18.2, running the command /reload
may fail with An unexpected error occurred trying to execute that command
under the following setup:
- Create a new world with cheats enabled.
- Create a new file in the
scripts
folder namedtest_lib.scl
with the following contents:
global_some_variable = {}
- Create a new file in the
scripts
folder namedtest_app.sc
with the following contents:
import('test_lib', 'global_not_existing_variable');
print(global_not_existing_variable);
- Run
/script load test_app
- Run
/reload
and/or/script load test_app
a few more times. - Notice that the command fails with
An unexpected error occurred trying to execute that command
and the following exception is printed to the game log.
Exception on `/reload` or `/script load test_app`
[16:41:26] [Server thread/ERROR]: Command exception: /script load test_app
java.lang.NullPointerException: Cannot read field "host" because "_c" is null
at carpet.script.Expression.lambda$getOrSetAnyVariable$4(Expression.java:741) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.LazyValue.evalValue(LazyValue.java:21) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.ScriptHost$ModuleData.lambda$new$1(ScriptHost.java:69) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at it.unimi.dsi.fastutil.objects.Object2ObjectMap.lambda$forEach$0(Object2ObjectMap.java:212) ~[fastutil-8.5.6.jar:?]
at it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap$MapEntrySet.fastForEach(Object2ObjectOpenHashMap.java:1051) ~[fastutil-8.5.6.jar:?]
at it.unimi.dsi.fastutil.objects.Object2ObjectMap.forEach(Object2ObjectMap.java:215) ~[fastutil-8.5.6.jar:?]
at carpet.script.ScriptHost$ModuleData.<init>(ScriptHost.java:67) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.ScriptHost.lambda$setupUserHost$8(ScriptHost.java:356) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at java.util.HashMap.forEach(HashMap.java:1421) ~[?:?]
at carpet.script.ScriptHost.setupUserHost(ScriptHost.java:356) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.CarpetScriptHost.setupUserHost(CarpetScriptHost.java:268) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.ScriptHost.retrieveForExecution(ScriptHost.java:347) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.CarpetScriptHost.retrieveForExecution(CarpetScriptHost.java:612) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.CarpetScriptServer.addScriptHost(CarpetScriptServer.java:317) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.commands.ScriptCommand.lambda$register$37(ScriptCommand.java:273) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263) ~[brigadier-1.0.18.jar:?]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177) ~[brigadier-1.0.18.jar:?]
at net.minecraft.class_2170.method_9249(class_2170.java:264) ~[client-intermediary.jar:?]
at net.minecraft.class_3244.method_14370(class_3244.java:1253) ~[client-intermediary.jar:?]
at net.minecraft.class_3244.method_31286(class_3244.java:1237) ~[client-intermediary.jar:?]
at net.minecraft.class_3244.method_12048(class_3244.java:1220) ~[client-intermediary.jar:?]
at net.minecraft.class_2797.method_12115(class_2797.java:30) ~[client-intermediary.jar:?]
at net.minecraft.class_2797.method_11054(class_2797.java:7) ~[client-intermediary.jar:?]
at net.minecraft.class_2600.method_11072(class_2600.java:22) ~[client-intermediary.jar:?]
at net.minecraft.class_3738.run(class_3738.java:18) ~[client-intermediary.jar:?]
at net.minecraft.class_1255.method_18859(class_1255.java:157) ~[client-intermediary.jar:?]
at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_24306(MinecraftServer.java:808) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_18859(MinecraftServer.java:165) ~[client-intermediary.jar:?]
at net.minecraft.class_1255.method_16075(class_1255.java:131) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_20415(MinecraftServer.java:790) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_16075(MinecraftServer.java:784) ~[client-intermediary.jar:?]
at net.minecraft.class_1255.method_18857(class_1255.java:140) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_16208(MinecraftServer.java:769) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.handler$zbk000$modifiedRunLoop(MinecraftServer.java:2905) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:676) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:273) ~[client-intermediary.jar:?]
at java.lang.Thread.run(Thread.java:833) [?:?]
EDIT: Closing and reloading the entire world causes the player to be kicked during join with "Invalid player data" after the following exception:
Exception on world reload
[16:46:24] [Server thread/ERROR]: Couldn't place player in world
java.lang.NullPointerException: Cannot read field "host" because "_c" is null
at carpet.script.Expression.lambda$getOrSetAnyVariable$4(Expression.java:741) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.LazyValue.evalValue(LazyValue.java:21) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.ScriptHost$ModuleData.lambda$new$1(ScriptHost.java:69) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at it.unimi.dsi.fastutil.objects.Object2ObjectMap.lambda$forEach$0(Object2ObjectMap.java:212) ~[fastutil-8.5.6.jar:?]
at it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap$MapEntrySet.fastForEach(Object2ObjectOpenHashMap.java:1051) ~[fastutil-8.5.6.jar:?]
at it.unimi.dsi.fastutil.objects.Object2ObjectMap.forEach(Object2ObjectMap.java:215) ~[fastutil-8.5.6.jar:?]
at carpet.script.ScriptHost$ModuleData.<init>(ScriptHost.java:67) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.ScriptHost.lambda$setupUserHost$8(ScriptHost.java:356) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at java.util.HashMap.forEach(HashMap.java:1421) ~[?:?]
at carpet.script.ScriptHost.setupUserHost(ScriptHost.java:356) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.CarpetScriptHost.setupUserHost(CarpetScriptHost.java:268) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.ScriptHost.retrieveForExecution(ScriptHost.java:347) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.CarpetScriptHost.retrieveOwnForExecution(CarpetScriptHost.java:635) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.script.CarpetScriptServer.lambda$onPlayerJoin$11(CarpetScriptServer.java:412) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at java.util.HashMap$Values.forEach(HashMap.java:1065) ~[?:?]
at carpet.script.CarpetScriptServer.onPlayerJoin(CarpetScriptServer.java:406) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at carpet.CarpetServer.onPlayerLoggedIn(CarpetServer.java:161) ~[fabric-carpet-1.18.2-1.4.66+v220228.jar:?]
at net.minecraft.class_3324.handler$zcp000$onPlayerConnected(class_3324.java:951) ~[client-intermediary.jar:?]
at net.minecraft.class_3324.method_14570(class_3324.java:282) ~[client-intermediary.jar:?]
at net.minecraft.class_3248.method_33800(class_3248.java:130) ~[client-intermediary.jar:?]
at net.minecraft.class_3248.method_14384(class_3248.java:117) ~[client-intermediary.jar:?]
at net.minecraft.class_3248.redirect$bam000$handlePlayerJoin(class_3248.java:563) ~[client-intermediary.jar:?]
at net.minecraft.class_3248.method_18785(class_3248.java:67) ~[client-intermediary.jar:?]
at net.minecraft.class_2535.method_10754(class_2535.java:243) ~[client-intermediary.jar:?]
at net.minecraft.class_3242.method_14357(class_3242.java:183) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:918) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:851) ~[client-intermediary.jar:?]
at net.minecraft.class_1132.method_3748(class_1132.java:97) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.handler$zbk000$modifiedRunLoop(MinecraftServer.java:2896) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:676) ~[client-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:273) ~[client-intermediary.jar:?]
at java.lang.Thread.run(Thread.java:833) [?:?]