Compare commits

...

2 Commits

2 changed files with 13 additions and 8 deletions

View File

@ -331,6 +331,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
init {
capabilityCaches.add(this)
waitForServerLevel { rebuildCache() }
}
override fun get(): T? {
@ -361,6 +362,10 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
// IllegalStateException("Do not call getCapability on an invalid cache or from the invalidation listener!")
// what a shame.
{ onceServer { if (!isRemoved && creationVersion == currentVersion) listeners.accept(cache?.capability) } })
onceServer {
if (!isRemoved && creationVersion == currentVersion) listeners.accept(cache?.capability)
}
}
}
@ -376,7 +381,6 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc
if (!level.isClientSide) {
subscribe()
waitForServerLevel.forEach { it.invoke() }
capabilityCaches.forEach { it.rebuildCache() }
waitForServerLevel.clear()
} else {
waitForServerLevel.clear()

View File

@ -1,16 +1,13 @@
package ru.dbotthepony.mc.otm.core.util
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.ObjectAVLTreeSet
import it.unimi.dsi.fastutil.objects.ObjectArrayList
import it.unimi.dsi.fastutil.objects.ObjectArraySet
import org.apache.logging.log4j.LogManager
import ru.dbotthepony.mc.otm.core.addSorted
import java.util.LinkedList
import java.util.PriorityQueue
import java.util.concurrent.atomic.AtomicInteger
import java.util.*
class TickList : ITickable {
private val tickers = LinkedList<IConditionalTickable>()
private val queuedTickers = ArrayList<IConditionalTickable>()
private val queuedTickers = ObjectArraySet<IConditionalTickable>()
private val timers = PriorityQueue<Timer>()
private val namedTimers = HashMap<Any?, Timer>()
@ -71,6 +68,10 @@ class TickList : ITickable {
add(this)
} else {
queuedTickers.remove(this)
if (!inTicker) {
tickers.remove(this)
}
}
}
}