diff --git a/src/main/java/appeng/blockentity/crafting/CraftingBlockEntity.java b/src/main/java/appeng/blockentity/crafting/CraftingBlockEntity.java index c5639290481..dda7b18ed91 100644 --- a/src/main/java/appeng/blockentity/crafting/CraftingBlockEntity.java +++ b/src/main/java/appeng/blockentity/crafting/CraftingBlockEntity.java @@ -23,8 +23,6 @@ import java.util.Iterator; import java.util.Set; -import com.google.common.collect.Iterators; - import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -331,7 +329,18 @@ private Iterator getMultiblockNodes() { if (this.getCluster() == null) { return new ChainedIterator<>(); } - return Iterators.transform(this.getCluster().getBlockEntities(), CraftingBlockEntity::getGridNode); + var nodes = new ArrayList(); + var it = this.getCluster().getBlockEntities(); + while (it.hasNext()) { + var node = it.next().getGridNode(); + if (node != null) { + // We might have built the multiblock before all nodes have been initialized. + // As a quick fix just ignore null nodes, which matches previous pathing behavior. + // See https://github.com/AppliedEnergistics/Applied-Energistics-2/issues/8295 + nodes.add(node); + } + } + return nodes.iterator(); } @Override diff --git a/src/main/java/appeng/me/pathfinding/PathingCalculation.java b/src/main/java/appeng/me/pathfinding/PathingCalculation.java index 56c23fa849c..0cfa2546225 100644 --- a/src/main/java/appeng/me/pathfinding/PathingCalculation.java +++ b/src/main/java/appeng/me/pathfinding/PathingCalculation.java @@ -25,6 +25,9 @@ import java.util.Queue; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; import appeng.api.networking.GridFlags; @@ -46,6 +49,8 @@ * Second, a DFS is performed to propagate the channel count upwards. */ public class PathingCalculation { + private static final Logger LOG = LoggerFactory.getLogger(PathingCalculation.class); + private final IGrid grid; /** * Path items that are part of a multiblock that was already granted a channel. @@ -152,7 +157,12 @@ private void processQueue(Queue oldOpen, int queueIndex) { var oni = multiblock.getMultiblockNodes(); while (oni.hasNext()) { final IGridNode otherNodes = oni.next(); - if (otherNodes != pi) { + if (otherNodes == null) { + // Only a log for now until addons are fixed too. See + // https://github.com/AppliedEnergistics/Applied-Energistics-2/issues/8295 + LOG.error("Skipping null node returned by grid multiblock node {}", + multiblock); + } else if (otherNodes != pi) { this.multiblocksWithChannel.add((GridNode) otherNodes); } }