Cleanup and fixed network split
This commit is contained in:
parent
5113e5f660
commit
202a775a6d
12 changed files with 58 additions and 47 deletions
|
@ -11,11 +11,11 @@ import universalelectricity.core.vector.Vector3;
|
|||
import universalelectricity.prefab.multiblock.IMultiBlock;
|
||||
import assemblyline.client.render.BlockRenderingHandler;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
import assemblyline.common.machine.BlockALMachine;
|
||||
import assemblyline.common.machine.BlockAssembly;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockArmbot extends BlockALMachine
|
||||
public class BlockArmbot extends BlockAssembly
|
||||
{
|
||||
public BlockArmbot(int id)
|
||||
{
|
||||
|
|
|
@ -15,11 +15,11 @@ import net.minecraft.world.World;
|
|||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.CommonProxy;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
import assemblyline.common.machine.BlockALMachine;
|
||||
import assemblyline.common.machine.BlockAssembly;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockImprinter extends BlockALMachine
|
||||
public class BlockImprinter extends BlockAssembly
|
||||
{
|
||||
Icon imprinter_side;
|
||||
Icon imprinter_top;
|
||||
|
|
|
@ -12,14 +12,14 @@ import net.minecraft.world.World;
|
|||
import universalelectricity.prefab.implement.IRedstoneReceptor;
|
||||
import assemblyline.api.IFilterable;
|
||||
import assemblyline.common.imprinter.ItemImprinter;
|
||||
import assemblyline.common.machine.BlockALMachine;
|
||||
import assemblyline.common.machine.BlockAssembly;
|
||||
|
||||
/**
|
||||
* Extend this block class if a filter is allowed to be placed inside of this block.
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
public abstract class BlockImprintable extends BlockALMachine
|
||||
public abstract class BlockImprintable extends BlockAssembly
|
||||
{
|
||||
public BlockImprintable(String name, int id, Material material, CreativeTabs creativeTab)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import universalelectricity.prefab.block.BlockAdvanced;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
|
@ -16,11 +18,11 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.api.INetworkPart;
|
||||
|
||||
public class BlockALMachine extends BlockAdvanced
|
||||
public class BlockAssembly extends BlockAdvanced
|
||||
{
|
||||
public Icon machine_icon;
|
||||
|
||||
public BlockALMachine(int id, Material material, String name)
|
||||
public BlockAssembly(int id, Material material, String name)
|
||||
{
|
||||
super(AssemblyLine.CONFIGURATION.getBlock(name, id).getInt(), material);
|
||||
this.setUnlocalizedName(name);
|
||||
|
@ -39,7 +41,13 @@ public class BlockALMachine extends BlockAdvanced
|
|||
output += "Channel:" + (asm.getTileNetwork() != null ? asm.getTileNetwork().toString() : "Error") + "|";
|
||||
entityPlayer.sendChatToPlayer(output);
|
||||
output = "Debug>>>";
|
||||
output += "Powered:" + asm.running;
|
||||
output += "Powered:" + asm.running + " ";
|
||||
if (asm.getTileNetwork() instanceof NetworkAssembly)
|
||||
{
|
||||
output += ElectricityDisplay.getDisplaySimple(((NetworkAssembly) asm.getTileNetwork()).getCurrentBattery(), ElectricUnit.WATT, 2);
|
||||
output += "/";
|
||||
output += ElectricityDisplay.getDisplaySimple(((NetworkAssembly) asm.getTileNetwork()).getMaxBattery(), ElectricUnit.WATT, 2);
|
||||
}
|
||||
entityPlayer.sendChatToPlayer(output);
|
||||
}
|
||||
return super.onBlockActivated(world, x, y, z, entityPlayer, side, hitX, hitY, hitZ);
|
|
@ -25,7 +25,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class BlockCrate extends BlockALMachine
|
||||
public class BlockCrate extends BlockAssembly
|
||||
{
|
||||
Icon crate_icon;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import assemblyline.common.TabAssemblyLine;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockTurntable extends BlockALMachine
|
||||
public class BlockTurntable extends BlockAssembly
|
||||
{
|
||||
private Icon top;
|
||||
|
||||
|
|
|
@ -1,26 +1,13 @@
|
|||
package assemblyline.common.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import universalelectricity.core.block.IConductor;
|
||||
import universalelectricity.core.block.IConnectionProvider;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
import universalelectricity.core.electricity.IElectricityNetwork;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import dark.core.api.INetworkPart;
|
||||
import dark.core.tile.network.NetworkPowerTiles;
|
||||
import dark.core.tile.network.NetworkTileEntities;
|
||||
|
||||
public class NetworkAssembly extends NetworkPowerTiles
|
||||
{
|
||||
/** List of network members that are providing power for the network */
|
||||
private List<TileEntity> powerSources = new ArrayList<TileEntity>();
|
||||
|
||||
/** Power stored to be used by network members */
|
||||
private double wattStored = 0.0;
|
||||
|
||||
public NetworkAssembly(INetworkPart... parts)
|
||||
|
@ -28,12 +15,17 @@ public class NetworkAssembly extends NetworkPowerTiles
|
|||
super(parts);
|
||||
}
|
||||
|
||||
/** Checks if the tile can run as well sucks up energy for the tile to run */
|
||||
public boolean canRun(TileEntityAssembly tile)
|
||||
public NetworkTileEntities newInstance()
|
||||
{
|
||||
if (tile != null && this.wattStored >= tile.getRequest(ForgeDirection.UNKNOWN))
|
||||
return new NetworkAssembly();
|
||||
}
|
||||
|
||||
/** Checks if the tile can run as well sucks up energy for the tile to run */
|
||||
public boolean doPowerRun(TileEntityAssembly tile)
|
||||
{
|
||||
if (tile != null && this.wattStored >= tile.getRequest())
|
||||
{
|
||||
this.wattStored -= tile.getRequest(ForgeDirection.UNKNOWN);
|
||||
this.wattStored -= tile.getRequest();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -72,7 +64,7 @@ public class NetworkAssembly extends NetworkPowerTiles
|
|||
}
|
||||
|
||||
@Override
|
||||
public void postMergeProcessing(NetworkTileEntities network)
|
||||
public void mergeDo(NetworkTileEntities network)
|
||||
{
|
||||
NetworkAssembly newNetwork = new NetworkAssembly();
|
||||
newNetwork.getNetworkMemebers().addAll(this.getNetworkMemebers());
|
||||
|
@ -87,4 +79,10 @@ public class NetworkAssembly extends NetworkPowerTiles
|
|||
return super.isValidMember(part) && part instanceof TileEntityAssembly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "AssemblyNetwork[" + this.hashCode() + "|parts:" + this.networkMember.size() + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,17 +54,22 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple
|
|||
public void invalidate()
|
||||
{
|
||||
NetworkAssembly.invalidate(this);
|
||||
if (this.getTileNetwork() != null)
|
||||
{
|
||||
this.getTileNetwork().splitNetwork(this.worldObj, this);
|
||||
}
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
boolean prevRun = this.running;
|
||||
this.powered = false;
|
||||
super.updateEntity();
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
boolean prevRun = this.running;
|
||||
this.powered = false;
|
||||
super.updateEntity();
|
||||
if (ticks % updateTick == 0)
|
||||
{
|
||||
this.updateTick = ((int) random.nextInt(10) + 20);
|
||||
|
@ -105,14 +110,14 @@ public abstract class TileEntityAssembly extends TileEntityRunnableMachine imple
|
|||
/** Checks to see if this assembly tile can run using several methods */
|
||||
public boolean isRunning()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
boolean running = AssemblyLine.REQUIRE_NO_POWER;
|
||||
if (!running && this.getTileNetwork() instanceof NetworkAssembly)
|
||||
boolean on = AssemblyLine.REQUIRE_NO_POWER;
|
||||
if (!on && this.getTileNetwork() instanceof NetworkAssembly)
|
||||
{
|
||||
running = ((NetworkAssembly) this.getTileNetwork()).canRun(this);
|
||||
on = ((NetworkAssembly) this.getTileNetwork()).doPowerRun(this);
|
||||
}
|
||||
return running;
|
||||
return on;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import universalelectricity.core.UniversalElectricity;
|
||||
import assemblyline.client.render.BlockRenderingHandler;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
import assemblyline.common.machine.BlockALMachine;
|
||||
import assemblyline.common.machine.BlockAssembly;
|
||||
import assemblyline.common.machine.belt.TileEntityConveyorBelt.SlantType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -26,7 +26,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
*
|
||||
* @author Calclavia, DarkGuardsman
|
||||
*/
|
||||
public class BlockConveyorBelt extends BlockALMachine
|
||||
public class BlockConveyorBelt extends BlockAssembly
|
||||
{
|
||||
public BlockConveyorBelt(int id)
|
||||
{
|
||||
|
|
|
@ -8,11 +8,11 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import universalelectricity.core.UniversalElectricity;
|
||||
import assemblyline.client.render.BlockRenderingHandler;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
import assemblyline.common.machine.BlockALMachine;
|
||||
import assemblyline.common.machine.BlockAssembly;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCraneController extends BlockALMachine
|
||||
public class BlockCraneController extends BlockAssembly
|
||||
{
|
||||
public BlockCraneController(int id)
|
||||
{
|
||||
|
|
|
@ -8,11 +8,11 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import universalelectricity.core.UniversalElectricity;
|
||||
import assemblyline.client.render.BlockRenderingHandler;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
import assemblyline.common.machine.BlockALMachine;
|
||||
import assemblyline.common.machine.BlockAssembly;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCraneFrame extends BlockALMachine
|
||||
public class BlockCraneFrame extends BlockAssembly
|
||||
{
|
||||
public BlockCraneFrame(int id)
|
||||
{
|
||||
|
|
|
@ -10,11 +10,11 @@ import net.minecraft.world.World;
|
|||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.CommonProxy;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
import assemblyline.common.machine.BlockALMachine;
|
||||
import assemblyline.common.machine.BlockAssembly;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockEncoder extends BlockALMachine
|
||||
public class BlockEncoder extends BlockAssembly
|
||||
{
|
||||
Icon encoder_side;
|
||||
Icon encoder_top;
|
||||
|
|
Loading…
Reference in a new issue