diff options
| author | Shawn Buckley <shawntbuckley@gmail.com> | 2015-10-21 22:15:09 -0400 |
|---|---|---|
| committer | Shawn Buckley <shawntbuckley@gmail.com> | 2015-10-21 22:15:09 -0400 |
| commit | 123aa6ed288b2f67b0d47177f4d27cd6893daf3a (patch) | |
| tree | 358e3704182f5b6fda44fa8b20605ab63edca092 /src/main/java/gregtech/api/interfaces/tileentity | |
| parent | 43ddecc7b9715d2038747566f89930b5db8d0181 (diff) | |
| download | GT5-Unofficial-123aa6ed288b2f67b0d47177f4d27cd6893daf3a.tar.gz GT5-Unofficial-123aa6ed288b2f67b0d47177f4d27cd6893daf3a.tar.bz2 GT5-Unofficial-123aa6ed288b2f67b0d47177f4d27cd6893daf3a.zip | |
Reformat code
Diffstat (limited to 'src/main/java/gregtech/api/interfaces/tileentity')
22 files changed, 802 insertions, 729 deletions
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java b/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java index 6b39391d46..423b3d4379 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IBasicEnergyContainer.java @@ -4,96 +4,97 @@ package gregtech.api.interfaces.tileentity; * Interface for internal Code, which is mainly used for independent Energy conversion. */ public interface IBasicEnergyContainer extends IEnergyConnected { - /** - * Gets if that Amount of Energy is stored inside the Machine. - * It is used for checking the contained Energy before consuming it. - * If this returns false, it will also give a Message inside the Scanner, that this Machine doesn't have enough Energy. - */ - public boolean isUniversalEnergyStored(long aEnergyAmount); - - /** - * Gets the stored electric, kinetic or steam Energy (with EU as reference Value) - * Always returns the largest one. - */ - public long getUniversalEnergyStored(); - - /** - * Gets the largest electric, kinetic or steam Energy Capacity (with EU as reference Value) - */ - public long getUniversalEnergyCapacity(); - - /** - * Gets the amount of Energy Packets per tick. - */ - public long getOutputAmperage(); - - /** - * Gets the Output in EU/p. - */ - public long getOutputVoltage(); - - /** - * Gets the amount of Energy Packets per tick. - */ - public long getInputAmperage(); - - /** - * Gets the maximum Input in EU/p. - */ - public long getInputVoltage(); - - /** - * Decreases the Amount of stored universal Energy. If ignoring too less Energy, then it just sets the Energy to 0 and returns false. - */ - public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy); - - /** - * Increases the Amount of stored electric Energy. If ignoring too much Energy, then the Energy Limit is just being ignored. - */ - public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy); - - /** - * Drain Energy Call for Electricity. - */ - public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage); - - /** - * returns the amount of Electricity, accepted by this Block the last 5 ticks as Average. - */ - public long getAverageElectricInput(); - - /** - * returns the amount of Electricity, outputted by this Block the last 5 ticks as Average. - */ - public long getAverageElectricOutput(); - - /** - * returns the amount of electricity contained in this Block, in EU units! - */ - public long getStoredEU(); - - /** - * returns the amount of electricity containable in this Block, in EU units! - */ - public long getEUCapacity(); - - /** - * returns the amount of Steam contained in this Block, in EU units! - */ - public long getStoredSteam(); - - /** - * returns the amount of Steam containable in this Block, in EU units! - */ - public long getSteamCapacity(); - - /** - * Increases stored Energy. Energy Base Value is in EU, even though it's Steam! - * @param aEnergy The Energy to add to the Machine. - * @param aIgnoreTooMuchEnergy if it shall ignore if it has too much Energy. - * @return if it was successful - * - * And yes, you can't directly decrease the Steam of a Machine. That is done by decreaseStoredEnergyUnits - */ - public boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy); + /** + * Gets if that Amount of Energy is stored inside the Machine. + * It is used for checking the contained Energy before consuming it. + * If this returns false, it will also give a Message inside the Scanner, that this Machine doesn't have enough Energy. + */ + public boolean isUniversalEnergyStored(long aEnergyAmount); + + /** + * Gets the stored electric, kinetic or steam Energy (with EU as reference Value) + * Always returns the largest one. + */ + public long getUniversalEnergyStored(); + + /** + * Gets the largest electric, kinetic or steam Energy Capacity (with EU as reference Value) + */ + public long getUniversalEnergyCapacity(); + + /** + * Gets the amount of Energy Packets per tick. + */ + public long getOutputAmperage(); + + /** + * Gets the Output in EU/p. + */ + public long getOutputVoltage(); + + /** + * Gets the amount of Energy Packets per tick. + */ + public long getInputAmperage(); + + /** + * Gets the maximum Input in EU/p. + */ + public long getInputVoltage(); + + /** + * Decreases the Amount of stored universal Energy. If ignoring too less Energy, then it just sets the Energy to 0 and returns false. + */ + public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy); + + /** + * Increases the Amount of stored electric Energy. If ignoring too much Energy, then the Energy Limit is just being ignored. + */ + public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy); + + /** + * Drain Energy Call for Electricity. + */ + public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage); + + /** + * returns the amount of Electricity, accepted by this Block the last 5 ticks as Average. + */ + public long getAverageElectricInput(); + + /** + * returns the amount of Electricity, outputted by this Block the last 5 ticks as Average. + */ + public long getAverageElectricOutput(); + + /** + * returns the amount of electricity contained in this Block, in EU units! + */ + public long getStoredEU(); + + /** + * returns the amount of electricity containable in this Block, in EU units! + */ + public long getEUCapacity(); + + /** + * returns the amount of Steam contained in this Block, in EU units! + */ + public long getStoredSteam(); + + /** + * returns the amount of Steam containable in this Block, in EU units! + */ + public long getSteamCapacity(); + + /** + * Increases stored Energy. Energy Base Value is in EU, even though it's Steam! + * + * @param aEnergy The Energy to add to the Machine. + * @param aIgnoreTooMuchEnergy if it shall ignore if it has too much Energy. + * @return if it was successful + * <p/> + * And yes, you can't directly decrease the Steam of a Machine. That is done by decreaseStoredEnergyUnits + */ + public boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy); }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java index dc511f3050..6b69911ad2 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IColoredTileEntity.java @@ -1,14 +1,15 @@ package gregtech.api.interfaces.tileentity; public interface IColoredTileEntity { - /** - * @return 0 - 15 are Colors, while -1 means uncolored - */ - public byte getColorization(); - - /** - * Sets the Color Modulation of the Block - * @param aColor the Color you want to set it to. -1 for reset. - */ - public byte setColorization(byte aColor); + /** + * @return 0 - 15 are Colors, while -1 means uncolored + */ + public byte getColorization(); + + /** + * Sets the Color Modulation of the Block + * + * @param aColor the Color you want to set it to. -1 for reset. + */ + public byte setColorization(byte aColor); } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java index 546b8d81c6..99ec88c149 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/ICoverable.java @@ -4,32 +4,41 @@ import gregtech.api.util.GT_CoverBehavior; import net.minecraft.item.ItemStack; public interface ICoverable extends IRedstoneTileEntity, IHasInventory, IBasicEnergyContainer { - public boolean canPlaceCoverIDAtSide (byte aSide, int aID); - public boolean canPlaceCoverItemAtSide (byte aSide, ItemStack aCover); - public boolean dropCover (byte aSide, byte aDroppedSide, boolean aForced); - public void setCoverDataAtSide (byte aSide, int aData); - public void setCoverIDAtSide (byte aSide, int aID); - public void setCoverItemAtSide (byte aSide, ItemStack aCover); - public int getCoverDataAtSide (byte aSide); - public int getCoverIDAtSide (byte aSide); - public ItemStack getCoverItemAtSide (byte aSide); - public GT_CoverBehavior getCoverBehaviorAtSide (byte aSide); - - /** - * For use by the regular MetaTileEntities. Returns the Cover Manipulated input Redstone. - * Don't use this if you are a Cover Behavior. Only for MetaTileEntities. - */ - public byte getInternalInputRedstoneSignal(byte aSide); - - /** - * For use by the regular MetaTileEntities. This makes it not conflict with Cover based Redstone Signals. - * Don't use this if you are a Cover Behavior. Only for MetaTileEntities. - */ - public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength); - - /** - * Causes a general Cover Texture update. - * Sends 6 Integers to Client + causes @issueTextureUpdate() - */ - public void issueCoverUpdate(byte aSide); + public boolean canPlaceCoverIDAtSide(byte aSide, int aID); + + public boolean canPlaceCoverItemAtSide(byte aSide, ItemStack aCover); + + public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced); + + public void setCoverDataAtSide(byte aSide, int aData); + + public void setCoverIDAtSide(byte aSide, int aID); + + public void setCoverItemAtSide(byte aSide, ItemStack aCover); + + public int getCoverDataAtSide(byte aSide); + + public int getCoverIDAtSide(byte aSide); + + public ItemStack getCoverItemAtSide(byte aSide); + + public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide); + + /** + * For use by the regular MetaTileEntities. Returns the Cover Manipulated input Redstone. + * Don't use this if you are a Cover Behavior. Only for MetaTileEntities. + */ + public byte getInternalInputRedstoneSignal(byte aSide); + + /** + * For use by the regular MetaTileEntities. This makes it not conflict with Cover based Redstone Signals. + * Don't use this if you are a Cover Behavior. Only for MetaTileEntities. + */ + public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength); + + /** + * Causes a general Cover Texture update. + * Sends 6 Integers to Client + causes @issueTextureUpdate() + */ + public void issueCoverUpdate(byte aSide); }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IDigitalChest.java b/src/main/java/gregtech/api/interfaces/tileentity/IDigitalChest.java index d017a1d7c4..8f55b75fcf 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IDigitalChest.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IDigitalChest.java @@ -6,24 +6,26 @@ import net.minecraft.item.ItemStack; * You are allowed to include this File in your Download, as i will not change it. */ public interface IDigitalChest extends IHasWorldObjectAndCoords { - /** - * Is this even a TileEntity of a Digital Chest? - * I need things like this Function for MetaTileEntities, you MUST check this!!! - * Do not assume that it's a Digital Chest or similar Device, when it just implements this Interface. - */ - public boolean isDigitalChest(); - /** - * Gives an Array of Stacks with Size (of all the Data-stored Items) of the correspondent Item kinds (regular QChests have only one) - * Does NOT include the 64 "ready" Items inside the Slots, and neither the 128 Items in the overflow Buffer. - */ - public ItemStack[] getStoredItemData(); - /** - * A generic Interface for just setting the amount of contained Items - */ - public void setItemCount(int aCount); - - /** - * Gets the maximum Item count for this QChest alike Storage. This applies to the Data-Storage, not for the up to 192 buffered Items! - */ - public int getMaxItemCount(); + /** + * Is this even a TileEntity of a Digital Chest? + * I need things like this Function for MetaTileEntities, you MUST check this!!! + * Do not assume that it's a Digital Chest or similar Device, when it just implements this Interface. + */ + public boolean isDigitalChest(); + + /** + * Gives an Array of Stacks with Size (of all the Data-stored Items) of the correspondent Item kinds (regular QChests have only one) + * Does NOT include the 64 "ready" Items inside the Slots, and neither the 128 Items in the overflow Buffer. + */ + public ItemStack[] getStoredItemData(); + + /** + * A generic Interface for just setting the amount of contained Items + */ + public void setItemCount(int aCount); + + /** + * Gets the maximum Item count for this QChest alike Storage. This applies to the Data-Storage, not for the up to 192 buffered Items! + */ + public int getMaxItemCount(); }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConductor.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConductor.java index 96684de6e3..2384678529 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConductor.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConductor.java @@ -4,37 +4,37 @@ import gregtech.api.enums.Materials; /** * Informative Class for Cables. Not used for now. - * + * <p/> * Not all Data might be reliable. This is just for Information sake. */ public interface IEnergyConductor extends IEnergyConnected { - /** - * @return if this is actually a Cable. (you must check this) - */ - public boolean isConductor(); - - /** - * @return the maximum Voltage of the Cable. - */ - public long getMaxVoltage(); - - /** - * @return the maximum Amperage of the Cable, per Wire. - */ - public long getMaxAmperage(); - - /** - * @return the Loss of the Cable, per Meter. - */ - public long getLossPerMeter(); - - /** - * @return the Material the Cable consists of. (may return Materials._NULL) - */ - public Materials getCableMaterial(); - - /** - * @return the Material the Cable Insulation consists of. (may return Materials._NULL) - */ - public Materials getInsulationMaterial(); + /** + * @return if this is actually a Cable. (you must check this) + */ + public boolean isConductor(); + + /** + * @return the maximum Voltage of the Cable. + */ + public long getMaxVoltage(); + + /** + * @return the maximum Amperage of the Cable, per Wire. + */ + public long getMaxAmperage(); + + /** + * @return the Loss of the Cable, per Meter. + */ + public long getLossPerMeter(); + + /** + * @return the Material the Cable consists of. (may return Materials._NULL) + */ + public Materials getCableMaterial(); + + /** + * @return the Material the Cable Insulation consists of. (may return Materials._NULL) + */ + public Materials getInsulationMaterial(); }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index 097493807d..b62ed4500b 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -1,6 +1,5 @@ package gregtech.api.interfaces.tileentity; -import static gregtech.api.enums.GT_Values.V; import cofh.api.energy.IEnergyReceiver; import gregtech.api.GregTech_API; import gregtech.api.util.GT_Utility; @@ -10,80 +9,88 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import static gregtech.api.enums.GT_Values.V; + /** * Interface for getting Connected to the GregTech Energy Network. - * + * <p/> * This is all you need to connect to the GT Network. * IColoredTileEntity is needed for not connecting differently coloured Blocks to each other. * IHasWorldObjectAndCoords is needed for the InWorld related Stuff. @BaseTileEntity does implement most of that Interface. */ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAndCoords { - /** - * Inject Energy Call for Electricity. Gets called by EnergyEmitters to inject Energy into your Block - * - * Note: you have to check for @inputEnergyFrom because the Network won't check for that by itself. - * - * @param aSide 0 - 5 = Vanilla Directions of YOUR Block the Energy gets inserted to. 6 = No specific Side (don't do Side checks for this Side) - * @return amount of used Amperes. 0 if not accepted anything. - */ - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage); - - /** - * Sided Energy Input - */ - public boolean inputEnergyFrom(byte aSide); - - /** - * Sided Energy Output - */ - public boolean outputsEnergyTo(byte aSide); - - /** - * Utility for the Network - */ - public static class Util { - /** - * Emits Energy to the E-net. Also compatible with adjacent IC2 TileEntities. - * @return the used Amperage. - */ - public static final long emitEnergyToNetwork(long aVoltage, long aAmperage, IEnergyConnected aEmitter) { - long rUsedAmperes = 0; - for (byte i = 0, j = 0; i < 6 && aAmperage > rUsedAmperes; i++) if (aEmitter.outputsEnergyTo(i)) { - j = GT_Utility.getOppositeSide(i); - TileEntity tTileEntity = aEmitter.getTileEntityAtSide(i); - if (tTileEntity instanceof IEnergyConnected) { - if (aEmitter.getColorization() >= 0) { - byte tColor = ((IEnergyConnected)tTileEntity).getColorization(); - if (tColor >= 0 && tColor != aEmitter.getColorization()) continue; - } - rUsedAmperes+=((IEnergyConnected)tTileEntity).injectEnergyUnits(j, aVoltage, aAmperage-rUsedAmperes); + /** + * Inject Energy Call for Electricity. Gets called by EnergyEmitters to inject Energy into your Block + * <p/> + * Note: you have to check for @inputEnergyFrom because the Network won't check for that by itself. + * + * @param aSide 0 - 5 = Vanilla Directions of YOUR Block the Energy gets inserted to. 6 = No specific Side (don't do Side checks for this Side) + * @return amount of used Amperes. 0 if not accepted anything. + */ + public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage); + + /** + * Sided Energy Input + */ + public boolean inputEnergyFrom(byte aSide); + + /** + * Sided Energy Output + */ + public boolean outputsEnergyTo(byte aSide); + + /** + * Utility for the Network + */ + public static class Util { + /** + * Emits Energy to the E-net. Also compatible with adjacent IC2 TileEntities. + * + * @return the used Amperage. + */ + public static final long emitEnergyToNetwork(long aVoltage, long aAmperage, IEnergyConnected aEmitter) { + long rUsedAmperes = 0; + for (byte i = 0, j = 0; i < 6 && aAmperage > rUsedAmperes; i++) + if (aEmitter.outputsEnergyTo(i)) { + j = GT_Utility.getOppositeSide(i); + TileEntity tTileEntity = aEmitter.getTileEntityAtSide(i); + if (tTileEntity instanceof IEnergyConnected) { + if (aEmitter.getColorization() >= 0) { + byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); + if (tColor >= 0 && tColor != aEmitter.getColorization()) continue; + } + rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits(j, aVoltage, aAmperage - rUsedAmperes); // } else if (tTileEntity instanceof IEnergySink) { // if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aEmitter, ForgeDirection.getOrientation(j))) { // while (aAmperage > rUsedAmperes && ((IEnergySink)tTileEntity).demandedEnergyUnits() > 0 && ((IEnergySink)tTileEntity).injectEnergyUnits(ForgeDirection.getOrientation(j), aVoltage) < aVoltage) rUsedAmperes++; // } - } else if (tTileEntity instanceof IEnergySink) { - if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aEmitter, ForgeDirection.getOrientation(j))) { - while (aAmperage > rUsedAmperes && ((IEnergySink)tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink)tTileEntity).injectEnergy(ForgeDirection.getOrientation(j), aVoltage, aVoltage) < aVoltage) rUsedAmperes++; - } - } else if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver){ - ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100); - if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)==rfOut){ - ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++; - } - if(GregTech_API.mRFExplosions && GregTech_API.sMachineExplosions && ((IEnergyReceiver)tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600){ - if(rfOut > 32 * GregTech_API.mEUtoRF / 100) { - int aExplosionPower = rfOut; - float tStrength = aExplosionPower<V[0]?1.0F:aExplosionPower<V[1]?2.0F:aExplosionPower<V[2]?3.0F:aExplosionPower<V[3]?4.0F:aExplosionPower<V[4]?5.0F:aExplosionPower<V[4]*2?6.0F:aExplosionPower<V[5]?7.0F:aExplosionPower<V[6]?8.0F:aExplosionPower<V[7]?9.0F:10.0F; - int tX=tTileEntity.xCoord, tY=tTileEntity.yCoord, tZ=tTileEntity.zCoord; - World tWorld = tTileEntity.getWorldObj(); - GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); - tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) tWorld.createExplosion(null, tX+0.5, tY+0.5, tZ+0.5, tStrength, true);} - } - } - } - return rUsedAmperes; - } - } + } else if (tTileEntity instanceof IEnergySink) { + if (((IEnergySink) tTileEntity).acceptsEnergyFrom((TileEntity) aEmitter, ForgeDirection.getOrientation(j))) { + while (aAmperage > rUsedAmperes && ((IEnergySink) tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink) tTileEntity).injectEnergy(ForgeDirection.getOrientation(j), aVoltage, aVoltage) < aVoltage) + rUsedAmperes++; + } + } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) { + ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); + int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100); + if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) { + ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); + rUsedAmperes++; + } + if (GregTech_API.mRFExplosions && GregTech_API.sMachineExplosions && ((IEnergyReceiver) tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600) { + if (rfOut > 32 * GregTech_API.mEUtoRF / 100) { + int aExplosionPower = rfOut; + float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < V[4] * 2 ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F; + int tX = tTileEntity.xCoord, tY = tTileEntity.yCoord, tZ = tTileEntity.zCoord; + World tWorld = tTileEntity.getWorldObj(); + GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); + tWorld.setBlock(tX, tY, tZ, Blocks.air); + if (GregTech_API.sMachineExplosions) + tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); + } + } + } + } + return rUsedAmperes; + } + } }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java index f6758f2cd9..7e86701f6b 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IExperimentalEnergyTileEntity.java @@ -1,84 +1,93 @@ package gregtech.api.interfaces.tileentity; +import cofh.api.energy.IEnergyReceiver; import gregtech.api.enums.SubTag; import gregtech.api.util.GT_Utility; import ic2.api.energy.tile.IEnergySink; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import cofh.api.energy.IEnergyReceiver; /** * THIS IS GOING TO BE USED IN 1.8 - * + * <p/> * Interface for getting Connected to the GregTech Energy Network. - * + * <p/> * This is all you need to connect to the GT Network. * IColoredTileEntity is needed for not connecting differently coloured Blocks to each other. * IHasWorldObjectAndCoords is needed for the InWorld related Stuff. @BaseTileEntity does implement most of that Interface. */ public interface IExperimentalEnergyTileEntity extends IColoredTileEntity, IHasWorldObjectAndCoords { - /** - * Inject Energy Call for Electricity. Gets called by EnergyEmitters to inject Energy into your Block - * - * Note: you have to check for @inputEnergyFrom because the Network won't check for that by itself. - * - * @param aSide 0 - 5 = Vanilla Directions of YOUR Block the Energy gets inserted to. 6 = No specific Side (don't do Side checks for this Side) - * @return amount of used Amperes. 0 if not accepted anything. - */ - public long injectEnergy(SubTag aEnergyType, byte aSide, long aPrimary, long aSecondary); - - /** Sided Energy Input */ - public boolean inputEnergyFrom(SubTag aEnergyType, byte aSide); - - /** Sided Energy Output */ - public boolean outputsEnergyTo(SubTag aEnergyType, byte aSide); - - /** Utility for the Network */ - public static class Util { - private static boolean RF_ENERGY = false, IC_ENERGY = false, CHECK_ALL = true; - public static int RF_PER_EU = 4; - - private static void checkAvailabilities() { - if (CHECK_ALL) { - try { - Class tClass = cofh.api.energy.IEnergyReceiver.class; - tClass.getCanonicalName(); - RF_ENERGY = true; - } catch(Throwable e) {/**/} - try { - Class tClass = ic2.api.energy.tile.IEnergySink.class; - tClass.getCanonicalName(); - IC_ENERGY = true; - } catch(Throwable e) {/**/} - CHECK_ALL = false; - } - } - - /** - * Emits Energy to the adjacent Blocks. Also compatible with adjacent IC2 TileEntities when electric and RF TileEntities when RedstoneFlux. - * @return the amount of used secondary value. - */ - public static final long emitEnergyToNetwork(SubTag aEnergyType, long aPrimary, long aSecondary, IExperimentalEnergyTileEntity aEmitter) { - long rUsedSecondary = 0; - checkAvailabilities(); - for (byte i = 0, j = 0; i < 6 && aSecondary > rUsedSecondary; i++) if (aEmitter.outputsEnergyTo(aEnergyType, i)) { - j = GT_Utility.getOppositeSide(i); - TileEntity tTileEntity = aEmitter.getTileEntityAtSide(i); - if (tTileEntity instanceof IExperimentalEnergyTileEntity) { - if (aEmitter.getColorization() >= 0) { - byte tColor = ((IExperimentalEnergyTileEntity)tTileEntity).getColorization(); - if (tColor >= 0 && tColor != aEmitter.getColorization()) continue; - } - rUsedSecondary+=((IExperimentalEnergyTileEntity)tTileEntity).injectEnergy(aEnergyType, j, aPrimary, aSecondary-rUsedSecondary); - } else if (IC_ENERGY && aEnergyType == SubTag.ENERGY_ELECTRICITY && tTileEntity instanceof IEnergySink) { - if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aEmitter, ForgeDirection.getOrientation(j))) { - while (aSecondary > rUsedSecondary && ((IEnergySink)tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink)tTileEntity).injectEnergy(ForgeDirection.getOrientation(j), aPrimary, aPrimary) < aPrimary) rUsedSecondary++; - } - } else if (RF_ENERGY && aEnergyType == SubTag.ENERGY_REDSTONE_FLUX && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver)tTileEn |
