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,6 +25,12 @@ 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
*
@ -127,6 +133,19 @@ 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
*
@ -159,6 +178,7 @@ public abstract class NetworkTileEntities
* 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()
{