diff --git a/src/main/kotlin/net/shadowfacts/phycon/network/DeviceBlock.kt b/src/main/kotlin/net/shadowfacts/phycon/network/DeviceBlock.kt index 4aef5e1..8c9d700 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/network/DeviceBlock.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/network/DeviceBlock.kt @@ -14,6 +14,8 @@ import net.shadowfacts.phycon.block.BlockWithEntity */ abstract class DeviceBlock(settings: Settings): BlockWithEntity(settings), NetworkComponentBlock { + abstract override fun getNetworkConnectedSides(state: BlockState, world: World, pos: BlockPos): Collection + override fun getNetworkInterfaceForSide(side: Direction, state: BlockState, world: World, pos: BlockPos): Interface? { return getBlockEntity(world, pos)!! } diff --git a/src/main/kotlin/net/shadowfacts/phycon/network/block/netswitch/SwitchBlockEntity.kt b/src/main/kotlin/net/shadowfacts/phycon/network/block/netswitch/SwitchBlockEntity.kt index e51943f..51d0d51 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/network/block/netswitch/SwitchBlockEntity.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/network/block/netswitch/SwitchBlockEntity.kt @@ -36,9 +36,8 @@ class SwitchBlockEntity: BlockEntity(PhyBlockEntities.SWITCH), return interfaces.find { it.side == side }!! } - private fun handle(frame: EthernetFrame, fromItf: Interface) { - val itfSide = (fromItf as SwitchInterface).side - macTable[frame.source] = itfSide + private fun handle(frame: EthernetFrame, fromItf: SwitchInterface) { + macTable[frame.source] = fromItf.side if (frame is PacketFrame && frame.packet is ItemStackPacket) { val packet = frame.packet as ItemStackPacket @@ -54,10 +53,10 @@ class SwitchBlockEntity: BlockEntity(PhyBlockEntities.SWITCH), if (frame.destination.type != MACAddress.Type.BROADCAST && macTable.containsKey(frame.destination)) { val dir = macTable[frame.destination]!! - println("$this ($itfSide, ${fromItf.macAddress}) forwarding $frame to side $dir") + println("$this (${fromItf.side}, ${fromItf.macAddress}) forwarding $frame to side $dir") interfaceForSide(dir).send(frame) } else { - println("$this ($itfSide, ${fromItf.macAddress}) flooding $frame") + println("$this (${fromItf.side}, ${fromItf.macAddress}) flooding $frame") flood(frame, fromItf) } }