Skip to content

Commit

Permalink
More infinite mana being sent through issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ramidzkh committed Apr 14, 2022
1 parent 2728013 commit 3ab5ee7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/appbot/ae2/ManaP2PTunnelPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 3ab5ee7

Please sign in to comment.