diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt index 2bce86dcf..76284295d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/matter/MatterPanelBlockEntity.kt @@ -191,7 +191,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val task = _tasks[id] ?: return _tasks.remove(id) - (matterNode.graph as MatterGraph?)?.onMatterTaskRemoved(task) + matterNode.graph.onMatterTaskRemoved(task) listeners.forEach { it.taskRemoved(task) } setChanged() @@ -201,7 +201,7 @@ class MatterPanelBlockEntity(p_155229_: BlockPos, p_155230_: BlockState) : val task = ReplicationTask(UUID.randomUUID(), state.id, state.item, 0, 0, count) _tasks[task.id] = task - (matterNode.graph as MatterGraph?)?.onMatterTaskCreated(task) + matterNode.graph.onMatterTaskCreated(task) listeners.forEach { it.taskUpdated(task) } setChanged() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt index 28397e409..41a482a87 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/matter/MatterPanelMenu.kt @@ -266,7 +266,19 @@ class MatterPanelMenu @JvmOverloads constructor( fun networkTasksRemoved(tasks: Collection>) { for (task in tasks) { - this.tasks.remove(task) + val index = this.tasks.indexOfFirst(task::matchId) + + if (index != -1) { + this.tasks.removeAt(index) + + if (filter.test(task.item)) { + val index = this.tasksFiltered.indexOfFirst(task::matchId) + + if (index != -1) { + this.tasksFiltered.removeAt(index) + } + } + } } }