diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-20 00:30:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-20 09:30:50 +0100 |
commit | 7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb (patch) | |
tree | bea33f6637b929427e9abbe733e19606f8bf9032 /src/main/java/gregtech/api/graphs | |
parent | 750a4070af4756e3708e2b2555b9874864bf3cfb (diff) | |
download | GT5-Unofficial-7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb.tar.gz GT5-Unofficial-7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb.tar.bz2 GT5-Unofficial-7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb.zip |
MTE Inventory updates (#1496)
* MTE Inventory updates
* Separate Input/Output inventory
* Use a LinkedHashMap to ensure inventory orders are deterministic
* Input/Output work on either Input/Output inventories
* MTE Inventory
* Add GT_Packet_MultiTileEntity
* More dyanmic packet with packetFeatures
* Add IMTE_HasModes for MultiBlockPart
* Help with MTE Inventory (#1613)
* convert inventory to use ItemStackHandler
* Update MUI
* inventories
* move Iteminventory to its own method
Co-authored-by: miozune <miozune@gmail.com>
* Update MUI
* Update MUI
* Add IMultiBlockPart
* Mte fluid inventory (#1639)
* first work on fluid inventory
* make gui work with numbers not dividable by 4
* use math.min
* add outputfluids saving
* actually working
* Update MUI
Co-authored-by: miozune <miozune@gmail.com>
* Ticking Covers!
* Parts now register covers with the controller
* Controllers now tick covers on parts
* Break cover ticking out into `tickCoverAtSide`
Fix some inventory methods on MultiBlockController
* Filter on tickable covers
* Improve GUIs for MTEs (#1650)
* working controller GUI
* locked inventory selection work
* input and output locking of inventories
Co-authored-by: miozune <miozune@gmail.com>
* spotless
* CoverInfo refactor (#1654)
* Add `CoverInfo` and deprecate the old fields to hold cover information
* Disable MTE registration
* Fix NPE - Return EMPTY_INFO for SIDE_UNKNOWN
Temporarily add back old NBT saving in case of a revert so covers aren't lost.
* Actually save the old NBT data, instead of empty
Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com>
Co-authored-by: miozune <miozune@gmail.com>
Diffstat (limited to 'src/main/java/gregtech/api/graphs')
-rw-r--r-- | src/main/java/gregtech/api/graphs/GenerateNodeMap.java | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java index c0ee8b9490..8085421576 100644 --- a/src/main/java/gregtech/api/graphs/GenerateNodeMap.java +++ b/src/main/java/gregtech/api/graphs/GenerateNodeMap.java @@ -1,5 +1,6 @@ package gregtech.api.graphs; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.util.GT_Utility.getOppositeSide; import gregtech.api.graphs.consumers.ConsumerNode; @@ -15,7 +16,7 @@ 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) { - BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aNode.mTileEntity; + final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aNode.mTileEntity; tPipe.setNode(null); tPipe.setNodePath(null); if (aNode.mSelfPath != null) { @@ -23,24 +24,24 @@ public abstract class GenerateNodeMap { aNode.mSelfPath = null; } } - for (int i = 0; i < 6; i++) { - NodePath tPath = aNode.mNodePaths[i]; + for (byte side : ALL_VALID_SIDES) { + final NodePath tPath = aNode.mNodePaths[side]; if (tPath != null) { tPath.clearPath(); - aNode.mNodePaths[i] = null; + aNode.mNodePaths[side] = null; } - Node tNextNode = aNode.mNeighbourNodes[i]; + final Node tNextNode = aNode.mNeighbourNodes[side]; if (tNextNode == null) continue; if (tNextNode.mNodeValue != aReturnNodeValue) clearNodeMap(tNextNode, aNode.mNodeValue); - aNode.mNeighbourNodes[i] = null; + aNode.mNeighbourNodes[side] = null; } } // get how many connections the pipe have private static int getNumberOfConnections(MetaPipeEntity aPipe) { int tCons = 0; - for (int i = 0; i < 6; i++) { - if (aPipe.isConnectedAtSide(i)) tCons++; + for (byte side : ALL_VALID_SIDES) { + if (aPipe.isConnectedAtSide(side)) tCons++; } return tCons; } @@ -53,17 +54,17 @@ public abstract class GenerateNodeMap { int aNextNodeValue, ArrayList<ConsumerNode> tConsumers, HashSet<Node> tNodeMap) { - MetaPipeEntity tMetaPipe = (MetaPipeEntity) aPipe.getMetaTileEntity(); - for (byte i = 0; i < 6; i++) { - if (i == aInvalidSide) { + final MetaPipeEntity tMetaPipe = (MetaPipeEntity) aPipe.getMetaTileEntity(); + for (byte side : ALL_VALID_SIDES) { + if (side == aInvalidSide) { continue; } - TileEntity tNextTileEntity = aPipe.getTileEntityAtSide(i); - if (tNextTileEntity == null || (tMetaPipe != null && !tMetaPipe.isConnectedAtSide(i))) continue; - ArrayList<MetaPipeEntity> tNewPipes = new ArrayList<>(); - Pair nextTileEntity = getNextValidTileEntity(tNextTileEntity, tNewPipes, i, tNodeMap); + final TileEntity tNextTileEntity = aPipe.getTileEntityAtSide(side); + if (tNextTileEntity == null || (tMetaPipe != null && !tMetaPipe.isConnectedAtSide(side))) continue; + final ArrayList<MetaPipeEntity> tNewPipes = new ArrayList<>(); + final Pair nextTileEntity = getNextValidTileEntity(tNextTileEntity, tNewPipes, side, tNodeMap); if (nextTileEntity != null) { - Node tNextNode = generateNode( + final Node tNextNode = generateNode( nextTileEntity.mTileEntity, aPipeNode, aNextNodeValue + 1, @@ -74,10 +75,10 @@ public abstract class GenerateNodeMap { if (tNextNode != null) { aNextNodeValue = tNextNode.mHighestNodeValue; aPipeNode.mHighestNodeValue = tNextNode.mHighestNodeValue; - aPipeNode.mNeighbourNodes[i] = tNextNode; - aPipeNode.mNodePaths[i] = aPipeNode.returnValues.mReturnPath; - aPipeNode.locks[i] = aPipeNode.returnValues.returnLock; - aPipeNode.mNodePaths[i].reloadLocks(); + aPipeNode.mNeighbourNodes[side] = tNextNode; + aPipeNode.mNodePaths[side] = aPipeNode.returnValues.mReturnPath; + aPipeNode.locks[side] = aPipeNode.returnValues.returnLock; + aPipeNode.mNodePaths[side].reloadLocks(); } } } @@ -94,14 +95,14 @@ public abstract class GenerateNodeMap { ArrayList<ConsumerNode> aConsumers, HashSet<Node> aNodeMap) { if (aTileEntity.isInvalid()) return null; - byte tSideOp = getOppositeSide(aSide); - byte tInvalidSide = aPreviousNode == null ? -1 : tSideOp; + final byte tSideOp = getOppositeSide(aSide); + final byte tInvalidSide = aPreviousNode == null ? -1 : tSideOp; Node tThisNode = null; if (isPipe(aTileEntity)) { - BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; - MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity(); - int tConnections = getNumberOfConnections(tMetaPipe); - Node tPipeNode; + final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; + final MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity(); + final int tConnections = getNumberOfConnections(tMetaPipe); + final Node tPipeNode; if (tConnections == 1) { tPipeNode = getEmptyNode(aNextNodeValue, tSideOp, aTileEntity, aConsumers); if (tPipeNode == null) return null; @@ -115,7 +116,7 @@ public abstract class GenerateNodeMap { if (tInvalidSide > -1) { tPipeNode.mNeighbourNodes[tInvalidSide] = aPreviousNode; tPipeNode.mNodePaths[tInvalidSide] = getNewPath(aPipes.toArray(new MetaPipeEntity[0])); - Lock lock = new Lock(); + final Lock lock = new Lock(); tPipeNode.mNodePaths[tSideOp].lock = lock; tPipeNode.locks[tInvalidSide] = lock; aPreviousNode.returnValues.mReturnPath = tPipeNode.mNodePaths[tInvalidSide]; @@ -124,10 +125,10 @@ public abstract class GenerateNodeMap { if (tConnections > 1) generateNextNode(tPipe, tPipeNode, tInvalidSide, aNextNodeValue, aConsumers, aNodeMap); } else if (addConsumer(aTileEntity, tSideOp, aNextNodeValue, aConsumers)) { - ConsumerNode tConsumeNode = aConsumers.get(aConsumers.size() - 1); + final ConsumerNode tConsumeNode = aConsumers.get(aConsumers.size() - 1); tConsumeNode.mNeighbourNodes[tSideOp] = aPreviousNode; tConsumeNode.mNodePaths[tSideOp] = getNewPath(aPipes.toArray(new MetaPipeEntity[0])); - Lock lock = new Lock(); + final Lock lock = new Lock(); tConsumeNode.mNodePaths[tSideOp].lock = lock; aPreviousNode.returnValues.mReturnPath = tConsumeNode.mNodePaths[tSideOp]; aPreviousNode.returnValues.returnLock = lock; @@ -140,18 +141,18 @@ public abstract class GenerateNodeMap { 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(); + final BaseMetaPipeEntity tPipe = (BaseMetaPipeEntity) aTileEntity; + final MetaPipeEntity tMetaPipe = (MetaPipeEntity) tPipe.getMetaTileEntity(); + final Node tNode = tPipe.getNode(); if (tNode != null) { if (aNodeMap.contains(tNode)) return null; } - int tConnections = getNumberOfConnections(tMetaPipe); + final int tConnections = getNumberOfConnections(tMetaPipe); if (tConnections == 2) { - byte tSideOp = getOppositeSide(aSide); - for (byte i = 0; i < 6; i++) { + final byte tSideOp = getOppositeSide(aSide); + for (byte i : ALL_VALID_SIDES) { if (i == tSideOp || !(tMetaPipe.isConnectedAtSide(i))) continue; - TileEntity tNewTileEntity = tPipe.getTileEntityAtSide(i); + final TileEntity tNewTileEntity = tPipe.getTileEntityAtSide(i); if (tNewTileEntity == null) continue; if (isPipe(tNewTileEntity)) { aPipes.add(tMetaPipe); |