Pattern panel now properly react to removed replication tasks

This commit is contained in:
DBotThePony 2023-03-24 20:59:05 +07:00
parent c6ded6b134
commit d1978d7e04
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 15 additions and 3 deletions

View File

@ -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()

View File

@ -266,7 +266,19 @@ class MatterPanelMenu @JvmOverloads constructor(
fun networkTasksRemoved(tasks: Collection<IReplicationTask<*>>) {
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)
}
}
}
}
}