Added a read and write method to NetworkTile class

Should allow networks that extend this to read and write data from there
tiles when its called. Mainly used to store important info in tiles
while merging or splitting a network. However, it is used by
NetworkFluidTiles class in FM for reading/writing fluid volumes to the
tiles.
This commit is contained in:
DarkGuardsman 2013-07-29 02:32:52 -04:00
parent ced2f8f142
commit 38e0833a21

View file

@ -25,15 +25,21 @@ public abstract class NetworkTileEntities
this.networkMember.addAll(Arrays.asList(parts));
}
/** Should be called after a network is created from a split or merge */
public void init()
{
cleanUpMembers();
}
/** Creates a new instance of this network to be used to merge or split networks while still
* maintaining each class that extends the base network class
*
*
* @return - new network instance using the current networks properties */
public abstract NetworkTileEntities newInstance();
/** Adds a TileEntity to the network. extends this to catch non-network parts and add them to
* other tile lists
*
*
* @param tileEntity - tileEntity instance
* @param member - add to network member list
* @return */
@ -127,9 +133,22 @@ public abstract class NetworkTileEntities
return this.networkMember;
}
/** Override this to write any data to the time. Called before a merge, split, or major edit of the
* network */
public void writeDataToTiles()
{
}
/** Override this to write any data to the time. Called after a merge, split, or major edit of the
* network */
public void readDataFromTiles()
{
}
/** Combines two networks together into one. Calls to preMerge and doMerge instead of doing the
* merge process itself
*
*
* @param network
* @param mergePoint */
public void merge(NetworkTileEntities network, INetworkPart mergePoint)
@ -145,20 +164,21 @@ public abstract class NetworkTileEntities
/** Processing that needs too be done before the network merges. Use this to do final network
* merge calculations and to cause network merge failure
*
*
* @param network the network that is to merge with this one
* @param part the part at which started the network merge. Use this to cause damage if two
* networks merge with real world style failures
*
*
* @return false if the merge needs to be canceled.
*
*
* Cases in which the network should fail to merge are were the two networks merge with error.
* Or, in the case of pipes the two networks merge and the merge point was destroyed by
* combination of liquids.
*
*
* Ex Lava and water */
public boolean preMergeProcessing(NetworkTileEntities network, INetworkPart part)
{
this.writeDataToTiles();
return true;
}
@ -168,6 +188,7 @@ public abstract class NetworkTileEntities
NetworkTileEntities newNetwork = this.newInstance();
newNetwork.getNetworkMemebers().addAll(this.getNetworkMemebers());
newNetwork.getNetworkMemebers().addAll(network.getNetworkMemebers());
newNetwork.readDataFromTiles();
newNetwork.init();
}
@ -238,12 +259,6 @@ public abstract class NetworkTileEntities
}
}
/** Should be called after a network is created from a split or merge */
public void init()
{
cleanUpMembers();
}
@Override
public String toString()
{
@ -251,7 +266,7 @@ public abstract class NetworkTileEntities
}
/** invalidates/remove a tile from the networks that surround and connect to it
*
*
* @param tileEntity - tile */
public static void invalidate(TileEntity tileEntity)
{