Equipping pocket modem throws error
Lemmmy opened this issue ยท 1 comments
Minecraft Version
1.19.x
Version
1.102.0-fabric
Details
Equipping a wireless modem in a pocket computer (and similarly, Plethora neural interfaces, which will even kick the player from the server) throws "Using modem before position has been defined":
[16:01:43] [Server thread/ERROR] (LuaContext) Error running task
java.lang.IllegalStateException: Using modem before position has been defined
at dan200.computercraft.shared.pocket.peripherals.PocketModemPeripheral.getLevel(PocketModemPeripheral.java:31) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemPeripheral.getNetwork(WirelessModemPeripheral.java:56) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.peripheral.modem.ModemPeripheral.attach(ModemPeripheral.java:257) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.core.apis.PeripheralAPI$PeripheralWrapper.attach(PeripheralAPI.java:73) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.core.apis.PeripheralAPI.onPeripheralChanged(PeripheralAPI.java:207) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.core.computer.Environment.setPeripheral(Environment.java:276) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.computer.core.ServerComputer.setPeripheral(ServerComputer.java:220) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.pocket.core.PocketServerComputer.invalidatePeripheral(PocketServerComputer.java:104) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.pocket.core.PocketServerComputer.setUpgrade(PocketServerComputer.java:130) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.pocket.apis.PocketAPI.equipBack(PocketAPI.java:75) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.pocket.apis.PocketAPI$cc$equipBack163.apply(CC generated method) ~[?:?]
at dan200.computercraft.core.asm.LuaMethod.lambda$static$0(LuaMethod.java:14) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.api.lua.TaskCallback.execute(TaskCallback.java:31) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.core.computer.LuaContext.lambda$issueMainThreadTask$0(LuaContext.java:30) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.core.computer.mainthread.MainThreadExecutor.execute(MainThreadExecutor.java:140) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.core.computer.mainthread.MainThread.tick(MainThread.java:133) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.computer.core.ServerContext.tick(ServerContext.java:141) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at dan200.computercraft.shared.CommonHooks.onServerTickStart(CommonHooks.java:48) ~[cc-tweaked-1.19.3-fabric-1.102.0.jar:?]
at net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents.lambda$static$0(ServerTickEvents.java:40) ~[fabric-lifecycle-events-v1-2.2.9+23a79c8a85.jar:?]
at net.minecraft.server.MinecraftServer.handler$zfg000$onStartTick(MinecraftServer.java:3601) ~[[email protected]:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:872) ~[[email protected]:?]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:726) ~[[email protected]:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:266) ~[[email protected]:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Reproduction
- Get a pocket computer (with no peripherals)
- Get a wireless modem
- Run
lua
,pocket.equipBack()
- Observe error
At a quick glance, it looks like getNetwork() (used by the attach method) tries to get the level, which has not been set yet because PocketModem.update() (IPocketUpgrade) has not been called yet. I believe this worked properly during Plethora development but haven't been able to bisect the issue.
I suspect this was introduced in 04ef6bb, as we now call getLevel
much earlier.