Fixed framed wires not connecting

This commit is contained in:
Calclavia 2014-01-21 22:30:49 +08:00
parent 79d22687f6
commit 4990443e9a
2 changed files with 20 additions and 7 deletions

View file

@ -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));
}
}

View file

@ -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<IEnergyNetwork>) partMap(PartMap.CENTER.ordinal());
}
return null;
}
}