aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/graphs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/graphs')
-rw-r--r--src/main/java/gregtech/api/graphs/GenerateNodeMap.java56
-rw-r--r--src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java22
-rw-r--r--src/main/java/gregtech/api/graphs/Lock.java5
-rw-r--r--src/main/java/gregtech/api/graphs/Node.java4
-rw-r--r--src/main/java/gregtech/api/graphs/NodeList.java13
-rw-r--r--src/main/java/gregtech/api/graphs/PowerNode.java6
-rw-r--r--src/main/java/gregtech/api/graphs/PowerNodes.java33
-rw-r--r--src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java6
-rw-r--r--src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java11
-rw-r--r--src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java10
-rw-r--r--src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java99
-rw-r--r--src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java10
-rw-r--r--src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java5
-rw-r--r--src/main/java/gregtech/api/graphs/paths/NodePath.java2
-rw-r--r--src/main/java/gregtech/api/graphs/paths/PowerNodePath.java1
15 files changed, 170 insertions, 113 deletions
diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java
index 4d1b7a7461..c0ee8b9490 100644
--- a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java
+++ b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java
@@ -1,19 +1,17 @@
package gregtech.api.graphs;
+import static gregtech.api.util.GT_Utility.getOppositeSide;
+
import gregtech.api.graphs.consumers.ConsumerNode;
import gregtech.api.graphs.paths.NodePath;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
-import net.minecraft.tileentity.TileEntity;
-
import java.util.ArrayList;
import java.util.HashSet;
-
-import static gregtech.api.util.GT_Utility.getOppositeSide;
-
+import net.minecraft.tileentity.TileEntity;
// generates the node map
-abstract public class GenerateNodeMap {
+public abstract class GenerateNodeMap {
// clearing the node map to make sure it is gone on reset
public static void clearNodeMap(Node aNode, int aReturnNodeValue) {
if (aNode.mTileEntity instanceof BaseMetaPipeEntity) {
@@ -33,8 +31,7 @@ abstract public class GenerateNodeMap {
}
Node tNextNode = aNode.mNeighbourNodes[i];
if (tNextNode == null) continue;
- if (tNextNode.mNodeValue != aReturnNodeValue)
- clearNodeMap(tNextNode, aNode.mNodeValue);
+ if (tNextNode.mNodeValue != aReturnNodeValue) clearNodeMap(tNextNode, aNode.mNodeValue);
aNode.mNeighbourNodes[i] = null;
}
}
@@ -49,8 +46,13 @@ abstract public class GenerateNodeMap {
}
// gets the next node
- protected void generateNextNode(BaseMetaPipeEntity aPipe, Node aPipeNode, byte aInvalidSide, int aNextNodeValue,
- ArrayList<ConsumerNode> tConsumers, HashSet<Node> tNodeMap) {
+ protected void generateNextNode(
+ BaseMetaPipeEntity aPipe,
+ Node aPipeNode,
+ byte aInvalidSide,
+ int aNextNodeValue,
+ ArrayList<ConsumerNode> tConsumers,
+ HashSet<Node> tNodeMap) {
MetaPipeEntity tMetaPipe = (MetaPipeEntity) aPipe.getMetaTileEntity();
for (byte i = 0; i < 6; i++) {
if (i == aInvalidSide) {
@@ -61,8 +63,14 @@ abstract public class GenerateNodeMap {
ArrayList<MetaPipeEntity> tNewPipes = new ArrayList<>();
Pair nextTileEntity = getNextValidTileEntity(tNextTileEntity, tNewPipes, i, tNodeMap);
if (nextTileEntity != null) {
- Node tNextNode = generateNode(nextTileEntity.mTileEntity, aPipeNode, aNextNodeValue + 1, tNewPipes,
- nextTileEntity.mSide, tConsumers, tNodeMap);
+ Node tNextNode = generateNode(
+ nextTileEntity.mTileEntity,
+ aPipeNode,
+ aNextNodeValue + 1,
+ tNewPipes,
+ nextTileEntity.mSide,
+ tConsumers,
+ tNodeMap);
if (tNextNode != null) {
aNextNodeValue = tNextNode.mHighestNodeValue;
aPipeNode.mHighestNodeValue = tNextNode.mHighestNodeValue;
@@ -77,8 +85,14 @@ abstract public class GenerateNodeMap {
}
// on a valid tile entity create a new node
- protected Node generateNode(TileEntity aTileEntity, Node aPreviousNode, int aNextNodeValue, ArrayList<MetaPipeEntity> aPipes,
- int aSide, ArrayList<ConsumerNode> aConsumers, HashSet<Node> aNodeMap) {
+ protected Node generateNode(
+ TileEntity aTileEntity,
+ Node aPreviousNode,
+ int aNextNodeValue,
+ ArrayList<MetaPipeEntity> aPipes,
+ int aSide,
+ ArrayList<ConsumerNode> aConsumers,
+ HashSet<Node> aNodeMap) {
if (aTileEntity.isInvalid()) return null;
byte tSideOp = getOppositeSide(aSide);
byte tInvalidSide = aPreviousNode == null ? -1 : tSideOp;
@@ -96,7 +110,7 @@ abstract public class GenerateNodeMap {
}
tPipe.setNode(tPipeNode);
aNodeMap.add(tPipeNode);
- tPipeNode.mSelfPath = getNewPath(new MetaPipeEntity[]{tMetaPipe});
+ tPipeNode.mSelfPath = getNewPath(new MetaPipeEntity[] {tMetaPipe});
tThisNode = tPipeNode;
if (tInvalidSide > -1) {
tPipeNode.mNeighbourNodes[tInvalidSide] = aPreviousNode;
@@ -123,14 +137,14 @@ abstract public class GenerateNodeMap {
}
// go over the pipes until we see a valid tile entity that needs a node
- protected Pair getNextValidTileEntity(TileEntity aTileEntity, ArrayList<MetaPipeEntity> aPipes, byte aSide, HashSet<Node> aNodeMap) {
+ protected Pair getNextValidTileEntity(
+ TileEntity aTileEntity, ArrayList<MetaPipeEntity> aPipes, byte aSide, HashSet<Node> aNodeMap) {
if (isPipe(aTileEntity)) {
BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity;
MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity();
Node tNode = tPipe.getNode();
if (tNode != null) {
- if (aNodeMap.contains(tNode))
- return null;
+ if (aNodeMap.contains(tNode)) return null;
}
int tConnections = getNumberOfConnections(tMetaPipe);
if (tConnections == 2) {
@@ -161,13 +175,15 @@ abstract public class GenerateNodeMap {
}
// checks if the tile entity is a consumer and add to the list
- abstract protected boolean addConsumer(TileEntity aTileEntity, byte aSide, int aNodeValue, ArrayList<ConsumerNode> aConsumers);
+ protected abstract boolean addConsumer(
+ TileEntity aTileEntity, byte aSide, int aNodeValue, ArrayList<ConsumerNode> aConsumers);
// get correct pathClass that you need for your node network
protected abstract NodePath getNewPath(MetaPipeEntity[] aPipes);
// used for if you need to use dead ends for something can be null
- protected Node getEmptyNode(int aNodeValue, byte aSide, TileEntity aTileEntity, ArrayList<ConsumerNode> aConsumers) {
+ protected Node getEmptyNode(
+ int aNodeValue, byte aSide, TileEntity aTileEntity, ArrayList<ConsumerNode> aConsumers) {
return null;
}
diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java b/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java
index bb7a1f58e1..293a46502a 100644
--- a/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java
+++ b/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java
@@ -16,11 +16,10 @@ import gregtech.api.metatileentity.BaseMetaTileEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable;
import ic2.api.energy.tile.IEnergySink;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraftforge.common.util.ForgeDirection;
-
import java.util.ArrayList;
import java.util.HashSet;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
// node map generator for power distribution
public class GenerateNodeMapPower extends GenerateNodeMap {
@@ -30,11 +29,13 @@ public class GenerateNodeMapPower extends GenerateNodeMap {
@Override
protected boolean isPipe(TileEntity aTileEntity) {
- return super.isPipe(aTileEntity) && ((BaseMetaPipeEntity) aTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable;
+ return super.isPipe(aTileEntity)
+ && ((BaseMetaPipeEntity) aTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable;
}
@Override
- protected boolean addConsumer(TileEntity aTileEntity, byte aSide, int aNodeValue, ArrayList<ConsumerNode> aConsumers) {
+ protected boolean addConsumer(
+ TileEntity aTileEntity, byte aSide, int aNodeValue, ArrayList<ConsumerNode> aConsumers) {
if (aTileEntity instanceof BaseMetaTileEntity) {
BaseMetaTileEntity tBaseTileEntity = (BaseMetaTileEntity) aTileEntity;
if (tBaseTileEntity.inputEnergyFrom(aSide, false)) {
@@ -62,12 +63,14 @@ public class GenerateNodeMapPower extends GenerateNodeMap {
tNextTo = aTileEntity.getWorldObj().getTileEntity(dX, dY, dZ);
if (((IEnergySink) aTileEntity).acceptsEnergyFrom(tNextTo, ForgeDirection.getOrientation(aSide))) {
- ConsumerNode tConsumerNode = new NodeEnergySink(aNodeValue, (IEnergySink) aTileEntity, aSide, aConsumers);
+ ConsumerNode tConsumerNode =
+ new NodeEnergySink(aNodeValue, (IEnergySink) aTileEntity, aSide, aConsumers);
aConsumers.add(tConsumerNode);
return true;
}
} else if (GregTech_API.mOutputRF && aTileEntity instanceof IEnergyReceiver) {
- ConsumerNode tConsumerNode = new NodeEnergyReceiver(aNodeValue, (IEnergyReceiver) aTileEntity, aSide, aConsumers);
+ ConsumerNode tConsumerNode =
+ new NodeEnergyReceiver(aNodeValue, (IEnergyReceiver) aTileEntity, aSide, aConsumers);
aConsumers.add(tConsumerNode);
return true;
}
@@ -79,9 +82,10 @@ public class GenerateNodeMapPower extends GenerateNodeMap {
return new PowerNodePath(aPipes);
}
- //used to apply voltage on dead ends
+ // used to apply voltage on dead ends
@Override
- protected Node getEmptyNode(int aNodeValue, byte aSide, TileEntity aTileEntity, ArrayList<ConsumerNode> aConsumers) {
+ protected Node getEmptyNode(
+ int aNodeValue, byte aSide, TileEntity aTileEntity, ArrayList<ConsumerNode> aConsumers) {
Node tNode = new EmptyPowerConsumer(aNodeValue, aTileEntity, aSide, aConsumers);
aConsumers.add((ConsumerNode) tNode);
return tNode;
diff --git a/src/main/java/gregtech/api/graphs/Lock.java b/src/main/java/gregtech/api/graphs/Lock.java
index 0ba43b83de..e89cc8b25c 100644
--- a/src/main/java/gregtech/api/graphs/Lock.java
+++ b/src/main/java/gregtech/api/graphs/Lock.java
@@ -1,8 +1,7 @@
package gregtech.api.graphs;
-import net.minecraft.tileentity.TileEntity;
-
import java.util.ArrayList;
+import net.minecraft.tileentity.TileEntity;
public class Lock {
protected ArrayList<TileEntity> tiles = new ArrayList<>();
@@ -25,7 +24,7 @@ public class Lock {
return !tiles.isEmpty();
}
- //i want to check for the exact object not equals
+ // i want to check for the exact object not equals
protected int contains(TileEntity tileEntity) {
for (int i = 0; i < tiles.size(); i++) {
if (tiles.get(i) == tileEntity) {
diff --git a/src/main/java/gregtech/api/graphs/Node.java b/src/main/java/gregtech/api/graphs/Node.java
index be499dea0d..f6a3ebe2d2 100644
--- a/src/main/java/gregtech/api/graphs/Node.java
+++ b/src/main/java/gregtech/api/graphs/Node.java
@@ -2,11 +2,10 @@ package gregtech.api.graphs;
import gregtech.api.graphs.consumers.ConsumerNode;
import gregtech.api.graphs.paths.NodePath;
+import java.util.ArrayList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
-import java.util.ArrayList;
-
// base Node class
public class Node {
public Node(int aNodeValue, TileEntity aTileEntity, ArrayList<ConsumerNode> aConsumers) {
@@ -18,7 +17,6 @@ public class Node {
mCreationTime = MinecraftServer.getServer().getTickCounter();
}
-
public final TileEntity mTileEntity;
public Node[] mNeighbourNodes = new Node[6];
public NodePath[] mNodePaths = new NodePath[6];
diff --git a/src/main/java/gregtech/api/graphs/NodeList.java b/src/main/java/gregtech/api/graphs/NodeList.java
index fb8afe68fa..8a018e2123 100644
--- a/src/main/java/gregtech/api/graphs/NodeList.java
+++ b/src/main/java/gregtech/api/graphs/NodeList.java
@@ -4,21 +4,18 @@ package gregtech.api.graphs;
public class NodeList {
Node[] mNodes;
int mCounter = 0;
+
public NodeList(Node[] mNodes) {
this.mNodes = mNodes;
}
Node getNextNode() {
- if (++mCounter < mNodes.length)
- return mNodes[mCounter];
- else
- return null;
+ if (++mCounter < mNodes.length) return mNodes[mCounter];
+ else return null;
}
Node getNode() {
- if (mCounter < mNodes.length)
- return mNodes[mCounter];
- else
- return null;
+ if (mCounter < mNodes.length) return mNodes[mCounter];
+ else return null;
}
}
diff --git a/src/main/java/gregtech/api/graphs/PowerNode.java b/src/main/java/gregtech/api/graphs/PowerNode.java
index 82c97d3901..c81d436861 100644
--- a/src/main/java/gregtech/api/graphs/PowerNode.java
+++ b/src/main/java/gregtech/api/graphs/PowerNode.java
@@ -1,13 +1,13 @@
package gregtech.api.graphs;
import gregtech.api.graphs.consumers.ConsumerNode;
-import net.minecraft.tileentity.TileEntity;
-
import java.util.ArrayList;
+import net.minecraft.tileentity.TileEntity;
// base node for power networks
-public class PowerNode extends Node{
+public class PowerNode extends Node {
public boolean mHadVoltage = false;
+
public PowerNode(int aNodeValue, TileEntity aTileEntity, ArrayList<ConsumerNode> aConsumers) {
super(aNodeValue, aTileEntity, aConsumers);
}
diff --git a/src/main/java/gregtech/api/graphs/PowerNodes.java b/src/main/java/gregtech/api/graphs/PowerNodes.java
index e5d0e56699..759002dbdb 100644
--- a/src/main/java/gregtech/api/graphs/PowerNodes.java
+++ b/src/main/java/gregtech/api/graphs/PowerNodes.java
@@ -22,7 +22,8 @@ import gregtech.api.graphs.paths.PowerNodePath;
*/
public class PowerNodes {
// check if the looked for node is next to or get the next node that is closer to it
- static public long powerNode(Node aCurrentNode, Node aPreviousNode, NodeList aConsumers, long aVoltage, long aMaxAmps) {
+ public static long powerNode(
+ Node aCurrentNode, Node aPreviousNode, NodeList aConsumers, long aVoltage, long aMaxAmps) {
long tAmpsUsed = 0;
ConsumerNode tConsumer = (ConsumerNode) aConsumers.getNode();
int tLoopProtection = 0;
@@ -39,7 +40,8 @@ public class PowerNodes {
break;
} else {
if (aPreviousNode == tNextNode) return tAmpsUsed;
- tAmpsUsed += processNextNode(aCurrentNode, tNextNode, aConsumers, j, aMaxAmps - tAmpsUsed, aVoltage);
+ tAmpsUsed += processNextNode(
+ aCurrentNode, tNextNode, aConsumers, j, aMaxAmps - tAmpsUsed, aVoltage);
tConsumer = (ConsumerNode) aConsumers.getNode();
break;
}
@@ -52,7 +54,8 @@ public class PowerNodes {
if (tNextNode == null) continue;
if (tNextNode.mNodeValue > aCurrentNode.mNodeValue && tNextNode.mNodeValue < tTargetNodeValue) {
if (tNextNode == aPreviousNode) return tAmpsUsed;
- tAmpsUsed += processNextNodeAbove(aCurrentNode, tNextNode, aConsumers, side, aMaxAmps - tAmpsUsed, aVoltage);
+ tAmpsUsed += processNextNodeAbove(
+ aCurrentNode, tNextNode, aConsumers, side, aMaxAmps - tAmpsUsed, aVoltage);
tConsumer = (ConsumerNode) aConsumers.getNode();
break;
} else if (tNextNode.mNodeValue == tTargetNodeValue) {
@@ -74,7 +77,8 @@ public class PowerNodes {
// checking if target node is next to it or has a higher value then current node value
// these functions are different to either go down or up the stack
- protected static long powerNodeAbove(Node aCurrentNode, Node aPreviousNode, NodeList aConsumers, long aVoltage, long aMaxAmps) {
+ protected static long powerNodeAbove(
+ Node aCurrentNode, Node aPreviousNode, NodeList aConsumers, long aVoltage, long aMaxAmps) {
long tAmpsUsed = 0;
int tLoopProtection = 0;
ConsumerNode tConsumer = (ConsumerNode) aConsumers.getNode();
@@ -88,7 +92,8 @@ public class PowerNodes {
if (tNextNode == null) continue;
if (tNextNode.mNodeValue > aCurrentNode.mNodeValue && tNextNode.mNodeValue < tTargetNodeValue) {
if (tNextNode == aPreviousNode) return tAmpsUsed;
- tAmpsUsed += processNextNodeAbove(aCurrentNode, tNextNode, aConsumers, side, aMaxAmps - tAmpsUsed, aVoltage);
+ tAmpsUsed += processNextNodeAbove(
+ aCurrentNode, tNextNode, aConsumers, side, aMaxAmps - tAmpsUsed, aVoltage);
tConsumer = (ConsumerNode) aConsumers.getNode();
break;
} else if (tNextNode.mNodeValue == tTargetNodeValue) {
@@ -108,7 +113,8 @@ public class PowerNodes {
return tAmpsUsed;
}
- protected static long processNextNode(Node aCurrentNode, Node aNextNode, NodeList aConsumers, int aSide, long aMaxAmps, long aVoltage) {
+ protected static long processNextNode(
+ Node aCurrentNode, Node aNextNode, NodeList aConsumers, int aSide, long aMaxAmps, long aVoltage) {
if (aCurrentNode.locks[aSide].isLocked()) {
aConsumers.getNextNode();
return 0;
@@ -124,12 +130,12 @@ public class PowerNodes {
tVoltLoss += tPath.getLoss();
long tAmps = powerNode(aNextNode, aCurrentNode, aConsumers, aVoltage - tVoltLoss, aMaxAmps);
tPath.addAmps(tAmps);
- if (tSelfPath != null)
- tSelfPath.addAmps(tAmps);
+ if (tSelfPath != null) tSelfPath.addAmps(tAmps);
return tAmps;
}
- protected static long processNextNodeAbove(Node aCurrentNode, Node aNextNode, NodeList aConsumers, int aSide, long aMaxAmps, long aVoltage) {
+ protected static long processNextNodeAbove(
+ Node aCurrentNode, Node aNextNode, NodeList aConsumers, int aSide, long aMaxAmps, long aVoltage) {
if (aCurrentNode.locks[aSide].isLocked()) {
aConsumers.getNextNode();
return 0;
@@ -145,12 +151,12 @@ public class PowerNodes {
tVoltLoss += tPath.getLoss();
long tAmps = powerNodeAbove(aNextNode, aCurrentNode, aConsumers, aVoltage - tVoltLoss, aMaxAmps);
tPath.addAmps(tAmps);
- if (tSelfPath != null)
- tSelfPath.addAmps(tAmps);
+ if (tSelfPath != null) tSelfPath.addAmps(tAmps);
return tAmps;
}
- protected static long processNodeInject(Node aCurrentNode, ConsumerNode aConsumer, int aSide, long aMaxAmps, long aVoltage) {
+ protected static long processNodeInject(
+ Node aCurrentNode, ConsumerNode aConsumer, int aSide, long aMaxAmps, long aVoltage) {
if (aCurrentNode.locks[aSide].isLocked()) return 0;
final PowerNodePath tPath = (PowerNodePath) aCurrentNode.mNodePaths[aSide];
final PowerNodePath tSelfPath = (PowerNodePath) aCurrentNode.mSelfPath;
@@ -163,8 +169,7 @@ public class PowerNodes {
tVoltLoss += tPath.getLoss();
long tAmps = aConsumer.injectEnergy(aVoltage - tVoltLoss, aMaxAmps);
tPath.addAmps(tAmps);
- if (tSelfPath != null)
- tSelfPath.addAmps(tAmps);
+ if (tSelfPath != null) tSelfPath.addAmps(tAmps);
return tAmps;
}
}
diff --git a/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java b/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java
index e060c5c094..78b3c51928 100644
--- a/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java
+++ b/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java
@@ -1,15 +1,15 @@
package gregtech.api.graphs.consumers;
import gregtech.api.graphs.Node;
-import net.minecraft.tileentity.TileEntity;
-
import java.util.ArrayList;
+import net.minecraft.tileentity.TileEntity;
// node attached to a tile entity that can consume stuff from the network
public class ConsumerNode extends Node {
public byte mSide;
+
public ConsumerNode(int aNodeValue, TileEntity aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) {
- super(aNodeValue,aTileEntity,aConsumers);
+ super(aNodeValue, aTileEntity, aConsumers);
this.mSide = aSide;
}
diff --git a/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java b/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java
index 29f4fe8893..d5ff76c12b 100644
--- a/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java
+++ b/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java
@@ -2,12 +2,11 @@ package gregtech.api.graphs.consumers;
import gregtech.api.graphs.paths.PowerNodePath;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
-import net.minecraft.tileentity.TileEntity;
-
import java.util.ArrayList;
+import net.minecraft.tileentity.TileEntity;
-//this is here to apply voltage to dead ends
-public class EmptyPowerConsumer extends ConsumerNode{
+// this is here to apply voltage to dead ends
+public class EmptyPowerConsumer extends ConsumerNode {
public EmptyPowerConsumer(int aNodeValue, TileEntity aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) {
super(aNodeValue, aTileEntity, aSide, aConsumers);
}
@@ -20,8 +19,8 @@ public class EmptyPowerConsumer extends ConsumerNode{
@Override
public int injectEnergy(long aVoltage, long aMaxAmps) {
BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) mTileEntity;
- PowerNodePath tPath =(PowerNodePath) tPipe.getNodePath();
- tPath.applyVoltage(aVoltage,true);
+ PowerNodePath tPath = (PowerNodePath) tPipe.getNodePath();
+ tPath.applyVoltage(aVoltage, true);
return 0;
}
}
diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java
index 0b3c8e31fa..30582332e7 100644
--- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java
+++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java
@@ -1,13 +1,13 @@
package gregtech.api.graphs.consumers;
import gregtech.api.interfaces.tileentity.IEnergyConnected;
-import net.minecraft.tileentity.TileEntity;
-
import java.util.ArrayList;
+import net.minecraft.tileentity.TileEntity;
public class NodeEnergyConnected extends ConsumerNode {
- public NodeEnergyConnected(int aNodeValue, IEnergyConnected aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) {
- super(aNodeValue,(TileEntity) aTileEntity, aSide, aConsumers);
+ public NodeEnergyConnected(
+ int aNodeValue, IEnergyConnected aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) {
+ super(aNodeValue, (TileEntity) aTileEntity, aSide, aConsumers);
}
@Override
@@ -17,6 +17,6 @@ public class NodeEnergyConnected extends ConsumerNode {
@Override
public int injectEnergy(long aVoltage, long aMaxAmps) {
- return (int) ((IEnergyConnected)mTileEntity).injectEnergyUnits(mSide,aVoltage,aMaxAmps);
+ return (int) ((IEnergyConnected) mTileEntity).injectEnergyUnits(mSide, aVoltage, aMaxAmps);
}
}
diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java
index bd9e75945b..9c5e3f8aab 100644
--- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java
+++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java
@@ -1,5 +1,7 @@
package gregtech.api.graphs.consumers;
+import static gregtech.api.enums.GT_Values.V;
+
import cofh.api.energy.IEnergyReceiver;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
@@ -7,19 +9,18 @@ import gregtech.api.enums.SoundResource;
import gregtech.api.util.GT_Utility;
import gregtech.api.util.WorldSpawnedEventBuilder;
import gregtech.common.GT_Pollution;
+import java.util.ArrayList;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
-import java.util.ArrayList;
-
-import static gregtech.api.enums.GT_Values.V;
-
-//consumer for RF machines
+// consumer for RF machines
public class NodeEnergyReceiver extends ConsumerNode {
int mRestRF = 0;
- public NodeEnergyReceiver(int aNodeValue, IEnergyReceiver aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) {
+
+ public NodeEnergyReceiver(
+ int aNodeValue, IEnergyReceiver aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) {
super(aNodeValue, (TileEntity) aTileEntity, aSide, aConsumers);
}
@@ -37,44 +38,82 @@ public class NodeEnergyReceiver extends ConsumerNode {
mRestRF -= consumed;
return ampsUsed;
}
- if (GregTech_API.mRFExplosions && GregTech_API.sMachineExplosions &&
- ((IEnergyReceiver) mTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600L) {
+ if (GregTech_API.mRFExplosions
+ && GregTech_API.sMachineExplosions
+ && ((IEnergyReceiver) mTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600L) {
explode(rfOut);
}
return 0;
}
- //copied from IEnergyConnected
+ // copied from IEnergyConnected
private void explode(int aRfOut) {
if (aRfOut > 32L * GregTech_API.mEUtoRF / 100L) {
int aExplosionPower = aRfOut;
- float tStrength =
- aExplosionPower < V[0] ? 1.0F :
- aExplosionPower < V[1] ? 2.0F :
- aExplosionPower < V[2] ? 3.0F :
- aExplosionPower < V[3] ? 4.0F :
- aExplosionPower < V[4] ? 5.0F :
- aExplosionPower < V[4] * 2 ? 6.0F :
- aExplosionPower < V[5] ? 7.0F :
- aExplosionPower < V[6] ? 8.0F :
- aExplosionPower < V[7] ? 9.0F :
- aExplosionPower < V[8] ? 10.0F :
- aExplosionPower < V[8] * 2 ? 11.0F :
- aExplosionPower < V[9] ? 12.0F :
- aExplosionPower < V[10] ? 13.0F :
- aExplosionPower < V[11] ? 14.0F :
- aExplosionPower < V[12] ? 15.0F :
- aExplosionPower < V[12] * 2 ? 16.0F :
- aExplosionPower < V[13] ? 17.0F :
- aExplosionPower < V[14] ? 18.0F :
- aExplosionPower < V[15] ? 19.0F : 20.0F;
+ float tStrength = aExplosionPower < V[0]
+ ? 1.0F
+ : aExplosionPower < V[1]
+ ? 2.0F
+ : aExplosionPower < V[2]
+ ? 3.0F
+ : aExplosionPower < V[3]
+ ? 4.0F
+ : aExplosionPower < V[4]
+ ? 5.0F
+ : aExplosionPower < V[4] * 2
+ ? 6.0F
+ : aExplosionPower < V[5]
+ ? 7.0F
+ : aExplosionPower < V[6]
+ ? 8.0F
+ : aExplosionPower < V[7]
+ ? 9.0F
+ : aExplosionPower < V[8]
+ ? 10.0F
+ : aExplosionPower < V[8] * 2
+ ? 11.0F
+ : aExplosionPower
+ < V[
+ 9]
+ ? 12.0F
+ : aExplosionPower
+ < V[
+ 10]
+ ? 13.0F
+ : aExplosionPower
+ < V[
+ 11]
+ ? 14.0F
+ : aExplosionPower
+ < V[
+ 12]
+ ? 15.0F
+ : aExplosionPower
+ < V[
+ 12]
+ * 2
+ ? 16.0F
+ : aExplosionPower
+ < V[
+ 13]
+ ? 17.0F
+ : aExplosionPower
+ < V[
+ 14]
+ ? 18.0F
+ : aExplosionPower
+ < V[
+ 15]
+ ? 19.0F
+ : 20.0F;
int tX = mTileEntity.xCoord, tY = mTileEntity.yCoord, tZ = mTileEntity.zCoord;
World tWorld = mTileEntity.getWorldObj();
GT_Utility.sendSoundToPlayers(tWorld, SoundResource.IC2_MACHINES_MACHINE_OVERLOAD, 1.0F, -1, tX, tY, tZ);
tWorld.setBlock(tX, tY, tZ, Blocks.air);
if (GregTech_API.sMachineExplosions)
if (GT_Mod.gregtechproxy.mPollution)
- GT_Pollution.addPollution(tWorld.getChunkFromBlockCoords(tX, tZ), GT_Mod.gregtechproxy.mPollutionOnExplosion);
+ GT_Pollution.addPollution(
+ tWorld.getChunkFromBlockCoords(tX, tZ), GT_Mod.gregtechproxy.mPollutionOnExplosion);
new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder()
.setStrength(tStrength)
diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java
index d2c54e284f..95b16883af 100644
--- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java
+++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java
@@ -1,11 +1,10 @@
package gregtech.api.graphs.consumers;
import ic2.api.energy.tile.IEnergySink;
+import java.util.ArrayList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
-import java.util.ArrayList;
-
// consumer for IC2 machines
public class NodeEnergySink extends ConsumerNode {
public NodeEnergySink(int nodeValue, IEnergySink tileEntity, byte side, ArrayList<ConsumerNode> consumers) {
@@ -20,9 +19,10 @@ public class NodeEnergySink extends ConsumerNode {
@Override
public int injectEnergy(long aVoltage, long aMaxAmps) {
int tUsedAmps = 0;
- while (aMaxAmps > tUsedAmps && ((IEnergySink) mTileEntity).getDemandedEnergy() > 0 &&
- ((IEnergySink) mTileEntity).injectEnergy(ForgeDirection.getOrientation(mSide), aVoltage, aVoltage) < aVoltage)
- tUsedAmps++;
+ while (aMaxAmps > tUsedAmps
+ && ((IEnergySink) mTileEntity).getDemandedEnergy() > 0
+ && ((IEnergySink) mTileEntity).injectEnergy(ForgeDirection.getOrientation(mSide), aVoltage, aVoltage)
+ < aVoltage) tUsedAmps++;
return tUsedAmps;
}
}
diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java b/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java
index e9736df7f4..e367a5294e 100644
--- a/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java
+++ b/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java
@@ -6,13 +6,14 @@ import java.util.ArrayList;
// consumer for gt machines
public class NodeGTBaseMetaTile extends ConsumerNode {
- public NodeGTBaseMetaTile(int aNodeValue, BaseMetaTileEntity aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) {
+ public NodeGTBaseMetaTile(
+ int aNodeValue, BaseMetaTileEntity aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) {
super(aNodeValue, aTileEntity, aSide, aConsumers);
}
@Override
public int injectEnergy(long aVoltage, long aMaxAmps) {
- return (int)((IEnergyConnected) mTileEntity).injectEnergyUnits(mSide,aVoltage, aMaxAmps);
+ return (int) ((IEnergyConnected) mTileEntity).injectEnergyUnits(mSide, aVoltage, aMaxAmps);
}
@Override
diff --git a/src/main/java/gregtech/api/graphs/paths/NodePath.java b/src/main/java/gregtech/api/graphs/paths/NodePath.java
index 3a4bbed8c6..d5a179b24b 100644
--- a/src/main/java/gregtech/api/graphs/paths/NodePath.java
+++ b/src/main/java/gregtech/api/graphs/paths/NodePath.java
@@ -4,7 +4,7 @@ import gregtech.api.graphs.Lock;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
-//to contain all info about the path between nodes
+// to contain all info about the path between nodes
public class NodePath {
protected MetaPipeEntity[] mPipes;
public Lock lock = new Lock();
diff --git a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java
index d18d6bcdd3..3ab8c7fe03 100644
--- a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java
+++ b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java
@@ -16,7 +16,6 @@ public class PowerNodePath extends NodePath {
int mTick = 0;
boolean mCountUp = true;
-
public PowerNodePath(MetaPipeEntity[] aCables) {
super(aCables);
}