Tile Network changes

This commit is contained in:
DarkGuardsman 2013-11-08 03:03:48 -05:00
parent 801cfaed63
commit 046438c2d3
3 changed files with 15 additions and 35 deletions

View file

@ -12,6 +12,7 @@ import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.vector.Vector3;
import dark.api.parts.INetworkEnergyPart;
import dark.api.parts.INetworkPart;
import dark.core.prefab.tilenetwork.NetworkHandler;
import dark.core.prefab.tilenetwork.NetworkSharedPower;
public class NetworkAssembly extends NetworkSharedPower
@ -38,18 +39,16 @@ public class NetworkAssembly extends NetworkSharedPower
public float maxDemand = 0;
/** lowest demand the network has seen */
public float minDemand = 0;
static
{
NetworkHandler.registerNetworkClass("AssemblyNet", NetworkAssembly.class);
}
public NetworkAssembly(INetworkPart... parts)
{
super(parts);
}
@Override
public NetworkAssembly newInstance()
{
return new NetworkAssembly();
}
/** Gets the demand of all parts of the network including network parts */
public float getNetworkDemand()
{
@ -104,7 +103,7 @@ public class NetworkAssembly extends NetworkSharedPower
lastTime = time;
}
for (INetworkPart part : this.getNetworkMemebers())
for (INetworkPart part : this.getMembers())
{
if (part instanceof TileEntityAssembly)
{
@ -184,17 +183,10 @@ public class NetworkAssembly extends NetworkSharedPower
return higher;
}
@Override
public boolean isPartOfNetwork(TileEntity ent)
{
//TODO check how this is used since it might only want network parts and not connections
return this.networkMember.contains(ent);
}
@Override
public boolean removeTile(TileEntity ent)
{
return this.networkMember.remove(ent) || this.powerLoads.remove(ent) || this.powerSources.remove(ent);
return super.removeTile(ent) || this.powerLoads.remove(ent) || this.powerSources.remove(ent);
}
@Override
@ -266,10 +258,4 @@ public class NetworkAssembly extends NetworkSharedPower
return super.isValidMember(part) && part instanceof TileEntityAssembly;
}
@Override
public String toString()
{
return "AssemblyNetwork[" + this.hashCode() + "][parts:" + this.networkMember.size() + "]";
}
}

View file

@ -10,6 +10,7 @@ import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.vector.Vector3;
import dark.api.parts.INetworkEnergyPart;
import dark.api.parts.ITileNetwork;
import dark.assembly.common.AssemblyLine;
import dark.core.prefab.machine.TileEntityEnergyMachine;
import dark.core.prefab.tilenetwork.NetworkSharedPower;
@ -50,7 +51,7 @@ public abstract class TileEntityAssembly extends TileEntityEnergyMachine impleme
NetworkTileEntities.invalidate(this);
if (this.getTileNetwork() != null)
{
this.getTileNetwork().splitNetwork(this.worldObj, this);
this.getTileNetwork().splitNetwork(this);
}
super.invalidate();
}
@ -95,7 +96,7 @@ public abstract class TileEntityAssembly extends TileEntityEnergyMachine impleme
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj);
if (tileEntity instanceof TileEntityAssembly && ((TileEntityAssembly) tileEntity).canTileConnect(Connection.NETWORK, dir.getOpposite()))
{
this.getTileNetwork().merge(((TileEntityAssembly) tileEntity).getTileNetwork(), this);
this.getTileNetwork().mergeNetwork(((TileEntityAssembly) tileEntity).getTileNetwork(), this);
connectedTiles.add(tileEntity);
}
}
@ -119,7 +120,7 @@ public abstract class TileEntityAssembly extends TileEntityEnergyMachine impleme
}
@Override
public void setTileNetwork(NetworkTileEntities network)
public void setTileNetwork(ITileNetwork network)
{
if (network instanceof NetworkAssembly)
{
@ -186,13 +187,6 @@ public abstract class TileEntityAssembly extends TileEntityEnergyMachine impleme
this.energyStored = energy;
}
@Override
public boolean mergeDamage(String effect)
{
this.onDisable(20);
return true;
}
@Override
public AxisAlignedBB getRenderBoundingBox()
{

View file

@ -278,12 +278,12 @@ public class TileEntityConveyorBelt extends TileEntityAssembly implements IBelt,
rear = back.getTileEntity(this.worldObj);
if (front instanceof TileEntityAssembly)
{
this.getTileNetwork().merge(((TileEntityAssembly) front).getTileNetwork(), this);
this.getTileNetwork().mergeNetwork(((TileEntityAssembly) front).getTileNetwork(), this);
this.connectedTiles.add(front);
}
if (rear instanceof TileEntityAssembly)
{
this.getTileNetwork().merge(((TileEntityAssembly) rear).getTileNetwork(), this);
this.getTileNetwork().mergeNetwork(((TileEntityAssembly) rear).getTileNetwork(), this);
this.connectedTiles.add(rear);
}