Fixes an issue with detecting straight cable connections.
This commit is contained in:
parent
b42300a4da
commit
686832ebf8
|
@ -22,6 +22,7 @@ package appeng.parts.networking;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -440,27 +441,39 @@ public class PartCable extends AEBasePart implements IPartCable
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A cable connection is considered straight, if there are exactly two connection points on opposite sides,
|
||||||
|
* and the cable has no attached busses.
|
||||||
|
*/
|
||||||
protected boolean isStraight( IPartHost host, final EnumSet<AEPartLocation> sides )
|
protected boolean isStraight( IPartHost host, final EnumSet<AEPartLocation> sides )
|
||||||
{
|
{
|
||||||
boolean b = false;
|
if (sides.size() != 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<AEPartLocation> it = sides.iterator();
|
||||||
|
EnumFacing firstSide = it.next().getFacing();
|
||||||
|
EnumFacing secondSide = it.next().getFacing();
|
||||||
|
|
||||||
|
// Not on opposite sides
|
||||||
|
if (firstSide.getOpposite() != secondSide) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check any other point for attachments
|
||||||
for( EnumFacing facing : EnumFacing.values() )
|
for( EnumFacing facing : EnumFacing.values() )
|
||||||
{
|
{
|
||||||
b |= host.getPart( facing ) != null;
|
if( facing != firstSide && facing != secondSide )
|
||||||
}
|
|
||||||
if( !b && sides.size() == 2 )
|
|
||||||
{
|
|
||||||
AEPartLocation[] sa = sides.toArray( new AEPartLocation[0] );
|
|
||||||
if( sa[0] == sa[1].getOpposite() )
|
|
||||||
{
|
{
|
||||||
for( AEPartLocation side : sides )
|
// Check for an attached part here
|
||||||
|
if( host.getPart( facing ) != null )
|
||||||
{
|
{
|
||||||
TileEntity to = host.getTile().getWorld().getTileEntity( host.getTile().getPos().offset( side.getFacing() ) );
|
return false;
|
||||||
b |= to instanceof IPartHost && ( (IPartHost) to ).getPart( AEPartLocation.INTERNAL ) instanceof IPartCable && ( (IPartCable) ( (IPartHost) to ).getPart( AEPartLocation.INTERNAL ) ).getCableConnectionType() == getCableConnectionType();
|
|
||||||
}
|
}
|
||||||
return !b;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getChannelsOnSide( final int i )
|
int getChannelsOnSide( final int i )
|
||||||
|
|
Loading…
Reference in a new issue