From 4990443e9af5256f9a2e973024ca6da1d62dc781 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Tue, 21 Jan 2014 22:30:49 +0800 Subject: [PATCH] Fixed framed wires not connecting --- .../electrical/wire/framed/PartFramedWire.java | 16 +++++++++------- .../electrical/wire/trait/TraitConductor.java | 11 +++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java b/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java index 9be3e313..e6e5abba 100644 --- a/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java +++ b/src/main/java/resonantinduction/electrical/wire/framed/PartFramedWire.java @@ -283,9 +283,9 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN { if (tile() != null && this.getNetwork() != null) { - getNetwork().getConnectors().remove(tile()); + getNetwork().getConnectors().remove(this); super.bind(t); - getNetwork().getConnectors().add((IConductor) tile()); + getNetwork().getConnectors().add((IConductor) this); } else { @@ -374,7 +374,7 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN try { this.getNetwork().removeConnector(this); - this.getNetwork().split((IConductor) tile()); + this.getNetwork().split((IConductor) this); } catch (NullPointerException e) { @@ -390,7 +390,10 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN if (tileEntity instanceof IConductor) { - this.getNetwork().merge(((IConductor) tileEntity).getNetwork()); + IConductor conductor = (IConductor) ((IConductor) tileEntity).getInstance(side.getOpposite()); + + if (conductor != null) + this.getNetwork().merge(conductor.getNetwork()); } } } @@ -445,7 +448,7 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN return false; } - Vector3 connectPos = new Vector3(tile()).modifyPositionFromSide(direction); + Vector3 connectPos = new Vector3(tile()).translate(direction); TileEntity connectTile = connectPos.getTileEntity(world()); return !isConnectionPrevented(connectTile, direction); } @@ -537,8 +540,7 @@ public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JN this.currentWireConnections = otherCable.currentWireConnections; this.currentAcceptorConnections = otherCable.currentAcceptorConnections; this.setNetwork(otherCable.getNetwork()); - this.getNetwork().setBufferFor(this, otherCable.getNetwork().getBufferOf(otherCable)); + this.getNetwork().setBufferFor(this, otherCable.getInstance(ForgeDirection.UNKNOWN).getNetwork().getBufferOf(otherCable)); } - } \ No newline at end of file diff --git a/src/main/java/resonantinduction/electrical/wire/trait/TraitConductor.java b/src/main/java/resonantinduction/electrical/wire/trait/TraitConductor.java index df337fb8..f23f6790 100644 --- a/src/main/java/resonantinduction/electrical/wire/trait/TraitConductor.java +++ b/src/main/java/resonantinduction/electrical/wire/trait/TraitConductor.java @@ -7,6 +7,7 @@ import net.minecraftforge.common.ForgeDirection; import universalelectricity.api.energy.IConductor; import universalelectricity.api.energy.IEnergyNetwork; import universalelectricity.api.net.IConnector; +import codechicken.multipart.PartMap; import codechicken.multipart.TMultiPart; import codechicken.multipart.TileMultipart; @@ -112,6 +113,11 @@ public class TraitConductor extends TileMultipart implements IConductor } } } + + if (partMap(PartMap.CENTER.ordinal()) instanceof IConductor) + { + return ((IConductor) partMap(PartMap.CENTER.ordinal())).onReceiveEnergy(from, receive, doReceive); + } return 0; } @@ -177,6 +183,11 @@ public class TraitConductor extends TileMultipart implements IConductor } } + if (partMap(PartMap.CENTER.ordinal()) instanceof IConductor) + { + return (IConnector) partMap(PartMap.CENTER.ordinal()); + } + return null; } }