Updated UE
This commit is contained in:
parent
29d55d3aa8
commit
afd1bbde71
5 changed files with 21 additions and 234 deletions
|
@ -48,7 +48,7 @@ public class BatteryStructure extends Structure<TileBattery>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void refreshNode(TileBattery node)
|
protected void reconstructNode(TileBattery node)
|
||||||
{
|
{
|
||||||
node.setNetwork(this);
|
node.setNetwork(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,132 +177,6 @@ public abstract class FluidNetwork extends Network<IFluidNetwork, IFluidConnecto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IFluidNetwork merge(IFluidNetwork network)
|
|
||||||
{
|
|
||||||
FluidNetwork newNetwork = null;
|
|
||||||
if (network != null && network.getClass().isAssignableFrom(this.getClass()) && network != this)
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
newNetwork = this.getClass().newInstance();
|
|
||||||
|
|
||||||
newNetwork.getConnectors().addAll(this.getConnectors());
|
|
||||||
newNetwork.getConnectors().addAll(network.getConnectors());
|
|
||||||
|
|
||||||
network.getConnectors().clear();
|
|
||||||
network.getNodes().clear();
|
|
||||||
this.getConnectors().clear();
|
|
||||||
this.getNodes().clear();
|
|
||||||
|
|
||||||
newNetwork.reconstruct();
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return newNetwork;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void split(IFluidConnector splitPoint)
|
|
||||||
{
|
|
||||||
this.removeConnector(splitPoint);
|
|
||||||
this.reconstruct();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loop through the connected blocks and attempt to see if there are connections between the
|
|
||||||
* two points elsewhere.
|
|
||||||
*/
|
|
||||||
Object[] connectedBlocks = splitPoint.getConnections();
|
|
||||||
|
|
||||||
for (int i = 0; i < connectedBlocks.length; i++)
|
|
||||||
{
|
|
||||||
Object connectedBlockA = connectedBlocks[i];
|
|
||||||
|
|
||||||
if (connectedBlockA instanceof IFluidConnector)
|
|
||||||
{
|
|
||||||
for (int ii = 0; ii < connectedBlocks.length; ii++)
|
|
||||||
{
|
|
||||||
final Object connectedBlockB = connectedBlocks[ii];
|
|
||||||
|
|
||||||
if (connectedBlockA != connectedBlockB && connectedBlockB instanceof IFluidConnector)
|
|
||||||
{
|
|
||||||
ConnectionPathfinder finder = new ConnectionPathfinder((IFluidConnector) connectedBlockB, splitPoint);
|
|
||||||
finder.findNodes((IFluidConnector) connectedBlockA);
|
|
||||||
|
|
||||||
if (finder.results.size() <= 0)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The connections A and B are not connected anymore. Give them both
|
|
||||||
* a new common network.
|
|
||||||
*/
|
|
||||||
IFluidNetwork newNetwork = this.getClass().newInstance();
|
|
||||||
|
|
||||||
for (IConnector node : finder.closedSet)
|
|
||||||
{
|
|
||||||
if (node != splitPoint && node instanceof IFluidConnector)
|
|
||||||
{
|
|
||||||
newNetwork.addConnector((IFluidConnector) node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newNetwork.reconstruct();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void split(IFluidConnector connectorA, IFluidConnector connectorB)
|
|
||||||
{
|
|
||||||
this.reconstruct();
|
|
||||||
|
|
||||||
/** Check if connectorA connects with connectorB. */
|
|
||||||
ConnectionPathfinder finder = new ConnectionPathfinder(connectorB);
|
|
||||||
finder.findNodes(connectorA);
|
|
||||||
|
|
||||||
if (finder.results.size() <= 0)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The connections A and B are not connected anymore. Give them both a new common
|
|
||||||
* network.
|
|
||||||
*/
|
|
||||||
IFluidNetwork newNetwork;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
newNetwork = this.getClass().newInstance();
|
|
||||||
|
|
||||||
for (IConnector node : finder.closedSet)
|
|
||||||
{
|
|
||||||
if (node instanceof IFluidConnector)
|
|
||||||
{
|
|
||||||
newNetwork.addConnector((IFluidConnector) node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newNetwork.reconstruct();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidTank getTank()
|
public FluidTank getTank()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
import resonantinduction.api.fluid.IFluidConnector;
|
import resonantinduction.api.fluid.IFluidConnector;
|
||||||
|
import resonantinduction.api.fluid.IFluidNetwork;
|
||||||
import resonantinduction.api.fluid.IFluidPipe;
|
import resonantinduction.api.fluid.IFluidPipe;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import calclavia.lib.utility.FluidUtility;
|
import calclavia.lib.utility.FluidUtility;
|
||||||
|
@ -120,4 +121,10 @@ public class PipeNetwork extends FluidNetwork
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IFluidNetwork newInstance()
|
||||||
|
{
|
||||||
|
return new PipeNetwork();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Set;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import resonantinduction.api.fluid.IFluidConnector;
|
import resonantinduction.api.fluid.IFluidConnector;
|
||||||
|
import resonantinduction.api.fluid.IFluidNetwork;
|
||||||
import resonantinduction.mechanical.fluid.network.FluidNetwork;
|
import resonantinduction.mechanical.fluid.network.FluidNetwork;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,4 +70,10 @@ public class TankNetwork extends FluidNetwork
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IFluidNetwork newInstance()
|
||||||
|
{
|
||||||
|
return new TankNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,112 +246,6 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMechanicalNetwork merge(IMechanicalNetwork network)
|
|
||||||
{
|
|
||||||
if (network.getClass().isAssignableFrom(this.getClass()) && network != this)
|
|
||||||
{
|
|
||||||
MechanicalNetwork newNetwork = new MechanicalNetwork();
|
|
||||||
newNetwork.getConnectors().addAll(this.getConnectors());
|
|
||||||
newNetwork.getConnectors().addAll(network.getConnectors());
|
|
||||||
network.getConnectors().clear();
|
|
||||||
network.getNodes().clear();
|
|
||||||
this.getConnectors().clear();
|
|
||||||
this.getNodes().clear();
|
|
||||||
|
|
||||||
newNetwork.reconstruct();
|
|
||||||
return newNetwork;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void split(IMechanicalConnector splitPoint)
|
|
||||||
{
|
|
||||||
this.removeConnector(splitPoint);
|
|
||||||
this.reconstruct();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loop through the connected blocks and attempt to see if there are connections between the
|
|
||||||
* two points elsewhere.
|
|
||||||
*/
|
|
||||||
Object[] connectedBlocks = splitPoint.getConnections();
|
|
||||||
|
|
||||||
for (int i = 0; i < connectedBlocks.length; i++)
|
|
||||||
{
|
|
||||||
Object connectedBlockA = connectedBlocks[i];
|
|
||||||
|
|
||||||
if (connectedBlockA instanceof IMechanicalConnector)
|
|
||||||
{
|
|
||||||
for (int ii = 0; ii < connectedBlocks.length; ii++)
|
|
||||||
{
|
|
||||||
final Object connectedBlockB = connectedBlocks[ii];
|
|
||||||
|
|
||||||
if (connectedBlockA != connectedBlockB && connectedBlockB instanceof IMechanicalConnector)
|
|
||||||
{
|
|
||||||
ConnectionPathfinder finder = new ConnectionPathfinder((IConnector) connectedBlockB, splitPoint);
|
|
||||||
finder.findNodes((IConnector) connectedBlockA);
|
|
||||||
|
|
||||||
if (finder.results.size() <= 0)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The connections A and B are not connected anymore. Give them both
|
|
||||||
* a new common network.
|
|
||||||
*/
|
|
||||||
IMechanicalNetwork newNetwork = new MechanicalNetwork();
|
|
||||||
for (IConnector node : finder.closedSet)
|
|
||||||
{
|
|
||||||
if (node != splitPoint && node instanceof IMechanicalConnector)
|
|
||||||
{
|
|
||||||
newNetwork.addConnector((IMechanicalConnector) node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newNetwork.reconstruct();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void split(IMechanicalConnector connectorA, IMechanicalConnector connectorB)
|
|
||||||
{
|
|
||||||
this.reconstruct();
|
|
||||||
|
|
||||||
/** Check if connectorA connects with connectorB. */
|
|
||||||
ConnectionPathfinder finder = new ConnectionPathfinder(connectorB);
|
|
||||||
finder.findNodes(connectorA);
|
|
||||||
|
|
||||||
if (finder.results.size() <= 0)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The connections A and B are not connected anymore. Give them both a new common
|
|
||||||
* network.
|
|
||||||
*/
|
|
||||||
IMechanicalNetwork newNetwork = new MechanicalNetwork();
|
|
||||||
|
|
||||||
for (IConnector node : finder.closedSet)
|
|
||||||
{
|
|
||||||
if (node instanceof IMechanicalConnector)
|
|
||||||
{
|
|
||||||
newNetwork.addConnector((IMechanicalConnector) node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newNetwork.reconstruct();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getRotation()
|
public float getRotation()
|
||||||
{
|
{
|
||||||
|
@ -366,10 +260,15 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalCo
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMechanicalNetwork newInstance()
|
||||||
|
{
|
||||||
|
return new MechanicalNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return this.getClass().getSimpleName() + "[" + this.hashCode() + ", Handlers: " + getNodes().size() + ", Connectors: " + getConnectors().size() + ", Power:" + getPower() + "]";
|
return this.getClass().getSimpleName() + "[" + this.hashCode() + ", Handlers: " + getNodes().size() + ", Connectors: " + getConnectors().size() + ", Power:" + getPower() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue