diff --git a/src/minecraft/assemblyline/common/machine/NetworkAssembly.java b/src/minecraft/assemblyline/common/machine/NetworkAssembly.java index 1c33a1f80..46f2a16a4 100644 --- a/src/minecraft/assemblyline/common/machine/NetworkAssembly.java +++ b/src/minecraft/assemblyline/common/machine/NetworkAssembly.java @@ -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); - } - } - } diff --git a/src/minecraft/assemblyline/common/machine/TileEntityAssembly.java b/src/minecraft/assemblyline/common/machine/TileEntityAssembly.java index c565ccf4e..9db726a46 100644 --- a/src/minecraft/assemblyline/common/machine/TileEntityAssembly.java +++ b/src/minecraft/assemblyline/common/machine/TileEntityAssembly.java @@ -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();