simple container action: commit action correctly

This commit is contained in:
Bixilon 2022-11-19 14:12:18 +01:00
parent d046c69574
commit ebb2e50387
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 5 additions and 2 deletions

View File

@ -82,6 +82,7 @@ class SimpleContainerAction(
target.item._count -= subtract
floatingItem.item._count += subtract
}
target.commit(false)
if (floatingItem._valid) {
container.floatingItem = floatingItem

View File

@ -198,11 +198,13 @@ class ItemStack {
lock.lock()
}
fun commit() {
fun commit(unlock: Boolean = true) {
if (!_valid) {
holder?.container?._validate()
}
lock.unlock()
if (unlock) {
lock.unlock()
}
revision++
holder?.container?.apply { revision++ } // increase revision after unlock to prevent deadlock
}