Began work on a more modular approach to networks

This commit is contained in:
Aidan C. Brady 2013-08-16 11:56:42 -04:00
parent 98a436d2f7
commit 20728eff4f
6 changed files with 22 additions and 26 deletions

View file

@ -0,0 +1,9 @@
package mekanism.api;
public class DynamicNetwork
{
protected int ticksSinceCreate = 0;
protected int ticksSinceSecond = 0;
protected boolean fixed = false;
}

View file

@ -20,16 +20,13 @@ import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.ChunkEvent;
import cpw.mods.fml.common.FMLCommonHandler;
public class GasNetwork implements ITransmitterNetwork
public class GasNetwork extends DynamicNetwork implements ITransmitterNetwork
{
public HashSet<IPressurizedTube> tubes = new HashSet<IPressurizedTube>();
public Set<IGasAcceptor> possibleAcceptors = new HashSet<IGasAcceptor>();
public Map<IGasAcceptor, ForgeDirection> acceptorDirections = new HashMap<IGasAcceptor, ForgeDirection>();
private int ticksSinceCreate = 0;
private boolean fixed = false;
public GasNetwork(IPressurizedTube... varPipes)
{
tubes.addAll(Arrays.asList(varPipes));
@ -370,7 +367,7 @@ public class GasNetwork implements ITransmitterNetwork
@Override
public String toString()
{
return "[GasNetwork] " + tubes.size() + " pipes, " + possibleAcceptors.size() + " acceptors.";
return "[GasNetwork] " + tubes.size() + " tubes, " + possibleAcceptors.size() + " acceptors.";
}
public void tick()

View file

@ -12,7 +12,6 @@ import cpw.mods.fml.relauncher.Side;
public class TransmitterNetworkRegistry implements ITickHandler
{
private static TransmitterNetworkRegistry INSTANCE = new TransmitterNetworkRegistry();
private HashSet<ITransmitterNetwork> networks = new HashSet<ITransmitterNetwork>();
public TransmitterNetworkRegistry()
@ -78,7 +77,7 @@ public class TransmitterNetworkRegistry implements ITickHandler
@Override
public String getLabel()
{
return "Mekanism Transmitter Networks";
return "MekanismNetworks";
}
@Override

View file

@ -13,8 +13,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import cpw.mods.fml.common.FMLCommonHandler;
import mekanism.api.DynamicNetwork;
import mekanism.api.IStrictEnergyAcceptor;
import mekanism.api.ITransmitterNetwork;
import mekanism.api.Object3D;
@ -26,13 +25,14 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.Event;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.ChunkEvent;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.electricity.ElectricityPack;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import universalelectricity.core.block.IElectrical;
import universalelectricity.core.electricity.ElectricityPack;
import cpw.mods.fml.common.FMLCommonHandler;
public class EnergyNetwork implements ITransmitterNetwork
public class EnergyNetwork extends DynamicNetwork implements ITransmitterNetwork
{
public HashSet<IUniversalCable> cables = new HashSet<IUniversalCable>();
@ -42,9 +42,6 @@ public class EnergyNetwork implements ITransmitterNetwork
private double lastPowerScale = 0;
private double joulesTransmitted = 0;
private double joulesLastTick = 0;
private int ticksSinceCreate = 0;
private int ticksSinceSecond = 0;
private boolean fixed = false;
public EnergyNetwork(IUniversalCable... varCables)
{

View file

@ -11,6 +11,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import mekanism.api.DynamicNetwork;
import mekanism.api.ITransmitterNetwork;
import mekanism.api.Object3D;
import mekanism.api.TransmitterNetworkRegistry;
@ -25,17 +26,13 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.common.FMLCommonHandler;
public class FluidNetwork implements ITransmitterNetwork
public class FluidNetwork extends DynamicNetwork implements ITransmitterNetwork
{
public HashSet<IMechanicalPipe> pipes = new HashSet<IMechanicalPipe>();
public Set<IFluidHandler> possibleAcceptors = new HashSet<IFluidHandler>();
public Map<IFluidHandler, ForgeDirection> acceptorDirections = new HashMap<IFluidHandler, ForgeDirection>();
private int ticksSinceCreate = 0;
private int ticksSinceSecond = 0;
private boolean fixed = false;
public FluidNetwork(IMechanicalPipe... varPipes)
{
pipes.addAll(Arrays.asList(varPipes));

View file

@ -10,6 +10,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import mekanism.api.DynamicNetwork;
import mekanism.api.ITransmitterNetwork;
import mekanism.api.Object3D;
import mekanism.api.TransmitterNetworkRegistry;
@ -20,17 +21,13 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.ChunkEvent;
public class InventoryNetwork implements ITransmitterNetwork
public class InventoryNetwork extends DynamicNetwork implements ITransmitterNetwork
{
public HashSet<ILogisticalTransporter> transporters = new HashSet<ILogisticalTransporter>();
public Set<IInventory> possibleAcceptors = new HashSet<IInventory>();
public Map<IInventory, ForgeDirection> acceptorDirections = new HashMap<IInventory, ForgeDirection>();
private int ticksSinceCreate = 0;
private int ticksSinceSecond = 0;
private boolean fixed = false;
public InventoryNetwork(ILogisticalTransporter... varTransporters)
{
transporters.addAll(Arrays.asList(varTransporters));
@ -315,7 +312,7 @@ public class InventoryNetwork implements ITransmitterNetwork
@Override
public String toString()
{
return "[InventoryNetwork] " + transporters.size() + " pipes, " + possibleAcceptors.size() + " acceptors.";
return "[InventoryNetwork] " + transporters.size() + " transporters, " + possibleAcceptors.size() + " acceptors.";
}
@Override