This commit is contained in:
OneLemonyBoi
2021-05-23 14:57:10 -07:00
parent 21ba20716f
commit 9e4eac89ef
2 changed files with 26 additions and 13 deletions

View File

@@ -93,20 +93,9 @@ public class MachinePortBlockEntity extends UpdatableTile implements ITickableTi
@Override
public void receiveMana(int mana) {
if (storage instanceof ManaPortStorage) {
if (storage instanceof ManaPortStorage && this.isInput()) {
ManaPortStorage s = (ManaPortStorage) storage;
if (this.isInput()) {
s.getInv().receiveMana(mana, false);
}
else {
int tiles = s.getValidPools().size();
if (tiles != 0) {
int manaForEach = mana / tiles;
for (IManaReceiver pool : s.getValidPools()) {
pool.receiveMana(manaForEach);
}
}
}
s.getInv().receiveMana(mana, false);
}
}

View File

@@ -98,6 +98,30 @@ public class ManaPortStorage extends PortStorage {
}
}
System.out.println(this.validPools);
int tiles = validPools.size();
if (tiles != 0) {
int extractableMana = inv.extractMana(Integer.MAX_VALUE, true);
int extractedMana = 0;
int filledPools = 0;
while (extractableMana != 0) {
for (IManaReceiver pool : validPools) {
if (!pool.isFull()) {
pool.receiveMana(1);
extractableMana--;
extractedMana++;
}
else {
filledPools++;
}
}
if (filledPools == validPools.size()) {
break;
}
}
inv.extractMana(extractedMana, false);
}
super.tick(tile);
}
}