Fix CapabilityCache not calling "invalidated" listeners on first cache initialization
This commit is contained in:
parent
83baf5a8a0
commit
bc75b61852
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user