diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt index 931fad1fb..7cfedece9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/GenericNetworkChannel.kt @@ -17,6 +17,8 @@ import ru.dbotthepony.mc.otm.android.feature.ItemEntityDataPacket import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.client.onceClient +import ru.dbotthepony.mc.otm.core.collect.map +import ru.dbotthepony.mc.otm.core.collect.reduce import ru.dbotthepony.mc.otm.item.QuantumBatteryItem import ru.dbotthepony.mc.otm.matter.MatterManager import java.util.* @@ -69,12 +71,11 @@ class BlockEntitySyncPacket(val position: BlockPos, val buffer: ByteArray, val v val blockEntity = level.getBlockEntity(position) if (blockEntity == null) { - LOGGER.warn("Putting BlockEntitySyncPacket received for $position into backlog because there is literally no block entity there! This is CERTAINLY a bug in one of optimizing mods you have or server has installed! This might cause memory leak.") - - backlog.computeIfAbsent(level) { Object2ObjectOpenHashMap() } + val list = backlog.computeIfAbsent(level) { Object2ObjectOpenHashMap() } .computeIfAbsent(position, Object2ObjectFunction { ArrayList() }) - .add(this) + list.add(this) + LOGGER.warn("Putting BlockEntitySyncPacket received for $position into backlog (size: ${list.iterator().map { it.validBytes }.reduce(0, Int::plus) } bytes) because there is literally no block entity there! This might cause memory leak.") return } else if (blockEntity !is MatteryBlockEntity) { LOGGER.warn("Dropping BlockEntitySyncPacket received for $position, because there is $blockEntity which is not MatteryBlockEntity!")