feat(block/switch): Add support for displaying link state
This commit is contained in:
@@ -28,6 +28,7 @@ import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
public final class NetworkSwitchBlockEntity extends ModBlockEntity implements NamedDevice, DocumentedDevice, NetworkInterface, TickableBlockEntity {
|
||||
private final String GET_LINK_STATE = "getLinkState";
|
||||
private final String GET_HOST_TABLE = "getHostTable";
|
||||
private final String GET_PORT_CONFIG = "getPortConfig";
|
||||
private final String SET_PORT_CONFIG = "setPortConfig";
|
||||
@@ -242,6 +243,16 @@ public final class NetworkSwitchBlockEntity extends ModBlockEntity implements Na
|
||||
}
|
||||
}
|
||||
|
||||
@Callback(name = GET_LINK_STATE)
|
||||
public boolean[] getLinkState() {
|
||||
validateAdjacentBlocks();
|
||||
boolean[] sides = new boolean[Constants.BLOCK_FACE_COUNT];
|
||||
for (int i = 0; i < Constants.BLOCK_FACE_COUNT; i++) {
|
||||
sides[i] = adjacentBlockInterfaces[i] != null;
|
||||
}
|
||||
return sides;
|
||||
}
|
||||
|
||||
private Optional<Integer> sideReverseLookup(NetworkInterface iface) {
|
||||
for (int i = 0; i < Constants.BLOCK_FACE_COUNT; i++) {
|
||||
if (iface == adjacentBlockInterfaces[i]) {
|
||||
|
||||
Reference in New Issue
Block a user