From 3ab5ee7268d1ff9456529a60bccc76dc8638fd38 Mon Sep 17 00:00:00 2001 From: Ramid Khan Date: Thu, 14 Apr 2022 18:15:28 +1000 Subject: [PATCH] More infinite mana being sent through issues --- src/main/java/appbot/ae2/ManaP2PTunnelPart.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/appbot/ae2/ManaP2PTunnelPart.java b/src/main/java/appbot/ae2/ManaP2PTunnelPart.java index 5595ab7..fce667b 100644 --- a/src/main/java/appbot/ae2/ManaP2PTunnelPart.java +++ b/src/main/java/appbot/ae2/ManaP2PTunnelPart.java @@ -2,7 +2,9 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import com.google.common.base.Predicates; @@ -141,12 +143,22 @@ public boolean isFull() { @Override public void receiveMana(int mana) { - var outputs = getOutputs(); + var outputs = getOutputStream() + .filter(part -> { + try (var guard = part.getAdjacentCapability()) { + var receiver = get(guard); + + return receiver.canReceiveManaFromBursts() && !receiver.isFull(); + } + }) + .collect(Collectors.toList()); if (outputs.isEmpty()) { return; } + Collections.shuffle(outputs); + queueTunnelDrain(PowerUnits.AE, mana / 100D); var manaForEach = mana / outputs.size(); var spill = mana % outputs.size();