Fixed cable connectivity/scanning.

This commit is contained in:
Florian Nücke
2020-12-25 07:56:49 +01:00
parent 6e5cb5efe9
commit 8943a437b8
2 changed files with 15 additions and 3 deletions

View File

@@ -69,9 +69,17 @@ public class BusCableTileEntity extends AbstractTileEntity {
@Override
protected boolean canConnectToSide(final Direction direction) {
return getConnectionType(direction) == BusCableBlock.ConnectionType.LINK;
}
@Override
protected boolean hasInterfaceOnSide(final Direction direction) {
return getConnectionType(direction) == BusCableBlock.ConnectionType.PLUG;
}
private BusCableBlock.ConnectionType getConnectionType(final Direction direction) {
final EnumProperty<BusCableBlock.ConnectionType> property = BusCableBlock.FACING_TO_CONNECTION_MAP.get(direction);
final BusCableBlock.ConnectionType connectionType = getBlockState().get(property);
return connectionType == BusCableBlock.ConnectionType.PLUG;
return getBlockState().get(property);
}
}
}

View File

@@ -87,7 +87,7 @@ public class TileEntityDeviceBusElement extends AbstractGroupingBlockDeviceBusEl
final int index = direction.getIndex();
final HashSet<BlockDeviceInfo> newDevices = new HashSet<>();
if (canConnectToSide(direction)) {
if (hasInterfaceOnSide(direction)) {
for (final LazyOptional<BlockDeviceInfo> deviceInfo : Devices.getDevices(world, pos, direction)) {
deviceInfo.ifPresent(newDevices::add);
deviceInfo.addListener(unused -> handleNeighborChanged(pos));
@@ -119,6 +119,10 @@ public class TileEntityDeviceBusElement extends AbstractGroupingBlockDeviceBusEl
return true;
}
protected boolean hasInterfaceOnSide(final Direction direction) {
return canConnectToSide(direction);
}
///////////////////////////////////////////////////////////////////
private void scanNeighborsForDevices() {