Skip to content

Commit

Permalink
fix: possible reason for a capability related crash
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed May 26, 2024
1 parent c96644c commit b1e4ccd
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public List<BlockCapabilityCache<T, C>> buildTargetCapabilities(List<BlockPos> t
var serverLevel = (ServerLevel) this.level();
return targets.stream()
.map(target -> BlockCapabilityCache.create(this.capabilityType(), serverLevel, target, this.getTargetContext(target),
//only listen to the invalidator if the node is still valid
() -> !this.blockEntity.isRemoved() && Logistics.get().getNetwork(this.globalPos()) != null,
//only listen to the invalidator if we (the BE) still exist.
//Note: Previously we also checked if there is a valid network at this location, however that leads to issues
// namely a single inserter node that is not connected to anything will not have a network, which can lead to the cap cache being removed despite the inserter being fine!
() -> !this.blockEntity.isRemoved(),
() -> {
//handles chunk loads/unloads and destruction of the target BE
this.onCapabilityInvalidated(target, this, false);
Expand Down

0 comments on commit b1e4ccd

Please sign in to comment.