Fixes #24: IndexOutOfBoundsException with FMP parts.

(cherry picked from commit e67969f52f)
This commit is contained in:
Sebastian Hartte 2019-06-23 14:16:46 +08:00 committed by xsun2001
parent a66378a79d
commit c067f5905d
1 changed files with 19 additions and 18 deletions

View File

@ -471,27 +471,28 @@ public class PartCable extends AEBasePart implements IPartCable
boolean[] writeSide = new boolean[ForgeDirection.VALID_DIRECTIONS.length];
int[] channelsPerSide = new int[ForgeDirection.VALID_DIRECTIONS.length];
for( final ForgeDirection thisSide : ForgeDirection.VALID_DIRECTIONS )
{
final IPart part = this.getHost().getPart( thisSide );
if( part != null )
{
writeSide[thisSide.ordinal()] = true;
int channels = 0;
if( part.getGridNode() != null )
{
final IReadOnlyCollection<IGridConnection> set = part.getGridNode().getConnections();
for( final IGridConnection gc : set )
{
channels = Math.max( channels, gc.getUsedChannels() );
}
}
channelsPerSide[thisSide.ordinal()] = channels;
}
}
IGridNode n = this.getGridNode();
if( n != null )
{
for( final ForgeDirection thisSide : ForgeDirection.VALID_DIRECTIONS )
{
final IPart part = this.getHost().getPart( thisSide );
if( part != null )
{
if( part.getGridNode() != null )
{
writeSide[thisSide.ordinal()] = true;
final IReadOnlyCollection<IGridConnection> set = part.getGridNode().getConnections();
for( final IGridConnection gc : set )
{
channelsPerSide[thisSide.ordinal()] = gc.getUsedChannels();
}
}
}
}
for( final IGridConnection gc : n.getConnections() )
{
final ForgeDirection side = gc.getDirection( n );