Store cable side directly, and not relative side, to further improve cable transfer performance
This commit is contained in:
parent
9a6cc53189
commit
8f9103ca48
@ -115,7 +115,7 @@ abstract class EnergyCableBlockEntity(type: BlockEntityType<*>, blockPos: BlockP
|
||||
|
||||
val sides get() = energySides
|
||||
|
||||
val currentlyTransferringTo = ObjectArraySet<Pair<Node, RelativeSide>>()
|
||||
val currentlyTransferringTo = ObjectArraySet<Pair<Node, CableSide>>()
|
||||
|
||||
override fun onNeighbour(link: Link) {
|
||||
if (link is DirectionLink) {
|
||||
|
@ -74,8 +74,8 @@ private class LinkedPriorityQueue<T : Comparable<T>> {
|
||||
}
|
||||
|
||||
class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableGraph>() {
|
||||
private val livelyNodes = HashSet<Pair<EnergyCableBlockEntity.Node, RelativeSide>>()
|
||||
private val livelyNodesList = ArrayList<Pair<EnergyCableBlockEntity.Node, RelativeSide>>()
|
||||
private val livelyNodes = HashSet<Pair<EnergyCableBlockEntity.Node, EnergyCableBlockEntity.CableSide>>()
|
||||
private val livelyNodesList = ArrayList<Pair<EnergyCableBlockEntity.Node, EnergyCableBlockEntity.CableSide>>()
|
||||
|
||||
fun addLivelyNode(node: EnergyCableBlockEntity.Node) {
|
||||
when (contains(node)) {
|
||||
@ -83,7 +83,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
|
||||
ContainsStatus.DOES_NOT_BELONG -> 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<EnergyCableBlockEntity.Node, EnergyCableG
|
||||
|
||||
override fun onNodeRemoved(node: EnergyCableBlockEntity.Node) {
|
||||
for (dir in RelativeSide.entries) {
|
||||
val pair = node to dir
|
||||
val pair = node to node.sides[dir]!!
|
||||
|
||||
if (livelyNodes.remove(pair)) {
|
||||
check(livelyNodesList.remove(pair))
|
||||
@ -617,7 +617,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
|
||||
|
||||
override fun onNodeAdded(node: EnergyCableBlockEntity.Node) {
|
||||
for (dir in RelativeSide.entries) {
|
||||
val pair = node to dir
|
||||
val pair = node to node.sides[dir]!!
|
||||
check(livelyNodes.add(pair))
|
||||
livelyNodesList.add(pair)
|
||||
}
|
||||
@ -649,8 +649,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
|
||||
continue
|
||||
|
||||
try {
|
||||
val (node, relSide) = pair
|
||||
val side = node.sides[relSide]!!
|
||||
val (node, side) = pair
|
||||
|
||||
if (!side.isEnabled) {
|
||||
indicesToRemove.add(i)
|
||||
|
Loading…
Reference in New Issue
Block a user