diff options
author | Dimach <dimach2142@gmail.com> | 2017-08-27 01:55:20 +0300 |
---|---|---|
committer | Dimach <dimach2142@gmail.com> | 2017-08-27 01:55:20 +0300 |
commit | ded594c86c701a0ff1f2282b4d6bff9cc7b1b9f6 (patch) | |
tree | 24effc783fd7f6f1df29ddee75c52526eef9d5cb /src/main/java/appeng/parts/p2p/PartP2PGTPower.java | |
parent | f94d61a3d27f34555c5ccc1171501e1b768be4aa (diff) | |
download | GT5-Unofficial-ded594c86c701a0ff1f2282b4d6bff9cc7b1b9f6.tar.gz GT5-Unofficial-ded594c86c701a0ff1f2282b4d6bff9cc7b1b9f6.tar.bz2 GT5-Unofficial-ded594c86c701a0ff1f2282b4d6bff9cc7b1b9f6.zip |
Patched ME energy tunnel, now they can emit GT energy.
Diffstat (limited to 'src/main/java/appeng/parts/p2p/PartP2PGTPower.java')
-rw-r--r-- | src/main/java/appeng/parts/p2p/PartP2PGTPower.java | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/main/java/appeng/parts/p2p/PartP2PGTPower.java b/src/main/java/appeng/parts/p2p/PartP2PGTPower.java new file mode 100644 index 0000000000..a4fc3ce24b --- /dev/null +++ b/src/main/java/appeng/parts/p2p/PartP2PGTPower.java @@ -0,0 +1,86 @@ +package appeng.parts.p2p; + +import appeng.api.networking.IGridNode; +import appeng.api.networking.ticking.IGridTickable; +import appeng.api.networking.ticking.TickRateModulation; +import appeng.api.networking.ticking.TickingRequest; +import gregtech.api.interfaces.tileentity.IEnergyConnected; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class PartP2PGTPower extends PartP2PIC2Power implements IGridTickable { + public PartP2PGTPower(ItemStack is) { + super(is); + } + + public final World getWorld() { + return tile.getWorldObj(); + } + + public final int getXCoord() { + return tile.xCoord; + } + + public final short getYCoord() { + return (short) tile.yCoord; + } + + public final int getZCoord() { + return tile.zCoord; + } + + public final int getOffsetX(byte aSide, int aMultiplier) { + return getXCoord() + ForgeDirection.getOrientation(aSide).offsetX * aMultiplier; + } + + public final short getOffsetY(byte aSide, int aMultiplier) { + return (short) (getYCoord() + ForgeDirection.getOrientation(aSide).offsetY * aMultiplier); + } + + public final int getOffsetZ(byte aSide, int aMultiplier) { + return getZCoord() + ForgeDirection.getOrientation(aSide).offsetZ * aMultiplier; + } + + public final TileEntity getTileEntity(int aX, int aY, int aZ) { + return getWorld().getTileEntity(aX, aY, aZ); + } + + public final TileEntity getTileEntityAtSide(byte aSide) { + int tX = getOffsetX(aSide, 1), tY = getOffsetY(aSide, 1), tZ = getOffsetZ(aSide, 1); + return getWorld().getTileEntity(tX, tY, tZ); + } + + public boolean outputEnergy() { + if (OutputEnergyA == 0) { + return false; + } + TileEntity t = getTileEntityAtSide((byte) side.ordinal()); + if (t instanceof IEnergyConnected) { + long l = ((IEnergyConnected) t).injectEnergyUnits(GT_Utility.getOppositeSide(side.ordinal()), (long) OutputVoltageA, ((long) OutputEnergyA) / ((long) OutputVoltageA)); + if (l > 0) { + OutputEnergyA -= ((long) OutputVoltageA) * l; + if (OutputEnergyA < 1) { + OutputEnergyA = OutputEnergyB; + OutputVoltageA = OutputVoltageB; + OutputEnergyB = 0; + OutputVoltageB = 0; + } + return true; + } + } + return false; + } + + @Override + public TickingRequest getTickingRequest(IGridNode iGridNode) { + return new TickingRequest(1, 10, false, false); + } + + @Override + public TickRateModulation tickingRequest(IGridNode iGridNode, int i) { + return outputEnergy() ? TickRateModulation.FASTER : TickRateModulation.SLOWER; + } +} |