Added TE support for universal wires
This commit is contained in:
parent
7c79270259
commit
ab32553c2d
2 changed files with 57 additions and 3 deletions
|
@ -28,6 +28,7 @@ public class MultipartMI implements IPartFactory
|
||||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_wire" });
|
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_wire" });
|
||||||
MultipartGenerator.registerPassThroughInterface("universalelectricity.core.block.IConductor");
|
MultipartGenerator.registerPassThroughInterface("universalelectricity.core.block.IConductor");
|
||||||
MultipartGenerator.registerPassThroughInterface("buildcraft.api.power.IPowerReceptor");
|
MultipartGenerator.registerPassThroughInterface("buildcraft.api.power.IPowerReceptor");
|
||||||
|
MultipartGenerator.registerPassThroughInterface("cofh.api.energy.IEnergyHandler");
|
||||||
MultipartGenerator.registerPassThroughInterface("mekanism.induction.common.wire.IInsulatedMaterial");
|
MultipartGenerator.registerPassThroughInterface("mekanism.induction.common.wire.IInsulatedMaterial");
|
||||||
MultipartGenerator.registerPassThroughInterface("mekanism.induction.common.wire.IBlockableConnection");
|
MultipartGenerator.registerPassThroughInterface("mekanism.induction.common.wire.IBlockableConnection");
|
||||||
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "mekanism.induction.common.wire.TEnergySink");
|
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "mekanism.induction.common.wire.TEnergySink");
|
||||||
|
|
|
@ -20,8 +20,9 @@ import buildcraft.api.power.IPowerReceptor;
|
||||||
import buildcraft.api.power.PowerHandler;
|
import buildcraft.api.power.PowerHandler;
|
||||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||||
import buildcraft.api.power.PowerHandler.Type;
|
import buildcraft.api.power.PowerHandler.Type;
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
|
||||||
public abstract class PartUniversalConductor extends PartConductor implements IEnergySink, IPowerReceptor
|
public abstract class PartUniversalConductor extends PartConductor implements IEnergySink, IPowerReceptor, IEnergyHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
protected boolean isAddedToEnergyNet;
|
protected boolean isAddedToEnergyNet;
|
||||||
|
@ -38,14 +39,19 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidAcceptor(TileEntity tile)
|
public boolean isValidAcceptor(TileEntity tile)
|
||||||
{
|
{
|
||||||
if (Compatibility.isIndustrialCraft2Loaded() && tile instanceof IEnergyTile)
|
if (tile instanceof IEnergyTile)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (Compatibility.isBuildcraftLoaded() && tile instanceof IPowerReceptor)
|
else if (tile instanceof IPowerReceptor)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (tile instanceof IEnergyHandler)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return super.isValidAcceptor(tile);
|
return super.isValidAcceptor(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,4 +204,51 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
||||||
{
|
{
|
||||||
return world();
|
return world();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thermal Expansion Functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
||||||
|
{
|
||||||
|
ElectricityPack pack = ElectricityPack.getFromWatts(maxReceive * Compatibility.TE_RATIO, 1);
|
||||||
|
float request = this.getMaxEnergyStored(from);
|
||||||
|
|
||||||
|
if (!simulate)
|
||||||
|
{
|
||||||
|
if (request > 0)
|
||||||
|
{
|
||||||
|
return (int) (maxReceive - (this.getNetwork().produce(pack, new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(this.world())) * Compatibility.TO_TE_RATIO));
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) Math.min(maxReceive, request * Compatibility.TO_TE_RATIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInterface(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnergyStored(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxEnergyStored(ForgeDirection from)
|
||||||
|
{
|
||||||
|
return (int) (this.getNetwork().getRequest(new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(this.world())).getWatts() * Compatibility.TO_TE_RATIO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue