Patched ME energy tunnel, now they can emit GT energy.
This commit is contained in:
parent
f94d61a3d2
commit
ded594c86c
3 changed files with 116 additions and 0 deletions
86
src/main/java/appeng/parts/p2p/PartP2PGTPower.java
Normal file
86
src/main/java/appeng/parts/p2p/PartP2PGTPower.java
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -597,6 +597,7 @@ public class GT_Mod implements IGT_Mod {
|
||||||
new GT_CropLoader().run();
|
new GT_CropLoader().run();
|
||||||
new GT_Worldgenloader().run();
|
new GT_Worldgenloader().run();
|
||||||
new GT_CoverLoader().run();
|
new GT_CoverLoader().run();
|
||||||
|
new GT_AE2EnergyTunnelLoader().run();
|
||||||
LoadArmorComponents.init();
|
LoadArmorComponents.init();
|
||||||
|
|
||||||
GT_RecipeRegistrator.registerUsagesForMaterials(new ItemStack(Blocks.planks, 1), null, false);
|
GT_RecipeRegistrator.registerUsagesForMaterials(new ItemStack(Blocks.planks, 1), null, false);
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package gregtech.loaders.postload;
|
||||||
|
|
||||||
|
import appeng.items.parts.PartType;
|
||||||
|
import appeng.parts.p2p.PartP2PGTPower;
|
||||||
|
import gregtech.GT_Mod;
|
||||||
|
import gregtech.api.util.GT_Log;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class GT_AE2EnergyTunnelLoader implements Runnable {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (GT_Mod.gregtechproxy.mAE2Integration) {
|
||||||
|
try {
|
||||||
|
load();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
GT_Log.out.println("Failed to load P2P tunnel for GT electricity");
|
||||||
|
e.printStackTrace(GT_Log.out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() throws Throwable {
|
||||||
|
Field f = PartType.class.getDeclaredField("myPart");
|
||||||
|
f.setAccessible(true);
|
||||||
|
f.set(PartType.P2PTunnelEU, PartP2PGTPower.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue