Skip to content

Commit

Permalink
Send raw error message to client and add extra method to resolve erro…
Browse files Browse the repository at this point in the history
…r message.

Avoids powered-off computers showing "bus incomplete" after load.
  • Loading branch information
fnuecke committed Feb 13, 2022
1 parent cb4117a commit f0a06c8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected void renderFg(final PoseStack stack, final float partialTicks, final i
Sprites.ENERGY_BAR.drawFillY(stack, x, y, menu.getEnergy() / (float) menu.getEnergyCapacity());
}

terminalWidget.render(stack, mouseX, mouseY, menu.getVirtualMachine().getBootError());
terminalWidget.render(stack, mouseX, mouseY, menu.getVirtualMachine().getError());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void renderStatusText(final ComputerBlockEntity computer, final PoseStac
return;
}

final Component bootError = computer.getVirtualMachine().getBootError();
final Component bootError = computer.getVirtualMachine().getError();
if (bootError == null) {
return;
}
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/li/cil/oc2/common/vm/AbstractVirtualMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ public void setRunStateClient(final VMRunState value) {
@Override
@Nullable
public Component getBootError() {
return bootError;
}

@Override
@OnlyIn(Dist.CLIENT)
public void setBootErrorClient(@Nullable final Component value) {
bootError = value;
}

@Override
@Nullable
public Component getError() {
switch (busState) {
case SCAN_PENDING:
case INCOMPLETE:
Expand All @@ -145,12 +157,6 @@ public Component getBootError() {
return null;
}

@Override
@OnlyIn(Dist.CLIENT)
public void setBootErrorClient(@Nullable final Component value) {
bootError = value;
}

@Override
public void start() {
if (runState == VMRunState.RUNNING) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/li/cil/oc2/common/vm/VirtualMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public interface VirtualMachine {
@OnlyIn(Dist.CLIENT)
void setBootErrorClient(@Nullable Component value);

@Nullable
Component getError();

boolean isRunning();

void start();
Expand Down

0 comments on commit f0a06c8

Please sign in to comment.