Paranoia: when removing cable/interface, ensure previously known devices are disposed via controller, even if they're currently in unloaded chunks.
This commit is contained in:
@@ -251,12 +251,7 @@ public final class BusCableBlockEntity extends ModBlockEntity {
|
||||
super.unloadServer(isRemove);
|
||||
|
||||
if (isRemove) {
|
||||
// Bus element will usually be discovered via bus scan, not via capability request, so
|
||||
// automatic invalidation via capability will *not* necessarily schedule a scan on the
|
||||
// controller of our current bus. So we need to trigger that manually.
|
||||
// The controller already listens to chunk unloads, so we don't want to call this when
|
||||
// the containing chunk gets unloaded, only when we're being removed.
|
||||
busElement.scheduleScan();
|
||||
busElement.setRemoved();
|
||||
}
|
||||
|
||||
for (final NeighborTracker tracker : neighborTrackers) {
|
||||
|
||||
@@ -87,6 +87,22 @@ public abstract class AbstractBlockDeviceBusElement extends AbstractGroupingDevi
|
||||
);
|
||||
}
|
||||
|
||||
public void setRemoved() {
|
||||
final LevelAccessor level = getLevel();
|
||||
if (level == null || level.isClientSide()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (final Direction side : Direction.values()) {
|
||||
final int index = side.get3DDataValue();
|
||||
final BlockPos pos = getPosition().relative(side);
|
||||
final BlockDeviceQuery query = Devices.makeQuery(level, pos, side.getOpposite());
|
||||
setEntriesForGroup(index, new BlockQueryResult(query, Collections.emptySet()));
|
||||
}
|
||||
|
||||
scheduleScan();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
protected boolean canScanContinueTowards(@Nullable final Direction direction) {
|
||||
|
||||
Reference in New Issue
Block a user