diff options
Diffstat (limited to 'src/main/java/gregtech/api/graphs')
15 files changed, 160 insertions, 153 deletions
diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java index 8085421576..fba74b0aec 100644 --- a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java +++ b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java @@ -3,16 +3,19 @@ package gregtech.api.graphs; import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.util.GT_Utility.getOppositeSide; +import java.util.ArrayList; +import java.util.HashSet; + +import net.minecraft.tileentity.TileEntity; + import gregtech.api.graphs.consumers.ConsumerNode; import gregtech.api.graphs.paths.NodePath; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; -import java.util.ArrayList; -import java.util.HashSet; -import net.minecraft.tileentity.TileEntity; // generates the node map 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) { @@ -47,13 +50,8 @@ public abstract 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) { final MetaPipeEntity tMetaPipe = (MetaPipeEntity) aPipe.getMetaTileEntity(); for (byte side : ALL_VALID_SIDES) { if (side == aInvalidSide) { @@ -86,14 +84,8 @@ public abstract 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; final byte tSideOp = getOppositeSide(aSide); final byte tInvalidSide = aPreviousNode == null ? -1 : tSideOp; @@ -111,7 +103,7 @@ public abstract 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; @@ -138,8 +130,8 @@ public abstract 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)) { final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; final MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity(); @@ -176,15 +168,15 @@ public abstract class GenerateNodeMap { } // checks if the tile entity is a consumer and add to the list - protected abstract 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 + // 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; } @@ -194,6 +186,7 @@ public abstract class GenerateNodeMap { } private static class Pair { + public byte mSide; public TileEntity mTileEntity; diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java b/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java index 293a46502a..62dfa2d8ea 100644 --- a/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java +++ b/src/main/java/gregtech/api/graphs/GenerateNodeMapPower.java @@ -1,5 +1,11 @@ package gregtech.api.graphs; +import java.util.ArrayList; +import java.util.HashSet; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + import cofh.api.energy.IEnergyReceiver; import gregtech.api.GregTech_API; import gregtech.api.graphs.consumers.ConsumerNode; @@ -16,13 +22,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 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 { + public GenerateNodeMapPower(BaseMetaPipeEntity aTileEntity) { generateNode(aTileEntity, null, 1, null, -1, new ArrayList<>(), new HashSet<>()); } @@ -34,8 +37,8 @@ public class GenerateNodeMapPower extends GenerateNodeMap { } @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)) { @@ -63,14 +66,20 @@ 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; } @@ -84,8 +93,8 @@ public class GenerateNodeMapPower extends GenerateNodeMap { // 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 e89cc8b25c..d3c8c49169 100644 --- a/src/main/java/gregtech/api/graphs/Lock.java +++ b/src/main/java/gregtech/api/graphs/Lock.java @@ -1,9 +1,11 @@ package gregtech.api.graphs; import java.util.ArrayList; + import net.minecraft.tileentity.TileEntity; public class Lock { + protected ArrayList<TileEntity> tiles = new ArrayList<>(); public void addTileEntity(TileEntity tileEntity) { diff --git a/src/main/java/gregtech/api/graphs/Node.java b/src/main/java/gregtech/api/graphs/Node.java index f6a3ebe2d2..21b9937191 100644 --- a/src/main/java/gregtech/api/graphs/Node.java +++ b/src/main/java/gregtech/api/graphs/Node.java @@ -1,13 +1,16 @@ 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 gregtech.api.graphs.consumers.ConsumerNode; +import gregtech.api.graphs.paths.NodePath; + // base Node class public class Node { + public Node(int aNodeValue, TileEntity aTileEntity, ArrayList<ConsumerNode> aConsumers) { this.mNodeValue = aNodeValue; this.mTileEntity = aTileEntity; @@ -29,6 +32,7 @@ public class Node { public int mHighestNodeValue; public class ReturnPair { + public NodePath mReturnPath; public Lock returnLock; } diff --git a/src/main/java/gregtech/api/graphs/NodeList.java b/src/main/java/gregtech/api/graphs/NodeList.java index 8a018e2123..899384b3d4 100644 --- a/src/main/java/gregtech/api/graphs/NodeList.java +++ b/src/main/java/gregtech/api/graphs/NodeList.java @@ -2,6 +2,7 @@ package gregtech.api.graphs; // keep track on which node is being looked for across the recursive functions public class NodeList { + Node[] mNodes; int mCounter = 0; diff --git a/src/main/java/gregtech/api/graphs/PowerNode.java b/src/main/java/gregtech/api/graphs/PowerNode.java index c81d436861..75a8e8d73b 100644 --- a/src/main/java/gregtech/api/graphs/PowerNode.java +++ b/src/main/java/gregtech/api/graphs/PowerNode.java @@ -1,11 +1,14 @@ package gregtech.api.graphs; -import gregtech.api.graphs.consumers.ConsumerNode; import java.util.ArrayList; + import net.minecraft.tileentity.TileEntity; +import gregtech.api.graphs.consumers.ConsumerNode; + // base node for power networks public class PowerNode extends Node { + public boolean mHadVoltage = false; public PowerNode(int aNodeValue, TileEntity aTileEntity, ArrayList<ConsumerNode> aConsumers) { diff --git a/src/main/java/gregtech/api/graphs/PowerNodes.java b/src/main/java/gregtech/api/graphs/PowerNodes.java index 759002dbdb..12416f6d72 100644 --- a/src/main/java/gregtech/api/graphs/PowerNodes.java +++ b/src/main/java/gregtech/api/graphs/PowerNodes.java @@ -3,27 +3,20 @@ package gregtech.api.graphs; import gregtech.api.graphs.consumers.ConsumerNode; import gregtech.api.graphs.paths.PowerNodePath; -/* look for and power node that need power - * - * how this works - * - * a node only contains nodes that has a higher value then it self except for 1 which is the return node - * this node also contains the highest known node value of its network - * this network only includes nodes that have a higher value then it self so it does not know the highest known value that - * the return node knows - * - * with these rules we can know for the target node to be in the network of a node, the target node must have a value no - * less than the node we are looking and no greater than the highest value that node knows - * this way we don't have to go over the entire network to look for it - * - * we also hold a list of all consumers so we can check before looking if that consumer actually needs power - * and only look for nodes that actually need power - * +/* + * look for and power node that need power how this works a node only contains nodes that has a higher value then it + * self except for 1 which is the return node this node also contains the highest known node value of its network this + * network only includes nodes that have a higher value then it self so it does not know the highest known value that + * the return node knows with these rules we can know for the target node to be in the network of a node, the target + * node must have a value no less than the node we are looking and no greater than the highest value that node knows + * this way we don't have to go over the entire network to look for it we also hold a list of all consumers so we can + * check before looking if that consumer actually needs power and only look for nodes that actually need power */ public class PowerNodes { + // check if the looked for node is next to or get the next node that is closer to it - public static 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; @@ -41,7 +34,12 @@ public class PowerNodes { } else { if (aPreviousNode == tNextNode) return tAmpsUsed; tAmpsUsed += processNextNode( - aCurrentNode, tNextNode, aConsumers, j, aMaxAmps - tAmpsUsed, aVoltage); + aCurrentNode, + tNextNode, + aConsumers, + j, + aMaxAmps - tAmpsUsed, + aVoltage); tConsumer = (ConsumerNode) aConsumers.getNode(); break; } @@ -55,7 +53,12 @@ public class PowerNodes { if (tNextNode.mNodeValue > aCurrentNode.mNodeValue && tNextNode.mNodeValue < tTargetNodeValue) { if (tNextNode == aPreviousNode) return tAmpsUsed; tAmpsUsed += processNextNodeAbove( - aCurrentNode, tNextNode, aConsumers, side, aMaxAmps - tAmpsUsed, aVoltage); + aCurrentNode, + tNextNode, + aConsumers, + side, + aMaxAmps - tAmpsUsed, + aVoltage); tConsumer = (ConsumerNode) aConsumers.getNode(); break; } else if (tNextNode.mNodeValue == tTargetNodeValue) { @@ -77,8 +80,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(); @@ -93,7 +96,12 @@ public class PowerNodes { if (tNextNode.mNodeValue > aCurrentNode.mNodeValue && tNextNode.mNodeValue < tTargetNodeValue) { if (tNextNode == aPreviousNode) return tAmpsUsed; tAmpsUsed += processNextNodeAbove( - aCurrentNode, tNextNode, aConsumers, side, aMaxAmps - tAmpsUsed, aVoltage); + aCurrentNode, + tNextNode, + aConsumers, + side, + aMaxAmps - tAmpsUsed, + aVoltage); tConsumer = (ConsumerNode) aConsumers.getNode(); break; } else if (tNextNode.mNodeValue == tTargetNodeValue) { @@ -113,8 +121,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; @@ -134,8 +142,8 @@ public class PowerNodes { 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; @@ -155,8 +163,8 @@ public class PowerNodes { 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; diff --git a/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java b/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java index 78b3c51928..f82798f09b 100644 --- a/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java +++ b/src/main/java/gregtech/api/graphs/consumers/ConsumerNode.java @@ -1,11 +1,14 @@ package gregtech.api.graphs.consumers; -import gregtech.api.graphs.Node; import java.util.ArrayList; + import net.minecraft.tileentity.TileEntity; +import gregtech.api.graphs.Node; + // 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) { diff --git a/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java b/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java index d5ff76c12b..6507d0f8e4 100644 --- a/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java +++ b/src/main/java/gregtech/api/graphs/consumers/EmptyPowerConsumer.java @@ -1,12 +1,15 @@ package gregtech.api.graphs.consumers; -import gregtech.api.graphs.paths.PowerNodePath; -import gregtech.api.metatileentity.BaseMetaPipeEntity; import java.util.ArrayList; + import net.minecraft.tileentity.TileEntity; +import gregtech.api.graphs.paths.PowerNodePath; +import gregtech.api.metatileentity.BaseMetaPipeEntity; + // 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); } diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java index 30582332e7..bd2087de84 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyConnected.java @@ -1,12 +1,15 @@ package gregtech.api.graphs.consumers; -import gregtech.api.interfaces.tileentity.IEnergyConnected; import java.util.ArrayList; + import net.minecraft.tileentity.TileEntity; +import gregtech.api.interfaces.tileentity.IEnergyConnected; + public class NodeEnergyConnected extends ConsumerNode { - public NodeEnergyConnected( - int aNodeValue, IEnergyConnected aTileEntity, byte aSide, ArrayList<ConsumerNode> aConsumers) { + + public NodeEnergyConnected(int aNodeValue, IEnergyConnected aTileEntity, byte aSide, + ArrayList<ConsumerNode> aConsumers) { super(aNodeValue, (TileEntity) aTileEntity, aSide, aConsumers); } diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java index 9c5e3f8aab..eec63cf935 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java @@ -2,6 +2,13 @@ package gregtech.api.graphs.consumers; import static gregtech.api.enums.GT_Values.V; +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 cofh.api.energy.IEnergyReceiver; import gregtech.GT_Mod; import gregtech.api.GregTech_API; @@ -9,18 +16,14 @@ 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; // 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); } @@ -38,8 +41,7 @@ public class NodeEnergyReceiver extends ConsumerNode { mRestRF -= consumed; return ampsUsed; } - if (GregTech_API.mRFExplosions - && GregTech_API.sMachineExplosions + if (GregTech_API.mRFExplosions && GregTech_API.sMachineExplosions && ((IEnergyReceiver) mTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600L) { explode(rfOut); } @@ -50,77 +52,45 @@ public class NodeEnergyReceiver extends ConsumerNode { 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 + 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 + < V[9] ? 12.0F : aExplosionPower - < V[ - 11] - ? 14.0F - : aExplosionPower - < V[ - 12] - ? 15.0F + < V[10] ? 13.0F : aExplosionPower - < V[ - 12] - * 2 - ? 16.0F - : aExplosionPower - < V[ - 13] - ? 17.0F + < V[11] ? 14.0F : aExplosionPower - < V[ - 14] - ? 18.0F - : aExplosionPower - < V[ - 15] - ? 19.0F - : 20.0F; + < 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); + if (GregTech_API.sMachineExplosions) if (GT_Mod.gregtechproxy.mPollution) GT_Pollution + .addPollution(tWorld.getChunkFromBlockCoords(tX, tZ), GT_Mod.gregtechproxy.mPollutionOnExplosion); - new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder() - .setStrength(tStrength) - .setSmoking(true) - .setPosition(tX + 0.5, tY + 0.5, tZ + 0.5) - .setWorld(tWorld) - .run(); + new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder().setStrength(tStrength).setSmoking(true) + .setPosition(tX + 0.5, tY + 0.5, tZ + 0.5).setWorld(tWorld).run(); } } } diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java index 95b16883af..16b8f99939 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergySink.java @@ -1,12 +1,15 @@ 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 ic2.api.energy.tile.IEnergySink; + // consumer for IC2 machines public class NodeEnergySink extends ConsumerNode { + public NodeEnergySink(int nodeValue, IEnergySink tileEntity, byte side, ArrayList<ConsumerNode> consumers) { super(nodeValue, (TileEntity) tileEntity, side, consumers); } @@ -19,10 +22,10 @@ public class NodeEnergySink extends ConsumerNode { @Override public int injectEnergy(long aVoltage, long aMaxAmps) { int tUsedAmps = 0; - while (aMaxAmps > tUsedAmps - && ((IEnergySink) mTileEntity).getDemandedEnergy() > 0 + while (aMaxAmps > tUsedAmps && ((IEnergySink) mTileEntity).getDemandedEnergy() > 0 && ((IEnergySink) mTileEntity).injectEnergy(ForgeDirection.getOrientation(mSide), aVoltage, aVoltage) - < aVoltage) tUsedAmps++; + < 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 e367a5294e..19a2478c07 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeGTBaseMetaTile.java @@ -1,13 +1,15 @@ package gregtech.api.graphs.consumers; +import java.util.ArrayList; + import gregtech.api.interfaces.tileentity.IEnergyConnected; import gregtech.api.metatileentity.BaseMetaTileEntity; -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); } diff --git a/src/main/java/gregtech/api/graphs/paths/NodePath.java b/src/main/java/gregtech/api/graphs/paths/NodePath.java index d5a179b24b..0e852bd484 100644 --- a/src/main/java/gregtech/api/graphs/paths/NodePath.java +++ b/src/main/java/gregtech/api/graphs/paths/NodePath.java @@ -6,6 +6,7 @@ import gregtech.api.metatileentity.MetaPipeEntity; // 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 3ab8c7fe03..1601d3b28d 100644 --- a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java +++ b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java @@ -1,13 +1,15 @@ package gregtech.api.graphs.paths; +import net.minecraft.server.MinecraftServer; + import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; -import net.minecraft.server.MinecraftServer; // path for cables // all calculations like amp and voltage happens here public class PowerNodePath extends NodePath { + long mMaxAmps; long mAmps = 0; long mLoss; |