Controller sorts by energy usage in GUI

This commit is contained in:
Raoul Van den Berge
2016-10-22 01:59:11 +02:00
parent 19b64ee84d
commit f8de0dfed0
2 changed files with 20 additions and 11 deletions

View File

@@ -10,6 +10,7 @@
- Added Silk Touch Upgrade for Destructor (InusualZ) - Added Silk Touch Upgrade for Destructor (InusualZ)
- Added Fortune Upgrade for Destructor (InusualZ) - Added Fortune Upgrade for Destructor (InusualZ)
- Added ore dictionary compare toggle to storage I/O blocks (raoulvdberge) - Added ore dictionary compare toggle to storage I/O blocks (raoulvdberge)
- Controller sorts by energy usage in GUI (raoulvdberge)
- The Constructor can now drop items in the world (raoulvdberge) - The Constructor can now drop items in the world (raoulvdberge)
- The Constructor can now place skulls (modmuss50) - The Constructor can now place skulls (modmuss50)
- The Destructor can now pick up items in the world (InusualZ) - The Destructor can now pick up items in the world (InusualZ)

View File

@@ -114,22 +114,22 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
node.getEnergyUsage() node.getEnergyUsage()
); );
if (clientNode.getStack().getItem() != null) { if (clientNode.getStack().getItem() == null) {
if (nodes.contains(clientNode)) { continue;
for (ClientNode other : nodes) { }
if (other.equals(clientNode)) {
other.setAmount(other.getAmount() + 1);
break; if (nodes.contains(clientNode)) {
} ClientNode other = nodes.get(nodes.indexOf(clientNode));
}
} else { other.setAmount(other.getAmount() + 1);
nodes.add(clientNode); } else {
} nodes.add(clientNode);
} }
} }
} }
Collections.sort(nodes, CLIENT_NODE_COMPARATOR);
return nodes; return nodes;
} }
}); });
@@ -139,6 +139,14 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
private static final String NBT_CRAFTING_TASKS = "CraftingTasks"; private static final String NBT_CRAFTING_TASKS = "CraftingTasks";
private static final Comparator<ClientNode> CLIENT_NODE_COMPARATOR = (left, right) -> {
if (left.getEnergyUsage() == right.getEnergyUsage()) {
return 0;
}
return (left.getEnergyUsage() > right.getEnergyUsage()) ? -1 : 1;
};
private static final Comparator<IItemStorage> ITEM_SIZE_COMPARATOR = (left, right) -> { private static final Comparator<IItemStorage> ITEM_SIZE_COMPARATOR = (left, right) -> {
if (left.getStored() == right.getStored()) { if (left.getStored() == right.getStored()) {
return 0; return 0;