From 8f9103ca48bbfa0eea0f8f7988767bb7c7290843 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 5 Apr 2025 09:47:30 +0700 Subject: [PATCH] Store cable side directly, and not relative side, to further improve cable transfer performance --- .../block/entity/cable/EnergyCableBlockEntity.kt | 2 +- .../mc/otm/block/entity/cable/EnergyCableGraph.kt | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt index e3cd1261b..37024d687 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableBlockEntity.kt @@ -115,7 +115,7 @@ abstract class EnergyCableBlockEntity(type: BlockEntityType<*>, blockPos: BlockP val sides get() = energySides - val currentlyTransferringTo = ObjectArraySet>() + val currentlyTransferringTo = ObjectArraySet>() override fun onNeighbour(link: Link) { if (link is DirectionLink) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt index 6b4155906..edc9e5c2c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/cable/EnergyCableGraph.kt @@ -74,8 +74,8 @@ private class LinkedPriorityQueue> { } class EnergyCableGraph : GraphNodeList() { - private val livelyNodes = HashSet>() - private val livelyNodesList = ArrayList>() + private val livelyNodes = HashSet>() + private val livelyNodesList = ArrayList>() fun addLivelyNode(node: EnergyCableBlockEntity.Node) { when (contains(node)) { @@ -83,7 +83,7 @@ class EnergyCableGraph : GraphNodeList throw IllegalArgumentException("$node does not belong to $this") ContainsStatus.CONTAINS -> { for (dir in RelativeSide.entries) { - val pair = node to dir + val pair = node to node.sides[dir]!! if (livelyNodes.add(pair)) { livelyNodesList.add(pair) @@ -589,7 +589,7 @@ class EnergyCableGraph : GraphNodeList