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 {
|
init {
|
||||||
capabilityCaches.add(this)
|
capabilityCaches.add(this)
|
||||||
|
waitForServerLevel { rebuildCache() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun get(): T? {
|
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!")
|
// IllegalStateException("Do not call getCapability on an invalid cache or from the invalidation listener!")
|
||||||
// what a shame.
|
// what a shame.
|
||||||
{ onceServer { if (!isRemoved && creationVersion == currentVersion) listeners.accept(cache?.capability) } })
|
{ 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) {
|
if (!level.isClientSide) {
|
||||||
subscribe()
|
subscribe()
|
||||||
waitForServerLevel.forEach { it.invoke() }
|
waitForServerLevel.forEach { it.invoke() }
|
||||||
capabilityCaches.forEach { it.rebuildCache() }
|
|
||||||
waitForServerLevel.clear()
|
waitForServerLevel.clear()
|
||||||
} else {
|
} else {
|
||||||
waitForServerLevel.clear()
|
waitForServerLevel.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user