From 4f41f5a1df71e3768b75c6a29f1d4aa7a505310b Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Thu, 2 Oct 2014 18:42:04 +0100 Subject: [PATCH] Prevent IC2 double-outputting. --- .../ic2/api/energy/tile/IEnergyConductor.java | 53 +++++++++++++++++++ .../common/tile/TileEntityElectricBlock.java | 3 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/api/java/ic2/api/energy/tile/IEnergyConductor.java diff --git a/src/api/java/ic2/api/energy/tile/IEnergyConductor.java b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java new file mode 100644 index 000000000..08dab8896 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IEnergyConductor.java @@ -0,0 +1,53 @@ +package ic2.api.energy.tile; + +/** + * Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this + * interface. + * + * See ic2/api/energy/usage.txt for an overall description of the energy net api. + */ +public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter { + /** + * Energy loss for the conductor in EU per block. + * + * @return Energy loss + */ + double getConductionLoss(); + + /** + * Amount of energy the insulation will handle before shocking nearby players and mobs. + * + * @return Insulation energy absorption in EU + */ + double getInsulationEnergyAbsorption(); + + /** + * Amount of energy the insulation will handle before it is destroyed. + * Ensure that this value is greater than the insulation energy absorption + 64. + * + * @return Insulation-destroying energy in EU + */ + double getInsulationBreakdownEnergy(); + + /** + * Amount of energy the conductor will handle before it melts. + * + * @return Conductor-destroying energy in EU + */ + double getConductorBreakdownEnergy(); + + /** + * Remove the conductor's insulation if the insulation breakdown energy was exceeded. + * + * @see #getInsulationBreakdownEnergy() + */ + void removeInsulation(); + + /** + * Remove the conductor if the conductor breakdown energy was exceeded. + * + * @see #getConductorBreakdownEnergy() + */ + void removeConductor(); +} + diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java index 45163e03c..e1e2c6e0b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java @@ -3,6 +3,7 @@ package mekanism.common.tile; import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergyConductor; import ic2.api.energy.tile.IEnergySink; import ic2.api.energy.tile.IEnergySource; import ic2.api.energy.tile.IEnergyTile; @@ -375,7 +376,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Method(modid = "IC2") public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { - return getOutputtingSides().contains(direction); + return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; } @Override