Got network working on power now
Still need to fix what looks like an infinite power issue.
This commit is contained in:
parent
b0b7ae3c06
commit
5113e5f660
2 changed files with 25 additions and 42 deletions
|
@ -39,6 +39,12 @@ public class NetworkAssembly extends NetworkPowerTiles
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Adds power to the network. Does not save power on area unload */
|
||||
public void addPower(double d)
|
||||
{
|
||||
this.wattStored += d;
|
||||
}
|
||||
|
||||
/** Gets the amount of power this network needs
|
||||
*
|
||||
* @param total - true for total network, false for amount equal to each power connection */
|
||||
|
@ -59,7 +65,7 @@ public class NetworkAssembly extends NetworkPowerTiles
|
|||
{
|
||||
return this.getRequest() * 4;
|
||||
}
|
||||
|
||||
|
||||
public double getCurrentBattery()
|
||||
{
|
||||
return this.wattStored;
|
||||
|
@ -75,51 +81,10 @@ public class NetworkAssembly extends NetworkPowerTiles
|
|||
newNetwork.cleanUpMembers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addNetworkPart(INetworkPart part)
|
||||
{
|
||||
boolean added = super.addNetworkPart(part);
|
||||
if (added && part instanceof TileEntityAssembly)
|
||||
{
|
||||
if (((TileEntityAssembly) part).powered)
|
||||
{
|
||||
this.markAsPowerSource((TileEntity) part, true);
|
||||
}
|
||||
}
|
||||
if (added)
|
||||
{
|
||||
this.doCalc();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidMember(INetworkPart part)
|
||||
{
|
||||
return super.isValidMember(part) && part instanceof TileEntityAssembly;
|
||||
}
|
||||
|
||||
public void doCalc()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/** Marks a tile as the source of power for the network
|
||||
*
|
||||
* @param powered true to add, false to remove */
|
||||
public void markAsPowerSource(TileEntity entity, boolean powered)
|
||||
{
|
||||
if (powered)
|
||||
{
|
||||
if (!this.powerSources.contains(entity))
|
||||
{
|
||||
this.powerSources.add(entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.powerSources.remove(entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,6 +81,24 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple
|
|||
this.onUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(ForgeDirection side, double voltage, double amperes)
|
||||
{
|
||||
if (voltage > this.getVoltage())
|
||||
{
|
||||
this.onDisable(2);
|
||||
return;
|
||||
}
|
||||
if (this.getTileNetwork() instanceof NetworkAssembly)
|
||||
{
|
||||
((NetworkAssembly) this.getTileNetwork()).addPower(voltage * amperes);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.wattsReceived = Math.min(this.wattsReceived + (voltage * amperes), this.getBattery(side));
|
||||
}
|
||||
}
|
||||
|
||||
/** Same as updateEntity */
|
||||
public abstract void onUpdate();
|
||||
|
||||
|
|
Loading…
Reference in a new issue