mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-04 15:43:00 +00:00
Fix creating a zero-sized pocket terminal
When the terminal data is not present, width/height are set to 0, rather than the terminal's width/height. This meant we'd create an empty terminal, which then crashes when we try to render it. We now make the terminal nullable and initialise it the first time we receive the terminal data. To prevent future mistakes, we hide width/height, and use TerminalState.create everywhere. Fixes #1765
This commit is contained in:
@@ -41,7 +41,7 @@ class Pocket_Computer_Test {
|
||||
val pocketComputer = ClientPocketComputers.get(minecraft.player!!.mainHandItem)!!
|
||||
assertEquals(ComputerState.ON, pocketComputer.state)
|
||||
|
||||
val term = pocketComputer.terminal
|
||||
val term = pocketComputer.terminal!!
|
||||
assertEquals("Hello, world!", term.getLine(0).toString().trim(), "Terminal contents is synced")
|
||||
}
|
||||
// Update the terminal contents again.
|
||||
@@ -57,7 +57,7 @@ class Pocket_Computer_Test {
|
||||
val pocketComputer = ClientPocketComputers.get(minecraft.player!!.mainHandItem)!!
|
||||
assertEquals(ComputerState.BLINKING, pocketComputer.state)
|
||||
|
||||
val term = pocketComputer.terminal
|
||||
val term = pocketComputer.terminal!!
|
||||
assertEquals("Updated text :)", term.getLine(0).toString().trim(), "Terminal contents is synced")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user