diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-04-09 17:55:01 +0200 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-04-09 17:55:01 +0200 |
commit | 9b71ae54da263e6c5d0e808f847f8ba8fe6c891a (patch) | |
tree | 7be3b1218654844980e812a243e3c6c045635800 /src/main/java/gregtech/api/util/GT_GC_Compat.java | |
parent | 1ed85c72f194d996ad3a1b44c0e74c9597b5326e (diff) | |
download | GT5-Unofficial-9b71ae54da263e6c5d0e808f847f8ba8fe6c891a.tar.gz GT5-Unofficial-9b71ae54da263e6c5d0e808f847f8ba8fe6c891a.tar.bz2 GT5-Unofficial-9b71ae54da263e6c5d0e808f847f8ba8fe6c891a.zip |
fixes
+refractored code,
+restored compability to vanilla ore gen,
+moved GC and Forrestry code to own classes to prevent crashes inDev
+implemented equals and hashcode on NearbySeeds class
+added an information line to the Implosion Compressor tooltip
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_GC_Compat.java')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_GC_Compat.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_GC_Compat.java b/src/main/java/gregtech/api/util/GT_GC_Compat.java new file mode 100644 index 0000000000..8131e3affb --- /dev/null +++ b/src/main/java/gregtech/api/util/GT_GC_Compat.java @@ -0,0 +1,47 @@ +package gregtech.api.util; + +import gregtech.api.GregTech_API; +import micdoodle8.mods.galacticraft.api.power.EnergySource; +import micdoodle8.mods.galacticraft.api.power.EnergySource.EnergySourceAdjacent; +import micdoodle8.mods.galacticraft.api.power.IEnergyHandlerGC; +import micdoodle8.mods.galacticraft.api.transmission.NetworkType; +import micdoodle8.mods.galacticraft.api.transmission.tile.IConnector; +import micdoodle8.mods.galacticraft.core.energy.EnergyConfigHandler; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public class GT_GC_Compat { + + public static long insertEnergyInto(TileEntity tTileEntity, long aVoltage, ForgeDirection tDirection) { + // GC Compat + if (GregTech_API.mGalacticraft && tTileEntity instanceof IEnergyHandlerGC) { + if (!(tTileEntity instanceof IConnector) || ((IConnector)tTileEntity).canConnect(tDirection, NetworkType.POWER)) { + EnergySource eSource = new EnergySourceAdjacent(tDirection); + + float tSizeToReceive = aVoltage * EnergyConfigHandler.IC2_RATIO, tStored = ((IEnergyHandlerGC)tTileEntity).getEnergyStoredGC(eSource); + if (tSizeToReceive >= tStored || tSizeToReceive <= ((IEnergyHandlerGC)tTileEntity).getMaxEnergyStoredGC(eSource) - tStored) { + float tReceived = ((IEnergyHandlerGC)tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false); + if (tReceived > 0) { + tSizeToReceive -= tReceived; + while (tSizeToReceive > 0) { + tReceived = ((IEnergyHandlerGC)tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false); + if (tReceived < 1) break; + tSizeToReceive -= tReceived; + } + return 1; + } + } + } + return 0; + } + return 2; + } + + public static boolean canConnect(TileEntity tTileEntity,ForgeDirection tDirection){ + // GC Compat + if (GregTech_API.mGalacticraft && tTileEntity instanceof IEnergyHandlerGC && (!(tTileEntity instanceof IConnector) || ((IConnector)tTileEntity).canConnect(tDirection, NetworkType.POWER))) + return true; + return false; + } + +} |