Updated UE
This commit is contained in:
parent
afd1bbde71
commit
3cac78bb60
7 changed files with 35 additions and 37 deletions
|
@ -5,14 +5,14 @@ import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.FluidTank;
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
import universalelectricity.api.net.INetwork;
|
import universalelectricity.api.net.INodeNetwork;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface version of the fluid network.
|
* Interface version of the fluid network.
|
||||||
*
|
*
|
||||||
* @author DarkGuardsman
|
* @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 */
|
/** Called to build the network when something changes such as addition of a pipe */
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,7 +12,7 @@ import net.minecraft.util.Icon;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.api.net.IConnector;
|
import universalelectricity.api.net.IConnector;
|
||||||
import universalelectricity.api.net.INetwork;
|
import universalelectricity.api.net.INodeNetwork;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import universalelectricity.api.vector.VectorHelper;
|
import universalelectricity.api.vector.VectorHelper;
|
||||||
import codechicken.lib.data.MCDataInput;
|
import codechicken.lib.data.MCDataInput;
|
||||||
|
@ -33,7 +33,7 @@ import codechicken.multipart.TMultiPart;
|
||||||
import codechicken.multipart.TSlottedPart;
|
import codechicken.multipart.TSlottedPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
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];
|
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];
|
||||||
|
|
|
@ -2,29 +2,29 @@ package resonantinduction.electrical.battery;
|
||||||
|
|
||||||
import java.util.Arrays;
|
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)
|
public void redistribute(TileBattery... exclusion)
|
||||||
{
|
{
|
||||||
long totalEnergy = 0;
|
long totalEnergy = 0;
|
||||||
|
|
||||||
for (TileBattery battery : this.get())
|
for (TileBattery battery : this.getConnectors())
|
||||||
{
|
{
|
||||||
totalEnergy += battery.getEnergy(null);
|
totalEnergy += battery.getEnergy(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
int amountOfNodes = this.get().size() - exclusion.length;
|
int amountOfNodes = this.getConnectors().size() - exclusion.length;
|
||||||
|
|
||||||
if (totalEnergy > 0 && amountOfNodes > 0)
|
if (totalEnergy > 0 && amountOfNodes > 0)
|
||||||
{
|
{
|
||||||
long totalPerBattery = totalEnergy / amountOfNodes;
|
long totalPerBattery = totalEnergy / amountOfNodes;
|
||||||
long totalPerBatteryRemainder = 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))
|
if (!Arrays.asList(exclusion).contains(battery))
|
||||||
{
|
{
|
||||||
|
@ -42,14 +42,14 @@ public class BatteryStructure extends Structure<TileBattery>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Structure getNew()
|
protected void reconstructConnector(TileBattery node)
|
||||||
{
|
|
||||||
return new BatteryStructure();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void reconstructNode(TileBattery node)
|
|
||||||
{
|
{
|
||||||
node.setNetwork(this);
|
node.setNetwork(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BatteryNetwork newInstance()
|
||||||
|
{
|
||||||
|
return new BatteryNetwork();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @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 **/
|
/** The transfer rate **/
|
||||||
public static final long DEFAULT_WATTAGE = getEnergyForTier(1);
|
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 */
|
/** Voltage increases as series connection increases */
|
||||||
public static final long DEFAULT_VOLTAGE = UniversalElectricity.DEFAULT_VOLTAGE;
|
public static final long DEFAULT_VOLTAGE = UniversalElectricity.DEFAULT_VOLTAGE;
|
||||||
|
|
||||||
private BatteryStructure structure;
|
private BatteryNetwork network;
|
||||||
|
|
||||||
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
|
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();
|
this.getNetwork().redistribute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,21 +134,21 @@ public class TileBattery extends TileElectrical implements IConnector<BatteryStr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BatteryStructure getNetwork()
|
public BatteryNetwork getNetwork()
|
||||||
{
|
{
|
||||||
if (this.structure == null)
|
if (this.network == null)
|
||||||
{
|
{
|
||||||
this.structure = new BatteryStructure();
|
this.network = new BatteryNetwork();
|
||||||
this.structure.add(this);
|
this.network.addConnector(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.structure;
|
return this.network;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNetwork(BatteryStructure structure)
|
public void setNetwork(BatteryNetwork structure)
|
||||||
{
|
{
|
||||||
this.structure = structure;
|
this.network = structure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,10 +9,9 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
import resonantinduction.api.fluid.IFluidConnector;
|
import resonantinduction.api.fluid.IFluidConnector;
|
||||||
import resonantinduction.api.fluid.IFluidNetwork;
|
import resonantinduction.api.fluid.IFluidNetwork;
|
||||||
import universalelectricity.api.net.IConnector;
|
import universalelectricity.api.net.IUpdate;
|
||||||
import universalelectricity.core.net.ConnectionPathfinder;
|
|
||||||
import universalelectricity.core.net.Network;
|
|
||||||
import universalelectricity.core.net.NetworkTickHandler;
|
import universalelectricity.core.net.NetworkTickHandler;
|
||||||
|
import universalelectricity.core.net.NodeNetwork;
|
||||||
import calclavia.lib.utility.FluidUtility;
|
import calclavia.lib.utility.FluidUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +20,7 @@ import calclavia.lib.utility.FluidUtility;
|
||||||
* @author DarkCow, Calclavia
|
* @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 FluidTank tank = new FluidTank(0);
|
||||||
protected final FluidTankInfo[] tankInfo = new FluidTankInfo[1];
|
protected final FluidTankInfo[] tankInfo = new FluidTankInfo[1];
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package resonantinduction.mechanical.network;
|
package resonantinduction.mechanical.network;
|
||||||
|
|
||||||
import universalelectricity.api.net.INetwork;
|
import universalelectricity.api.net.INodeNetwork;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mechanical network in interface form for interaction or extension
|
* Mechanical network in interface form for interaction or extension
|
||||||
*
|
*
|
||||||
* @author DarkGuardsman
|
* @author DarkGuardsman
|
||||||
*/
|
*/
|
||||||
public interface IMechanicalNetwork extends INetwork<IMechanicalNetwork, IMechanicalConnector, IMechanical>
|
public interface IMechanicalNetwork extends INodeNetwork<IMechanicalNetwork, IMechanicalConnector, IMechanical>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Gets the power of the network.
|
* Gets the power of the network.
|
||||||
|
|
|
@ -6,10 +6,9 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.api.net.IConnector;
|
import universalelectricity.api.net.IUpdate;
|
||||||
import universalelectricity.core.net.ConnectionPathfinder;
|
|
||||||
import universalelectricity.core.net.Network;
|
|
||||||
import universalelectricity.core.net.NetworkTickHandler;
|
import universalelectricity.core.net.NetworkTickHandler;
|
||||||
|
import universalelectricity.core.net.NodeNetwork;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mechanical network for translate speed and force using mechanical rotations.
|
* A mechanical network for translate speed and force using mechanical rotations.
|
||||||
|
@ -27,7 +26,7 @@ import universalelectricity.core.net.NetworkTickHandler;
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @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 long prevTorque = 0;
|
||||||
private float prevAngularVelocity = 0;
|
private float prevAngularVelocity = 0;
|
||||||
|
|
Loading…
Reference in a new issue