From d08bb5c48e8ef3498db352cb959c511f34b89ebd Mon Sep 17 00:00:00 2001 From: DarkGuardsman Date: Sun, 7 Jul 2013 09:26:00 -0400 Subject: [PATCH] more work on network resolved a few power issues though i'm running into mekanism energy cubes self powering. As well energy cube, different one, is request power from the network but is never getting supplied any. --- .../assemblyline/common/AssemblyLine.java | 5 -- .../common/machine/NetworkAssembly.java | 13 +++- .../common/machine/TileEntityAssembly.java | 59 ++++++++----------- 3 files changed, 34 insertions(+), 43 deletions(-) diff --git a/src/minecraft/assemblyline/common/AssemblyLine.java b/src/minecraft/assemblyline/common/AssemblyLine.java index 877cabd8b..8a3e89f46 100644 --- a/src/minecraft/assemblyline/common/AssemblyLine.java +++ b/src/minecraft/assemblyline/common/AssemblyLine.java @@ -8,8 +8,6 @@ import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.Configuration; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; import org.modstats.ModstatInfo; import org.modstats.Modstats; @@ -20,7 +18,6 @@ import universalelectricity.prefab.multiblock.TileEntityMulti; import universalelectricity.prefab.network.PacketManager; import assemblyline.common.armbot.BlockArmbot; import assemblyline.common.armbot.TileEntityArmbot; -import assemblyline.common.armbot.command.GrabDictionary; import assemblyline.common.imprinter.BlockImprinter; import assemblyline.common.imprinter.ItemImprinter; import assemblyline.common.imprinter.TileEntityImprinter; @@ -59,8 +56,6 @@ import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; -import dark.core.DarkMain; -import dark.core.PowerSystems; @ModstatInfo(prefix = "asmline") @Mod(modid = AssemblyLine.CHANNEL, name = AssemblyLine.MOD_NAME, version = AssemblyLine.VERSION, dependencies = "after:BasicComponents; after:IC2", useMetadata = true) diff --git a/src/minecraft/assemblyline/common/machine/NetworkAssembly.java b/src/minecraft/assemblyline/common/machine/NetworkAssembly.java index d6206c069..d983f8761 100644 --- a/src/minecraft/assemblyline/common/machine/NetworkAssembly.java +++ b/src/minecraft/assemblyline/common/machine/NetworkAssembly.java @@ -39,7 +39,7 @@ public class NetworkAssembly extends NetworkPowerTiles public void addPower(double d) { double before = this.wattStored; - this.wattStored = Math.max(this.wattStored + d, this.getMaxBattery()); + this.wattStored = Math.min(this.wattStored + d, this.getMaxBattery()); System.out.println("Power| +++" + ElectricityDisplay.getDisplaySimple(d, ElectricUnit.WATT, 2) + " A: " + ElectricityDisplay.getDisplaySimple(this.wattStored, ElectricUnit.WATT, 2)); } @@ -52,7 +52,14 @@ public class NetworkAssembly extends NetworkPowerTiles { pack = new ElectricityPack(0, 120); } - double watt = pack.getWatts(); + + return ElectricityPack.getFromWatts(pack.getWatts() + this.getMemberRequest(), pack.voltage); + } + + @Override + public double getMemberRequest() + { + double watt = 0; for (INetworkPart part : this.getNetworkMemebers()) { //TODO do check for ignored tiles/ents @@ -61,7 +68,7 @@ public class NetworkAssembly extends NetworkPowerTiles watt += ((TileEntityAssembly) part).getWattLoad(); } } - return ElectricityPack.getFromWatts(watt, pack.voltage); + return watt; } @Override diff --git a/src/minecraft/assemblyline/common/machine/TileEntityAssembly.java b/src/minecraft/assemblyline/common/machine/TileEntityAssembly.java index dd6809143..0ef7ecde1 100644 --- a/src/minecraft/assemblyline/common/machine/TileEntityAssembly.java +++ b/src/minecraft/assemblyline/common/machine/TileEntityAssembly.java @@ -27,6 +27,7 @@ import buildcraft.api.power.PowerProvider; import com.google.common.io.ByteArrayDataInput; import dark.core.api.INetworkPart; +import dark.core.tile.network.NetworkPowerTiles; import dark.core.tile.network.NetworkTileEntities; import dark.library.machine.TileEntityRunnableMachine; @@ -38,6 +39,7 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple { /** Is the tile currently powered allowing it to run */ public boolean running = false; + private boolean prevRun = false; /** Network used to link assembly machines together */ private NetworkAssembly assemblyNetwork; /** Tiles that are connected to this */ @@ -47,12 +49,6 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple /** Random rate by which this tile updates its connections */ private int updateTick = 1; - public TileEntityAssembly() - { - this.powerProvider = new AssemblyPowerProvider(this); - powerProvider.configure(0, 0, 100, 0, 200); - } - public static enum AssemblyTilePacket { POWER(), @@ -75,7 +71,7 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple { if (!this.worldObj.isRemote) { - boolean prevRun = this.running; + this.prevRun = this.running; super.updateEntity(); if (ticks % updateTick == 0) { @@ -135,6 +131,26 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple return 1; } + @Override + public double getBattery(ForgeDirection side) + { + if (this.getTileNetwork() instanceof NetworkAssembly) + { + return ((NetworkAssembly) this.getTileNetwork()).getMaxBattery(); + } + return super.getBattery(side); + } + + @Override + public double getCurrentBattery(ForgeDirection side) + { + if (this.getTileNetwork() instanceof NetworkAssembly) + { + return ((NetworkAssembly) this.getTileNetwork()).getCurrentBattery(); + } + return super.getCurrentBattery(side); + } + /** Amount of energy the network needs at any given time */ @Override public double getRequest(ForgeDirection side) @@ -142,8 +158,7 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple if (this.getTileNetwork() instanceof NetworkAssembly) { NetworkAssembly net = ((NetworkAssembly) this.getTileNetwork()); - double room = net.getMaxBattery() - net.getCurrentBattery(); - return Math.min(100, Math.max(0, room)); + return Math.min(100 + net.getMemberRequest(), Math.max(0, net.getRequest(new Vector3(this).modifyPositionFromSide(side).getTileEntity(this.worldObj), this).getWatts())); } return 0; } @@ -303,30 +318,4 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple return 1000; } - class AssemblyPowerProvider extends PowerProvider - { - public TileEntityAssembly tileEntity; - - public AssemblyPowerProvider(TileEntityAssembly tile) - { - tileEntity = tile; - } - - @Override - public void receiveEnergy(float quantity, ForgeDirection from) - { - powerSources[from.ordinal()] = 2; - - if (tileEntity.getTileNetwork() instanceof NetworkAssembly) - { - ((NetworkAssembly) tileEntity.getTileNetwork()).addPower(UniversalElectricity.BC3_RATIO * quantity); - System.out.println("BuildCraft Power Reciver>>>PlugPower>>>"+quantity); - } - else - { - this.energyStored += quantity; - } - } - } - }