Skip to content

Commit

Permalink
Fixes #5273: Close craft confirm when grid is missing. (#5292)
Browse files Browse the repository at this point in the history
  • Loading branch information
yueh authored and shartte committed Aug 17, 2021
1 parent e58150c commit d93c74f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/appeng/menu/me/crafting/CraftConfirmMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.crafting.ICraftingLink;
Expand Down Expand Up @@ -115,7 +116,15 @@ public void broadcastChanges() {
return;
}

this.cpuCycler.detectAndSendChanges(this.getGrid());
var grid = this.getGrid();

// Close the screen if the grid no longer exists
if (grid == null) {
this.setValidMenu(false);
return;
}

this.cpuCycler.detectAndSendChanges(grid);

super.broadcastChanges();

Expand Down Expand Up @@ -146,7 +155,8 @@ public void broadcastChanges() {

private IGrid getGrid() {
final IActionHost h = (IActionHost) this.getTarget();
return h.getActionableNode().getGrid();
final IGridNode a = h.getActionableNode();
return a != null ? a.getGrid() : null;
}

private boolean cpuMatches(final ICraftingCPU c) {
Expand Down

0 comments on commit d93c74f

Please sign in to comment.