diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt index 20a66630e..df53e1acf 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt @@ -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()