if ( newType != null )
{
if ( newType.getItem() instanceof IPartItem )
{
IPart testPart = ((IPartItem) newType.getItem()).createPartFromItemStack( newType );
if ( testPart instanceof PartP2PTunnel )
{
getHost().removePart( side, true );
ForgeDirection dir = getHost().addPart( newType, side, player );
IPart newBus = getHost().getPart( dir );
if ( newBus instanceof PartP2PTunnel )
{
PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
newTunnel.output = true;
try
{
P2PCache p2p = newTunnel.proxy.getP2P();
p2p.updateFreq( newTunnel, freq );
}
catch (GridAccessException e)
{
// :P
}
newTunnel.onTunnelNetworkChange();
}
mc.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
return true;
}
}
}
mc.notifyUser( player, MemoryCardMessages.INVALID_MACHINE );
}
else if ( tt != null ) // attunement
{
ItemStack newType = null;
switch (tt)
{
case LIGHT:
newType = AEApi.instance().parts().partP2PTunnelLight.stack( 1 );
break;
case RF_POWER:
newType = AEApi.instance().parts().partP2PTunnelRF.stack( 1 );
break;
case BC_POWER:
newType = AEApi.instance().parts().partP2PTunnelMJ.stack( 1 );
break;
case FLUID:
newType = AEApi.instance().parts().partP2PTunnelLiquids.stack( 1 );
break;
case IC2_POWER:
newType = AEApi.instance().parts().partP2PTunnelEU.stack( 1 );
break;
case ITEM:
newType = AEApi.instance().parts().partP2PTunnelItems.stack( 1 );
break;
case ME:
newType = AEApi.instance().parts().partP2PTunnelME.stack( 1 );
break;
case REDSTONE:
newType = AEApi.instance().parts().partP2PTunnelRedstone.stack( 1 );
break;
default:
break;
}
if ( newType != null && !Platform.isSameItem( newType, this.is ) )
{
boolean oldOutput = output;
long myFreq = freq;
getHost().removePart( side, false );
ForgeDirection dir = getHost().addPart( newType, side, player );
IPart newBus = getHost().getPart( dir );
if ( newBus instanceof PartP2PTunnel )
{
PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
newTunnel.output = oldOutput;