Avoid excessive re-checks at the same tick

This commit is contained in:
DBotThePony 2023-03-25 09:16:11 +07:00
parent d21a4653e1
commit 0902c445f6
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -137,13 +137,18 @@ class MatterReconstructorBlockEntity(blockPos: BlockPos, blockState: BlockState)
matterNode.discover(this)
}
private var changeset = 0
private fun containerChanged() {
matterPerTick = Decimal.ZERO
progressPerTick = 0.0
val item = repairContainer[0]
val thisChangeset = ++changeset
tickList.once {
if (thisChangeset != changeset) return@once
if (lastItem != item.item) {
lastItem = item.item
repairProgress = 0.0