Updated UE

This commit is contained in:
Calclavia 2014-01-20 19:08:17 +08:00
parent afd1bbde71
commit 3cac78bb60
7 changed files with 35 additions and 37 deletions

View file

@ -5,14 +5,14 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import universalelectricity.api.net.INetwork;
import universalelectricity.api.net.INodeNetwork;
/**
* Interface version of the fluid network.
*
* @author DarkGuardsman
*/
public interface IFluidNetwork extends INetwork<IFluidNetwork, IFluidConnector, IFluidHandler>
public interface IFluidNetwork extends INodeNetwork<IFluidNetwork, IFluidConnector, IFluidHandler>
{
/** Called to build the network when something changes such as addition of a pipe */
@Override

View file

@ -12,7 +12,7 @@ import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.net.IConnector;
import universalelectricity.api.net.INetwork;
import universalelectricity.api.net.INodeNetwork;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper;
import codechicken.lib.data.MCDataInput;
@ -33,7 +33,7 @@ import codechicken.multipart.TMultiPart;
import codechicken.multipart.TSlottedPart;
import codechicken.multipart.TileMultipart;
public abstract class PartFramedConnection<M extends Enum, C extends IConnector<N>, N extends INetwork> extends PartColorableMaterial<M> implements IConnector<N>, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
public abstract class PartFramedConnection<M extends Enum, C extends IConnector<N>, N extends INodeNetwork> extends PartColorableMaterial<M> implements IConnector<N>, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
{
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];

View file

@ -2,29 +2,29 @@ package resonantinduction.electrical.battery;
import java.util.Arrays;
import calclavia.lib.multiblock.structure.Structure;
import universalelectricity.core.net.Network;
public class BatteryStructure extends Structure<TileBattery>
public class BatteryNetwork extends Network<BatteryNetwork, TileBattery>
{
public void redistribute(TileBattery... exclusion)
{
long totalEnergy = 0;
for (TileBattery battery : this.get())
for (TileBattery battery : this.getConnectors())
{
totalEnergy += battery.getEnergy(null);
}
int amountOfNodes = this.get().size() - exclusion.length;
int amountOfNodes = this.getConnectors().size() - exclusion.length;
if (totalEnergy > 0 && amountOfNodes > 0)
{
long totalPerBattery = totalEnergy / amountOfNodes;
long totalPerBatteryRemainder = totalPerBattery + totalEnergy % amountOfNodes;
TileBattery firstNode = this.getFirstNode();
TileBattery firstNode = this.getFirstConnector();
for (TileBattery battery : this.get())
for (TileBattery battery : this.getConnectors())
{
if (!Arrays.asList(exclusion).contains(battery))
{
@ -42,14 +42,14 @@ public class BatteryStructure extends Structure<TileBattery>
}
@Override
public Structure getNew()
{
return new BatteryStructure();
}
@Override
protected void reconstructNode(TileBattery node)
protected void reconstructConnector(TileBattery node)
{
node.setNetwork(this);
}
@Override
public BatteryNetwork newInstance()
{
return new BatteryNetwork();
}
}

View file

@ -29,7 +29,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
*
* @author Calclavia
*/
public class TileBattery extends TileElectrical implements IConnector<BatteryStructure>, IVoltageInput, IVoltageOutput, IPacketSender, IPacketReceiver, IEnergyInterface, IEnergyContainer
public class TileBattery extends TileElectrical implements IConnector<BatteryNetwork>, IVoltageInput, IVoltageOutput, IPacketSender, IPacketReceiver, IEnergyInterface, IEnergyContainer
{
/** The transfer rate **/
public static final long DEFAULT_WATTAGE = getEnergyForTier(1);
@ -37,7 +37,7 @@ public class TileBattery extends TileElectrical implements IConnector<BatteryStr
/** Voltage increases as series connection increases */
public static final long DEFAULT_VOLTAGE = UniversalElectricity.DEFAULT_VOLTAGE;
private BatteryStructure structure;
private BatteryNetwork network;
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
@ -81,7 +81,7 @@ public class TileBattery extends TileElectrical implements IConnector<BatteryStr
}
}
this.energy.setMaxTransfer(DEFAULT_WATTAGE * this.getNetwork().get().size());
this.energy.setMaxTransfer(DEFAULT_WATTAGE * this.getNetwork().getConnectors().size());
this.getNetwork().redistribute();
}
}
@ -134,21 +134,21 @@ public class TileBattery extends TileElectrical implements IConnector<BatteryStr
}
@Override
public BatteryStructure getNetwork()
public BatteryNetwork getNetwork()
{
if (this.structure == null)
if (this.network == null)
{
this.structure = new BatteryStructure();
this.structure.add(this);
this.network = new BatteryNetwork();
this.network.addConnector(this);
}
return this.structure;
return this.network;
}
@Override
public void setNetwork(BatteryStructure structure)
public void setNetwork(BatteryNetwork structure)
{
this.structure = structure;
this.network = structure;
}
@Override

View file

@ -9,10 +9,9 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.fluid.IFluidConnector;
import resonantinduction.api.fluid.IFluidNetwork;
import universalelectricity.api.net.IConnector;
import universalelectricity.core.net.ConnectionPathfinder;
import universalelectricity.core.net.Network;
import universalelectricity.api.net.IUpdate;
import universalelectricity.core.net.NetworkTickHandler;
import universalelectricity.core.net.NodeNetwork;
import calclavia.lib.utility.FluidUtility;
/**
@ -21,7 +20,7 @@ import calclavia.lib.utility.FluidUtility;
* @author DarkCow, Calclavia
*
*/
public abstract class FluidNetwork extends Network<IFluidNetwork, IFluidConnector, IFluidHandler> implements IFluidNetwork
public abstract class FluidNetwork extends NodeNetwork<IFluidNetwork, IFluidConnector, IFluidHandler> implements IFluidNetwork, IUpdate
{
protected FluidTank tank = new FluidTank(0);
protected final FluidTankInfo[] tankInfo = new FluidTankInfo[1];

View file

@ -1,13 +1,13 @@
package resonantinduction.mechanical.network;
import universalelectricity.api.net.INetwork;
import universalelectricity.api.net.INodeNetwork;
/**
* Mechanical network in interface form for interaction or extension
*
* @author DarkGuardsman
*/
public interface IMechanicalNetwork extends INetwork<IMechanicalNetwork, IMechanicalConnector, IMechanical>
public interface IMechanicalNetwork extends INodeNetwork<IMechanicalNetwork, IMechanicalConnector, IMechanical>
{
/**
* Gets the power of the network.

View file

@ -6,10 +6,9 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.net.IConnector;
import universalelectricity.core.net.ConnectionPathfinder;
import universalelectricity.core.net.Network;
import universalelectricity.api.net.IUpdate;
import universalelectricity.core.net.NetworkTickHandler;
import universalelectricity.core.net.NodeNetwork;
/**
* A mechanical network for translate speed and force using mechanical rotations.
@ -27,7 +26,7 @@ import universalelectricity.core.net.NetworkTickHandler;
*
* @author Calclavia
*/
public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalConnector, IMechanical> implements IMechanicalNetwork
public class MechanicalNetwork extends NodeNetwork<IMechanicalNetwork, IMechanicalConnector, IMechanical> implements IMechanicalNetwork, IUpdate
{
private long prevTorque = 0;
private float prevAngularVelocity = 0;