diff --git a/build.gradle.kts b/build.gradle.kts index 120fca0d..edce69f0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -70,7 +70,7 @@ configure { } create("server") { - workingDirectory(project.file("run")) + workingDirectory(project.file("run-server")) property("forge.logging.markers", "REGISTRIES") property("forge.logging.console.level", "debug") diff --git a/src/main/kotlin/com/the9grounds/aeadditions/blockentity/MEWirelessTransceiverBlockEntity.kt b/src/main/kotlin/com/the9grounds/aeadditions/blockentity/MEWirelessTransceiverBlockEntity.kt index 0d49fd2f..978b4a29 100644 --- a/src/main/kotlin/com/the9grounds/aeadditions/blockentity/MEWirelessTransceiverBlockEntity.kt +++ b/src/main/kotlin/com/the9grounds/aeadditions/blockentity/MEWirelessTransceiverBlockEntity.kt @@ -4,6 +4,7 @@ import appeng.api.networking.* import appeng.api.util.AECableType import appeng.me.helpers.BlockEntityNodeListener import appeng.me.helpers.IGridConnectedBlockEntity +import com.the9grounds.aeadditions.Logger import com.the9grounds.aeadditions.core.AEAConfig import com.the9grounds.aeadditions.menu.MEWirelessTransceiverMenu import com.the9grounds.aeadditions.registries.BlockEntities @@ -86,6 +87,8 @@ class MEWirelessTransceiverBlockEntity(pos: BlockPos, blockState: BlockState) : currentChannel = channel + channel.checkSubscribers() + setupLinks() setChanged() } @@ -98,6 +101,7 @@ class MEWirelessTransceiverBlockEntity(pos: BlockPos, blockState: BlockState) : val alreadyExists = channel.subscribers.find { it == this } != null if (!alreadyExists) { + channel.checkSubscribers() channel.subscribers.add(this) currentChannel = channel @@ -119,10 +123,14 @@ class MEWirelessTransceiverBlockEntity(pos: BlockPos, blockState: BlockState) : subscriber.connection?.destroy() subscriber.connection = null } - val connection = GridHelper.createGridConnection(getGridNode(null), subscriber.getGridNode(null)) - subscriber.connection = connection - connections.add(connection) - localIdleDraw += AEAConfig.meWirelessTransceiverDistanceMultiplier * blockPos.distSqr(subscriber.blockPos) + try { + val connection = GridHelper.createGridConnection(getGridNode(null), subscriber.getGridNode(null)) + subscriber.connection = connection + connections.add(connection) + localIdleDraw += AEAConfig.meWirelessTransceiverDistanceMultiplier * blockPos.distSqr(subscriber.blockPos) + } catch (e: Exception) { + Logger.info(e) + } } } idleDraw = localIdleDraw @@ -231,7 +239,7 @@ class MEWirelessTransceiverBlockEntity(pos: BlockPos, blockState: BlockState) : return null } - if (_mainGridNode.node == null) { + if (!_mainGridNode.isReady) { _mainGridNode.create(level, blockPos) } diff --git a/src/main/kotlin/com/the9grounds/aeadditions/integration/theoneprobe/BlockEntityProvider.kt b/src/main/kotlin/com/the9grounds/aeadditions/integration/theoneprobe/BlockEntityProvider.kt index bdd68f9c..16cb3ab8 100644 --- a/src/main/kotlin/com/the9grounds/aeadditions/integration/theoneprobe/BlockEntityProvider.kt +++ b/src/main/kotlin/com/the9grounds/aeadditions/integration/theoneprobe/BlockEntityProvider.kt @@ -22,9 +22,7 @@ object BlockEntityProvider : IProbeInfoProvider { blockState: BlockState?, hitdata: IProbeHitData? ) { - val blockEntity = level!!.getBlockEntity(hitdata!!.pos) - - when(blockEntity) { + when(val blockEntity = level!!.getBlockEntity(hitdata!!.pos)) { is MEWirelessTransceiverBlockEntity -> blockEntity.addProbeInfo(blockEntity, mode, info, player, level, blockState, hitdata) } } diff --git a/src/main/kotlin/com/the9grounds/aeadditions/util/Channel.kt b/src/main/kotlin/com/the9grounds/aeadditions/util/Channel.kt index f741182b..eac66288 100644 --- a/src/main/kotlin/com/the9grounds/aeadditions/util/Channel.kt +++ b/src/main/kotlin/com/the9grounds/aeadditions/util/Channel.kt @@ -41,6 +41,11 @@ data class Channel(val channelInfo: ChannelInfo, var broadcaster: MEWirelessTran return tag } + // Check if subscribers are removed and remove them from the array + fun checkSubscribers() { + subscribers.removeAll { it.isRemoved } + } + fun hasAccessTo(player: ServerPlayer): Boolean { return channelInfo.hasAccessTo(player) }